好吧,是的,我觉得自己现在连问这个问题都像个白痴
对于那些想知道
- Public Sub GetSSBoundingBox(ss As AcadSelectionSet, ptMin As Variant, ptMax As Variant)
- Dim entItem As AcadEntity
- Dim ptImin As Variant
- Dim ptImax As Variant
- Const X = 0
- Const Y = 1
- ss(0).GetBoundingBox ptMin, ptMax
- For Each entItem In ss
- entItem.GetBoundingBox ptImin, ptImax
- If ptImin(X) < ptMin(X) Then ptMin(X) = ptImin(X)
- If ptImin(Y) < ptMin(Y) Then ptMin(Y) = ptImin(Y)
- If ptImax(X) > ptMax(X) Then ptMax(X) = ptImax(X)
- If ptImax(Y) > ptMax(Y) Then ptMax(Y) = ptImax(Y)
- Next
- End Sub
下面是如何调用函数
- Public Sub FlipTest()
- Dim ssFlip As AcadSelectionSet
- Dim pt1 As Variant
- Dim pt2 As Variant
- ' get selection set from user
- Set ssFlip = ThisDrawing.SelectionSets.Add("flip")
- ssFlip.SelectOnScreen
-
- ' get bounding box of selection set
- GetSSBoundingBox ssFlip, pt1, pt2
-
- ' draw a line from point to point
- ThisDrawing.ModelSpace.AddLine pt1, pt2
-
- ssFlip.Delete
-
- End Sub
|