[求助]提示Select 在SelectionSet上失败!请高手指教!!
Dim mysel As AcadSelectionSet<BR>dim gpcode(2) as integer<BR>dim gpvalue(2) as variant<BR>dim groupcode as variant<BR>dim groupvalue as variantgpcode(0) = 0 : gpvalue(0) = "insert"<BR>gpcode(1) = -4 : gpvalue(1) = "="<BR>gpcode(2) = 2 : gpvalue(2) = blockr.name<BR>groupcode = gpcode<BR>groupvalue = gpvalue<BR>set mysel = acaddoc.SelectionSets.Add("mysel")<BR>mysel.select acSelectionSetAll,,,groupcode,groupvalue
在运行到mysel.select acSelectionSetAll,,,groupcode,groupvalue这句时,提示Select 在SelectionSet 上失败!请高手指教!!
回复
你写的还挺离谱:<PRE class=Code>Sub Example_Select()
' This example adds members to a selection set, first by crossing and
' then by filtering for circles.
' Create the selection set
Dim ssetObj As AcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")
' Add all object to the selection set that lie within a crossing of (28,17,0) and
' (-3.3, -3.6,0)
Dim mode As Integer
Dim corner1(0 To 2) As Double
Dim corner2(0 To 2) As Double
mode = acSelectionSetCrossing
corner1(0) = 28: corner1(1) = 17: corner1(2) = 0
corner2(0) = -3.3: corner2(1) = -3.6: corner2(2) = 0
ssetObj.Select mode, corner1, corner2
' Add all the Circles to the selection set that lie within the crossing of (28,17,0) and
' (-3.3, -3.6,0) by filtering from the current drawing
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
gpCode(0) = 0
dataValue(0) = "Circle"
Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue
ssetObj.Select mode, corner1, corner2, groupCode, dataCode
End Sub</PRE> blockr是我得到的AcadBlockreference对象
blockr.name 是我得到了块名,经检查确实得到了。
acaddoc 是我得到的ActivateDocument 这也是没有错的
gpcode(0) = 0 : gpvalue(0) = "insert"<BR>gpcode(1) = -4 : gpvalue(1) = "="<BR>gpcode(2) = 2 : gpvalue(2) = blockr.name<BR>我是想得到以blockr.name为过滤条件的选择集
Dim mysel As AcadSelectionSet<BR>dim gpcode(2) as integer<BR>dim gpvalue(2) as variant<BR>dim groupcode as variant<BR>dim groupvalue as variant
gpcode(0) = 0 : gpvalue(0) = "insert"<BR>gpcode(1) = -4 : gpvalue(1) = "="<BR>gpcode(2) = 2 : gpvalue(2) = blockr.name<BR>groupcode = gpcode<BR>groupvalue = gpvalue<BR>set mysel = acaddoc.SelectionSets.Add("mysel")<BR>mysel.select acSelectionSetAll,,,groupcode,groupvalue
mysel.select acSelectionSetAll,,,groupcode,groupvalue 这句就是过不去啊<BR>
我用的是VB Dim ss As AcadSelectionSet
Set ss = CreatSSet
Dim FilterType As Variant
Dim FilterData As Variant
Dim FType(1) As Integer
Dim FData(1) As Variant
FType(0) = 0
FData(0) = "INSERT" '图元名
FType(1) = 2
FData(1) = "B-BTL" '图块名
FilterType = FType
FilterData = FData
ss.Select acSelectionSetAll, , , FilterType, FilterData
以下是用到的创建空白选择集的函数:Function CreatSSet() As AcadSelectionSet
On Error Resume Next
ThisDrawing.SelectionSets("mccad").Delete
Set CreatSSet = ThisDrawing.SelectionSets.Add("mccad")
End Function
页:
[1]