这段代码为什么会这样的错误------“方法'SelectOnScreen'作用于对象 ‘IAcadSelectionSet’时失败”
Sub try() Dim ssetObj As AcadSelectionSet Set ssetObj = ThisDrawing.SelectionSets.Add("Test") Dim FilterType As Integer Dim FilterData As String
FilterType = 0 FilterData = "line" ssetObj.SelectOnScreen FilterType, FilterData ssetObj.Delete End Sub
改成:
Sub try() Dim ssetObj As AcadSelectionSet Set ssetObj = ThisDrawing.SelectionSets.Add("Test") Dim FilterType(0) As Integer Dim FilterData(0) As String
FilterType(0) = 0 FilterData (0) = "line" ssetObj.SelectOnScreen FilterType, FilterData ssetObj.Delete End Sub
FilterType 和FilterData都应该是数组。
VB代码,看看能否给你提示,估计问题出现在数据类型上
Set sset = AcadDoc.SelectionSets.Add("mys") '创建选择集 Dim myss As Object 'Set myss = sset.Add("mys") '定义过滤组码数据 Dim gpcode(0) As Integer Dim datavalue(0) As Variant gpcode(0) = 0 datavalue(0) = "text" '注意组码以及组码值的数据类型的转化 Dim groupcode As Variant Dim datacode As Variant groupcode = gpcode datacode = datavalue '选择所有的文本 Call sset.SelectOnScreen(groupcode, datacode)