请教一个多重选择的问题~~
各位大虾:请问一下我用VBA建立了2个或多个不同的图元(比如一个圆和一根线段)我要再使用旋转命令的话不做块如何能一次全部选中进行旋转命令能否举了例子!!谢谢麻烦各位大虾了~
祝各位新年快乐~ 用选择集不行吗? 简单的例子:
Sub ro()
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("ro")
sset.Select acSelectionSetAll
Dim ent As AcadEntity
Dim pnt(0 To 2) As Double
Dim roang As Double
pnt(0) = 100
pnt(1) = 100
pnt(2) = 0
roang = 32
For Each ent In sset
ent.Rotate pnt, roang
Next
End Sub 哦原来如此谢谢绝大虾 哦!不好意思大虾!
可能我的解释有点问题,您的事例只能选择全部的物体,我需要的是建造了3或更多个图元但我只要选择其中的2个或几个图元比如我按顺序建立了1个lineobj和lineobj1和lineobj2这3个图元(建造图元的顺序不能改变)我如何选择lineobj1和lineobj2进行旋转呢?? 既然图元已经建立了,新可以直接用该图元进行旋转,如:
Dim pnt(0 To 2) As Double
Dim roang As Double
pnt(0) = 100
pnt(1) = 100
pnt(2) = 0
roang = 32
lineobj1.Rotate pnt, roang
lineobj2.Rotate pnt, roang 用这个方法创建的选择集是按图元的创建顺序来选择的,你如果要让1,2图元旋转,就选择sset.item(0)和sset.item(1)即可
Sub rota()
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("tmp111")
ReDim ssobjs(0 To ThisDrawing.ModelSpace.Count - 1) As AcadEntity
Dim I As Integer
For I = 0 To ThisDrawing.ModelSpace.Count - 1
Set ssobjs(I) = ThisDrawing.ModelSpace.Item(I)
Next
' Add the array of objects to the selection set
sset.AddItems ssobjs
End Sub 建议采用明总的办法 也就是在你建立图元的时候就把图元赋值给对象变量
页:
[1]