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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Can you find and change line positions in callouts within macros?

TimSharp
6-Contributor

Can you find and change line positions in callouts within macros?

We add lots of callouts to our illustrations and nearly always have to zoom in to each one to move the end of the leader line slightly away from the geometry to make it look cleaner.

I want to do a macro to move callout lines away from geometry automatically, but I need to know the start and end points of the callout to do this. I presume that when you select a callout, Isodraw knows where the start and end points of the leader line are but I don't know how to access this information.

Anyone know if it's possible?

11 REPLIES 11

You can retrieve text, line and background shape of callouts as their children. E.g.:

Message activeDoc.firstSelectedElement.lastChild.line.startPoint.x

prompts the x coordinate of the startpoint if one callout was selected.

Unfortunately these values are read-only. Maybe you can get around this

by creating a new callout that replaces the existing one and copy its values?

TimSharp
6-Contributor
(To:bgraffmann)

Thanks for your help. I can find the start point of the callout with this method no problem, but when I try doing the end point using

activeDoc.firstSelectedElement.lastChild.line.segments[1].endPoint.x

I get an "Unknown macro command" error. I presume the syntax isn't right somewhere.

Your suggestion to replace callout with new ones will hopefully work for me.

For me the syntax works exactly as you wrote above.
You should doublecheck if the callout is really selected (and no other elements are).

Please note that some callouts might not have a leader line at all, and you can not rely on the fact

that the line is always the last child (check the type of lastChild, firstChild, firstChild.nextSibling and so on.)

TimSharp
6-Contributor
(To:bgraffmann)

That's strange. However, I'm making them into variables so I can use them to re-create the callouts - maybe it's this that causes the problems?

To test, I first select a callout, then run the macro.

This is my code snippet:

define text_pos_x as float

define text_pos_y as float

text_pos_x = (activeDoc.firstSelectedElement.lastChild.line.startPoint.x)

text_pos_y = (activeDoc.firstSelectedElement.lastChild.line.startPoint.y)

define text_pos2_x as float

define text_pos2_y as float

# NEXT 2 LINES DON'T WORK - GIVES AN "UNKNOWN MACRO COMMAND" ERROR.

text_pos2_x = (activeDoc.firstSelectedElement.lastChild.line.segments[1].endPoint.x)

text_pos2_y = (activeDoc.firstSelectedElement.lastChild.line.segments[1].endPoint.y)

I copied your lines and they worked fine here again.

Are you running 7.2 ?

TimSharp
6-Contributor
(To:bgraffmann)

Ah that will be it - I thought these were all old commands.

No we're running 7.0. We tried 7.1 and it had so many problems for us that we went back to 7.0.

I'll see if we can upgrade as I hope the problems we had will have been sorted.

TimSharp
6-Contributor
(To:TimSharp)

Actually I don't think the version of Isodraw is the problem, the problem seems to be that I'm looking for the start AND end points of the leader line of a callout.

If I select a normal line and run it, it finds both ends OK, but if I select a callout, it gets the start point OK then gives the macro error when it tries to set the end point.

We only use simple callouts, i.e. with a single segment leader line - isn't there a way of getting the start and end points of these leader lines?

define text_pos_x as float

define text_pos_y as float

text_pos_x = (activeDoc.firstSelectedElement.lastChild.line.startPoint.x)

text_pos_y = (activeDoc.firstSelectedElement.lastChild.line.startPoint.y)

define text_pos2_x as float

define text_pos2_y as float

# NEXT 2 LINES DON'T WORK WHEN A CALLOUT IS SELECTED - GIVES AN "UNKNOWN MACRO COMMAND" ERROR.

text_pos2_x = (activeDoc.firstSelectedElement.lastChild.line.segments[1].endPoint.x)

text_pos2_y = (activeDoc.firstSelectedElement.lastChild.line.segments[1].endPoint.y)

Hi Tim,

Using the above coding your extracting the X and Y for start and end coordinate. keeping this values you can place a new callout with the same selected callout with the required coordinate values. Before that you have to delete the existing callout using macro command. Before deleting please assign the callout values to a variable for the new callout.

TimSharp
6-Contributor
(To:Vaduga1)

Thanks, but unfortunately the end 2 points won't work - it gives an UNKNOWN MACRO COMMAND error when trying to return the end 2 values. It might just be something in my syntax -

text_pos2_x = (activeDoc.firstSelectedElement.lastChild.line.segments[1].endPoint.x)

All our callouts have just 1 segment. Should I be using something else inside the square [1] brackets?

Tim, I don't see anything wrong with your Syntax. I double checked that it works even for 7.0 F000. First index for segments[] and others is always 1 in IsoDraw Macro Language.

Is your callout really the first (better the only!) selected element? Not grouped or maked? Try:

Message exists(activeDoc.firstSelectedElement)
# Should show "true"
Message activeDoc.firstSelectedElement.type
# Should show "callout"

Does the selected callout really have a leader line? Try:

Message exists(activeDoc.firstSelectedElement.firstChild.nextSibling.nextSibling)
# Should show "true" (The selected element has three internal children)
Message activeDoc.firstSelectedElement.firstChild.type
# Should show "text"
Message activeDoc.firstSelectedElement.firstChild.nextSibling.type
# Should show "rectangle"
Message activeDoc.firstSelectedElement.firstChild.nextSibling.nextSibling.type
Message activeDoc.firstSelectedElement.lastChild.type
# Should both show "line"

The order of the internal children is not guaranteed. If the line is not the last one in your case, now you know how to find it. (Instead of "Message" commands you could also use "Log" and look up your macro.log afterwards)

Sometimes "Unknown Macro Commands" appear if a your macro contains some strange characters, e.g. if you copied them from word. Try to type your failing macro lines again in a plain text editor as a final attempt.

TimSharp
6-Contributor
(To:bgraffmann)

Thanks very much for your help. I think I might be getting somewhere now - it might have been the tab's in the text that did it. I'll try to get some more time next week to look at it. Thanks again.

Top Tags