cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How do you find the extents of a drawing?

TimSharp
6-Contributor

How do you find the extents of a drawing?

When our drawings are converted to CGM's and brought into Word, the text at the top is often cut off slightly. We get round it by drawing a no line box round the drawing, slightly bigger than the geometry. I want to do a little macro to do this automatically, but I do not know how to find the points required. I need bottom left and top right of the geometry of the drawing. How do I retrieve these points?
7 REPLIES 7

I've attached two macros. The first is called Find_Extent. At the start of the macro you need to have an object selected. If you need to determine the extent of multiple objects, group them at the start and then ungroup them at the end. The second creates a no line box within the frame. It could be adjusted to work with an object. Note that in either case, you may want to add an adjustment to the text measurement as IsoDraw adds some whitespace at the bottom to allow for text types. So, basically take the Compare_Bottom variable and ADD .5 to it.
TimSharp
6-Contributor
(To:thendricks)

Thanks Trevor These will be very useful - I actually started trying to use something similar that I think you posted in another thread, but hoped there was an easier way to find the extents of a drawing. The problem is that if the macro groups the items on the drawing, all the layer detail will be lost. I'm wondering if there is a way of checking every element on the drawing regardless of grouping and getting the extents? I was using select all and trying to do select next element, looping through, but I find the macro language difficult to follow and can't yet get it to work. I think if necessary, we could run this macro just at the time of creating the CGM file and make sure the drawing is never saved down again afterwards, thus preserving the layer structure - there are bound to be mistakes though!

Here are a couple different approaches to your problem. 1) You could do a simple workaround that I've had to implement on our side for various issues with 7.0.
60f289931a
This basically saves the file, groups everything, finds the extent, closes the file without saving, and then reopens the version prior to the original macro. It's a dirty way of doing it, but it works. 2) You can loop through each object and basically have a set of variables that represent top/bottom/left/right. Each time you check the extent of an object you could compare the extent against these variables. Note that this could take quite a while depending on complexity of the file. Question: Why are you attempting to bring the CGM into Word?
TimSharp
6-Contributor
(To:thendricks)

Thanks Trevor It amazes me that simple things seem so complicated in Isodraw. Yes your workaround 1 will do it thanks - as you say it's not elegant, but perhaps the only way it can be done. Your solution 2 was the way I was trying to do it, but I have trouble following the syntax of the macro language and hadn't got it working - as you say, it would probably take ages on a complex drawing though. We do technical manuals for military equipment and all our documents have to be in Word. CGM is the only reliable input format we've found to add Isodraw files. I have a comment about your extents macro, but I'll put it in the thread that it was started in

I forgot about this approach yesterday. A third approach, that is a hybrid of my previous suggestions, is to loop through each layer grouping the contents. Here's the basic logic: 1) Define eight variables (i.e. Final_Top and Temp_Top). 2) Get layer count. 3) Loop through each layer locking them. 4) Lock through layers again doing the following on each. a) Unlock the layer. b) Select all c) Group d) Run Find_Extent submacro e) Ungroup f) Select none g) Lock layer h) Run code like this...
57451a6833
I) Repeat loop for next layer. You keep your layers separate, avoid closing the file and reopening, and it is faster than checking each object.

Hi Trevor,

I am new to IsoDraw and their Macro language. How would you get the data out of the macro you wrote? I would like to get the values for the extents for a group of elements.

Keith

thendricks
3-Visitor
(To:JB99)

Use the following set as a sample. Place ism in your macro folder and then open the iso file. Run the Center_Art macro. You'll see the finished result.

Now, start again. This time go to Macros | Macros | Debug Macro..

This will allow you to follow through each step of the macro. You'll see that Compare_ set of variables is what brings each layers X & Y coordinates back. The Final_ set of variables is what tells you the furthest set of points overall.

Note to everyone that this has been updated to work with 7.1. If you have the old version, and have had problems, change the initial value of Final_Left and Final_Right to nine 9's. It appears that 7.1 does not support the ten digits previously supported.

Top Tags