Private Sub Command1_Click()
Dim ssetobj As acadselectionset
Set ssetobj = acadapp.activedocument.selectionsets.Add("test")
AppActivate acadapp.Caption
Dim ftype(0) As Integer
Dim fdata(0) As Variant
ftype(0) = 0
fdata(0) = "circle"
Dim filtertype As Variant
Dim filterdata As Variant
filtertype = ftype
filterdata = fdata
ssetobj.SelectOnScreen filtertype, filterdata
AppActivate Form1.Caption
Dim pickedobjs As acadentity
For Each pickedobjs In ssetobj
pickedobjs.highlight (ture)
pickedobjs.Update
Next
ssetobj.Delete
end Sub
调试时,一直提示没有对象.
on error resume next
Set ssetobj = acadapp.activedocument.selectionsets("test")
if err then set ssetobj=acadapp.activedocument.selectionsets.add("test")
on error goto 0
AppActivate acadapp.Caption
Dim ftype(0) As Integer
Dim fdata(0) As Variant
ftype(0) = 0
fdata(0) = "circle"
AppActivate Form1.Caption
' 可以用ssetobj.count来判断选择集中的实体数目。
Dim pickedobjs As acadentity
For Each pickedobjs In ssetobj
pickedobjs.highlight (ture)
pickedobjs.Update
Next
ssetobj.Delete
'当一个过程结束时,要养成手动清除对象变量的习惯,以免各种原因引进内存泄露。
set ssetobj=nothing
end Sub