抱歉,没有看到代码格式准则:
- Sub DWG_Combine()
- 'On Error Resume Next
- 'Reads number of objects, moves them based on name, then creates layouts. Finally, explodes all for editing
- Dim i, NumObj, ObjID As Integer
- Dim SS1 As AcadSelectionSet
- Dim MspaceObj As AcadObject
- Dim p1(0 To 2), p2(0 To 2) As Double
- 'set p1 as origin
- p1(0) = 0: p1(1) = 0: p1(2) = 0
- 'selection set?
- If Err.Number <> 0 Then
- Set SS1 = ThisDrawing.SelectionSets.Add("SS1")
- End If
- 'Counts number of objects
- NumObj = ThisDrawing.ModelSpace.Count
- 'MsgBox NumObj
- i = 0
- 'Cycles through each item in the modelspace, reads the ID number, and moves a multiple of the ID Number
- For Each Item In ThisDrawing.ModelSpace
- Set MspaceObj = ThisDrawing.ModelSpace.Item(i)
- 'MsgBox MspaceObj.EffectiveName
- ObjID = Left(Right(MspaceObj.EffectiveName, 2), 1)
- 'MsgBox objID
- p2(0) = (ObjID - 1) * 45: p2(1) = 0: p2(2) = 0
- MspaceObj.Move p1, p2
- i = i + 1
- Next
- End Sub
|