再加一点
- Private Sub FindTheBlock()
- Dim oBref As AcadBlockReference
- Dim B As AcadBlock
- Dim Pt As Variant
- Dim C As AcadCircle
- Dim X As Double
- Dim Ent As AcadEntity
- 'get the BlockReference
- ThisDrawing.Utility.GetEntity oBref, Pt, "Pick a block reference:"
- 'Use the BlockReference's name to find the block definition
- Set B = ThisDrawing.Blocks(oBref.Name)
- 'Cycle through the entities in the block
- For Each Ent In B
- If TypeOf Ent Is AcadCircle Then
- 'Store the circle in an object variable
- Set C = Ent
- Exit For
- End If
- Next Ent
-
- Dim L As AcadLine
- ThisDrawing.Utility.GetEntity L, Pt, "Pick a line:"
- L.Move oBref.InsertionPoint, B.Origin
- Pt = L.EndPoint
- 'circle formula x^2+y^2=radius^2
- X = Sqr(C.radius ^ 2 - Pt(1) ^ 2)
- If Pt(0) < 0 Then X = -X
- Debug.Print Pt(0), X
- If Abs(Pt(0) - X) < 0.00000001 Then
- MsgBox "The line ends on the circle."
- End If
- L.Move B.Origin, oBref.InsertionPoint
-
- End Sub
现在,如果拾取的块引用的旋转为零,法线值为(0,0,1)
则圆';s中心;块参考与块参考插入点的距离和方向相同,因为块圆中心与块#039;s原点
|