TheSwamp
Code Red => VB(A) => Topic started by: CadRover on July 06, 2008, 04:08:26 PM
-
Does anyone know if it is possible to actually see the bounding box of an entity in ACAD?
If so, does anyone have any VBA code examples of this?
Thanks
CAD
-
Here is what you want
Option Explicit
Public Sub BoundingBoxTest()
Dim oEnt As AcadEntity
Dim varPt As Variant
Dim MaxPoint As Variant
Dim MinPoint As Variant
Dim Vertices(0 To 9) As Double
Dim oPline As AcadLWPolyline
ThisDrawing.Utility.GetEntity oEnt, varPt, vbCrLf & "Select object"
oEnt.GetBoundingBox MinPoint, MaxPoint
Vertices(0) = MinPoint(0)
Vertices(1) = MinPoint(1)
Vertices(2) = MaxPoint(0)
Vertices(3) = MinPoint(1)
Vertices(4) = MaxPoint(0)
Vertices(5) = MaxPoint(1)
Vertices(6) = MinPoint(0)
Vertices(7) = MaxPoint(1)
Vertices(8) = MinPoint(0)
Vertices(9) = MinPoint(1)
Set oPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(Vertices)
oPline.color = acYellow
End Sub
~'J'~
-
Fix,
That seems to be working very well, thank you.
Hey, just thought of something; you could add this bit of code to the end
if you'd like to retreive the actual points in the immediate window
Dim i As Integer
For i = 0 To 9
Debug.Print "Vertice Pnt"; (i); Vertices(i)
Next i
That should work
CAD
-
Nice shot
Glad you solved it by yourself
Happy computing :-)
~'J'~
-
Yes, thanks
Having the points are always good if you want to do something further with the entity, like calc the midpnt, move it etc