资源描述:
《autocad vba程序---批量插入块源代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、AutoCADVBA程序---批量插入块源代码OptionExplicitPrivateSubcmdClear_Click() Me.lstFile.ClearEndSubPrivateSubcmdDelete_Click() IflstFile.ListCount>=1Then IflstFile.ListIndex=-1Then MsgBox"请选择列表中的图形名称!",vbExclamation,Me.Caption ExitSub EndIf
2、 lstFile.RemoveItem(lstFile.ListIndex) EndIfEndSubPrivateSubcmdInsert_Click() DimiAsInteger DimpntX(0To2)AsDouble WithMe pntX(0)=0#:pntX(1)=0#:pntX(2)=0# If.lstFile.ListCount=0ThenExitSub .pbInsert.Value=0 .pbInsert.Max=.lstFile.ListCount Fori
3、=0To.lstFile.ListCount-1 .lstFile.ListIndex=i ThisDrawing.Application.ActiveDocument.ModelSpace.InsertBlockpntX,.lstFile.List(i),1,1,1,0 .pbInsert.Value=.pbInsert.Value+1 Nexti MsgBox"批量插入块完毕。",vbInformation,.Caption UnloadMe EndWithEndS
4、ubPrivateSubcmdOpen_Click() DimiAsInteger DimYAsInteger DimZAsInteger DimfileNames()AsString OnErrorGoToerrHandle WithcomDlg .CancelError=True .MaxFileSize=32767 .Flags=cdlOFNHideReadOnlyOrcdlOFNAllowMultiselectOrcdlOFNExplorerOrcd
5、lOFNNoDereferenceLinks .DialogTitle="选择图形文件" .filter="图形文件(*.dwg)
6、*.dwg" .FileName="" .ShowOpen EndWith comDlg.FileName=comDlg.FileName&Chr(0) Z=1 Fori=1ToLen(comDlg.FileName) i=InStr(Z,comDlg.FileName,Chr(0)) Ifi=0Th
7、enExitFor ReDimPreservefileNames(Y) fileNames(Y)=mID(comDlg.FileName,Z,i-Z) Z=i+1 Y=Y+1 Nexti DimcountAsInteger count=lstFile.ListCount IfY=1Then IfNotHasItem(fileNames(Y-1))Then lstFile.AddItemfileNames(Y-1),coun
8、t EndIf Else Fori=1ToY-1 IfStrComp(Right$(fileNames(0),1),"")=0Then fileNames(i)=fileNames(0)&fileNames(i) Else fileNames(i)=fileNames(0)&""&fileNames(i) EndIf IfNotH
9、asItem(fileNames(i))Then lstFile.AddItemfileNames(i),i-1+count EndIf Nexti EndIferrHandle:EndSubPrivateSublstFile_DblClick(ByValCancelAsMSFor