显示找不到“AcadSelectionSet”???
请帮忙分析一下下面的代码,谢谢先~~
Dim obj_Acad As Object, obj_Doc As Object, obj_ModelSpace As Object 'Application对象、Document对象、ModelSpace对象 Public Sub AutoCADOpen(FileName As String) '打开AutoCAD子程序 On Error Resume Next Set obj_Acad = GetObject(, "autocad.application") '若AutoCAD已启动,则直接得到Application对象,建议先打开CAD程序 If Err Then Err.Clear On Error Resume Next Set obj_Acad = CreateObject("autocad.application") '若AutoCAD未启动,则运行AutoCAD程序 If Err Then Err.Clear MsgBox "不能运行AutoCAD,请检查是否安装!", vbOKOnly, "警告!" Exit Sub End If End If obj_Acad.Visible = True '设置AutoCAD为可见(或者在后台运行,不可见) obj_Acad.Documents.open (FileName) '打开AutoCAD图形文件 Set obj_Doc = obj_Acad.ActiveDocument '获得当前活动图形文件,即刚打开的图形文件 Set obj_ModelSpace = obj_Doc.ModelSpace '获得当前活动图形文件的模型空间
On Error Resume Next
Dim MySet As AcadSelectionSet Dim FilterType(0) As Integer Dim FilterData(0) As Variant
ThisDrawing.SelectionSets.Item("MySet ").Delete
FilterType(0) = 0: FilterData(0) = "LWPOLYLINE,INSERT" Set MySet = ThisDrawing.SelectionSets.Add("MySet ") MySet.Select acSelectionSetAll, , , FilterType, FilterData
Dim i As Integer
Dim Bobj As Object
For i = 0 To MySet.Count - 1 If MySet(i).ObjectName = "AcDbPolyline" Then MySet(i).explode MySet(i).Delete Else For Each Bobj In ThisDrawing.Blocks(MySet(i).Name) If Bobj.ObjectName = "AcDbPolyline" Then Bobj.explode Bobj.Delete End If Next End If Next
End Sub
MsgBox "运行结束!", vbOKOnly, "工程1!" End Sub |