TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

When replying to a specific statement be sure to quote the previous post.

Getting the X,Y World Coordinates of the Upper Right hand Corner of a Drawing
Read 5126 times
* July 31, 2009, 06:36:13 PM
Does anyone know how to get the upper right hand coordinates of a TurboCad drawing using either VB or VBA?

I know how to Set up Turcocad objects and reference their properties.  What I can't figure out is what properties of what objects I need to access to obtain the coordinates of the upper right hand corner of the drawing.

Any help would be appreciated.


* August 01, 2009, 01:56:24 PM
I was able to figure it out and thought I would post the solution.

Run this in an Excel VBA module with a reference set to TurboCad v4.1 programmable objects.

Sub Drawing_Extents() 'Gets the full drawing extents in world coordinates
'Declare variables
   Dim TurboCad_Application As IMSIGX.Application
   Dim Bounding_Box As IMSIGX.BoundingBox
   Dim Drawing_Graphics As IMSIGX.Graphics
'Create a reference to the current instance of TurboCad
      Set TurboCad_Application = GetObject(, "TurboCAD.Application")
'Create a reference to the Graphics Collection of the Active Drawing
      Set Drawing_Graphics = TC_app.ActiveDrawing.Graphics
'Create a reference to the Bounding Box that encompasses theGraphics Collection of the 'Active Drawing
      Set Bounding_Box = Drawing_Graphics.CalcBoundingBox
'Print the bounding box limits to the debug window
      Debug.Print "min: " & Bounding_Box.Min.X & ", " & Bounding_Box.Min.Y & ", " &_                        Bounding_Box.Min.Z
      Debug.Print "max: " & Bounding_Box.Max.X & ", " & Bounding_Box.Max.Y & ", " &_                       Bounding_Box.Max.Z
'Set all references to nothing
      Set Bounding_Box = Nothing
      Set Drawing_Graphics = Nothing
      Set TurboCad_Application = Nothing
End Sub