问count的用法。
能用count获得自定义的选择集中项目的个数吗?具体怎么样实现? ssetObj.Count Sub example_select()<BR> On Error Resume Next<BR> <BR> Dim myss As AcadSelectionSet<BR> If Not IsNull(ThisDrawing.SelectionSets.Item("myss")) Then<BR> Set myss = ThisDrawing.SelectionSets.Item("myss")<BR> myss.detele<BR> End If<BR> <BR> Set myss = ThisDrawing.SelectionSets.Add("myss")<BR> <BR> Dim mode As Integer<BR> mode = acSelectionSetAll<BR> myss.Select mode<BR> <BR> Dim returnobj As Object<BR> <BR> Dim re As Variant<BR> ThisDrawing.Utility.GetEntity returnobj, "Ñ¡ÔñÒ»¸öͼÏñ:"<BR> <BR> returnobj.color = acRed<BR> returnobj.Update<BR> startpoint = returnobj.startpoint<BR> endpoint = returnobj.endpoint<BR> re = returnobj.ObjectName<BR> MsgBox "×ø±êÆðµã" & startpoint(0) & "," & startpoint(1) & "," & startpoint(2) & " ÖÕµã " & endpoint(0) & "," & endpoint(1) & "," & endpoint(2) & " id " & re<BR> returnobj.color = acByLayer<BR> returnobj.Update<BR> myss.RemoveItems returnobj<BR> <BR> <BR> MsgBox " ¸öÊý " & myss.count<BR> <BR> <BR>End Sub
为什么运行后是3个,难道myss.RemoveItems returnobj没有用? returnobj必须为图元数组,而不是图元。<BR>程序中GetEntity中的参数缺少,这样的结果是returnobj连图元都没返回 可以帮我改一下让我看看吗?
光看书发现好多弄不懂啊。 Sub example_select()
On Error Resume Next
Dim myss As AcadSelectionSet
If Not IsNull(ThisDrawing.SelectionSets.Item("myss")) Then
Set myss = ThisDrawing.SelectionSets.Item("myss")
myss.detele
End If
Set myss = ThisDrawing.SelectionSets.Add("myss")
Dim mode As Integer
mode = acSelectionSetAll
myss.Select mode
MsgBox "选择集数量" & myss.Count
Dim returnobj(0) As Object
Dim returnpnt As Variant
Dim re As Variant
ThisDrawing.Utility.GetEntity returnobj(0), returnpnt, "选择直线:"
returnobj(0).color = acRed
returnobj(0).Update
Dim StartPoint, EndPoint
StartPoint = returnobj(0).StartPoint
EndPoint = returnobj(0).EndPoint
re = returnobj(0).ObjectName
MsgBox "起点 " & StartPoint(0) & "," & StartPoint(1) & "," & StartPoint(2) & " 终点 " & EndPoint(0) & "," & EndPoint(1) & "," & EndPoint(2) & " id " & re
returnobj(0).color = acByLayer
returnobj(0).Update
myss.RemoveItems returnobj
MsgBox "选择集数量" & myss.Count
End Sub 真是太感谢了,学二次开发三个多星期了。
发现看书好多东西弄不懂。
以后希望能够多多向您请教。
页:
[1]