兰州人 发表于 2008-9-8 16:10:00

selectionset结合Move,rotate使用

Private Sub Form_Load()
Dim tempSet As AcadSelectionSet
Set tempSet = mmm
End Sub
Function mmm() As AcadSelectionSet
Dim Sset As AcadSelectionSet
Set Sset = DrawingGB6170Front(1, 2)
Dim pp(0 To 2) As Double
pp(0) = 100: pp(1) = 100: pp(2) = 0
For ii = 0 To Sset.Count - 1
    Sset.Item(ii).Rotate pp, 90 * 3.1415926 / 180
Next ii
Set mmm = Sset
End Function
Function CreateSelectionSet() As AcadSelectionSet
Dim appAutoCad As AutoCAD.AcadApplication
On Error Resume Next
Set appAutoCad = GetObject(, "AutoCAD.Application")
If Err Then
    Err.Clear
    Set appAutoCad = CreateObject("AutoCAD.Application")
End If
appAutoCad.Visible = True
Dim AcadDoc As AcadDocument
Set AcadDoc = appAutoCad.ActiveDocument
With AcadDoc
    On Error Resume Next
    If Not IsNull(.SelectionSets.Item("MySetSelectionSet")) Then
      Set CreateSelectionSet = .SelectionSets.Item("MySetSelectionSet")
      CreateSelectionSet.Delete
    End If
    Set CreateSelectionSet = .SelectionSets.Add("MySetSelectionSet")
End With
End Function

Function DrawingGB6170Front(xDirection As Double, yDirection As Double) As AcadSelectionSet
    Dim CadEntity As New MyAcadEntity
Dim objModelSpace As AcadModelSpace
Set objModelSpace = CadEntity.objModelSpace
NN = objModelSpace.Count - 1
Dim tempCollection() As AcadEntity
ReDim tempCollection(NN) As AcadEntity
Dim Sset As AcadSelectionSet
For ii = 0 To objModelSpace.Count - 1
Set tempCollection(ii) = objModelSpace.Item(ii)

Set Sset = CreateSelectionSet
Next ii
Sset.AddItems tempCollection
Set DrawingGB6170Front = Sset
End Function

muzi2005888 发表于 2008-9-8 17:04:00

收下学习一下

style6301 发表于 2008-9-23 01:00:00

要是能配上注解就好了,顺便在注上代码的功能、目的、接口等信息
页: [1]
查看完整版本: selectionset结合Move,rotate使用