yu-gn 发表于 2002-12-12 15:54:00

请帮忙改正,谢谢!

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
调试时,一直提示没有对象.

efan2000 发表于 2002-12-12 19:22:00

Re:请帮忙改正,谢谢!

Private Sub Command1_Click()
Dim ssetobj As acadselectionset

' 这里应检测该名称的选择集是否存在,CAD不允许创建已经存在的选择集。
'Set ssetobj = acadapp.activedocument.selectionsets.Add("test")

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"

' 选择集的过滤机制是要求整型数组的类型和变体型数组的数据。因而下面的定义是画蛇添足,没必要。
'Dim filtertype As Variant
'Dim filterdata As Variant
'filtertype = ftype
'filterdata = fdata
' 这里选择对象时,最好先隐藏本身的窗体,即使窗体是非模态的。
'ssetobj.SelectOnScreen filtertype, filterdata

me.hide
ssetobj.SelectOnScreen ftype, fdata

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

yu-gn 发表于 2002-12-12 23:06:00

怎么还不可以用呢???

efan2000 发表于 2002-12-13 12:51:00

Re: 怎么还不可以用呢???(

你调试一下吧。
对了,pickedobjs.Highlight (True),里面应为True,而不是ture。
页: [1]
查看完整版本: 请帮忙改正,谢谢!