Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
Heath

Labeling x and y coordinates on drawing

Recommended Posts

I am trying to find a way to display the x and y coordinates of a point on a drawing. I have found a few vector scripts that will do this using the page center 0,0. I need to display x and y coordinates after I have re-set the origin to a different point.

Share this post


Link to post

Use the following and subtract these values from your point.

GetOrigin(Xorig, Yorig);

Raymond

Share this post


Link to post

MullinRJ

I am not real smart on scripts. I have only used ones the people have shared in this forum. I have never written my own. Here is the script I have. Can you tell me how to add your suggestions?

Thanks a bunch.

Heath

PROCEDURE XYText;

VAR

objectHand, recordHand, wallHand : HANDLE;

objectName : STRING;

X, Y : REAL;

BEGIN

IF GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand) THEN BEGIN {Get Object info}

SetObjectVariableBoolean (objectHand,800,TRUE); {Let the text style be changed by the user from outside}

GetSymLoc(objectHand, X, Y); {Get Object Position}

END;

Locus(0,0); {Something to see, won't print}

TextOrigin (0,0); {Set text position, note the object internal coordinate system)}

FillPat(0); {Set Fill to None}

BeginText;

Concat('E ',Num2StrF(X),' N ',Num2StrF(Y),'' ) {Note there is no ; at the end of this line}

EndText;

END;

RUN (XYText);

Share this post


Link to post

In a script that is used in a palette, you can use GetOrigin(), but the script you are copying appears to be headed for a PIO.

GetCustomObjectInfo() is used in PIO's, but not in stand alone scripts.

GetOrigin() doesn't work in PIO's.

It looks like you are trying to make a tool that places a position marker where you click. I will be out for several hours, but if anyone else wants to have a go at this, please have at it.

Raymond

Share this post


Link to post

Heath,

This is not the most elegant solution, but it will work in a PIO. Move your origin, create a locus and put it at (0, 0) which is your new origin. In the OIP, go to the DATA pane and give it the name ORIGIN. Any name will do. Lock it.

Then in your script, use:

GetLocPt(GetObject('Origin'), Xorig, Yorig);

These values are then subtracted from X & Y in your Concat statement to adjust your displayed text. (Note, Num2Str is not needed inside Concat.) If you move your origin, you will have to move the named locus to the new origin before updating your PIO's. You can also write a small script to place and lock the reference locus.

The named locus does not have to be on the layer you where are working, nor does it have to be visible. You can place it on a layer of its own and hide it if you like. Then it is out of the way and not likely to get moved accidently. (You can even hide it in a Symbol Definition, if you are careful not to purge unused objects.)

code:

PROCEDURE XYText;

VAR

objectHand, recordHand, wallHand : HANDLE;

objectName : STRING;

X, Y, Xorig, Yorig : REAL;

BEGIN

GetLocPt(GetObject('Origin'), Xorig, Yorig);

IF GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand) THEN BEGIN { Get Plug-In Object info }

SetObjectVariableBoolean (objectHand, 800, TRUE); { Let the text style be changed by the user from outside }

GetSymLoc(objectHand, X, Y); { Get Object Position }

Locus(0, 0); { Something to see, won't print }

TextOrigin (0, 0); { Set text position, note the object internal coordinate system) }

FillPat(0); { Set Fill to None }

BeginText;

Concat('E ', X-Xorig, ' N ', Y-Yorig) { Note there is no ; at the end of this line }

EndText;

END;

END;

RUN (XYText);
[/code]

HTH,

Raymond

Share this post


Link to post

MullinRJ

Thanks so much for the help. This is what I was looking for. The only thing I would like to change is to be able to round to 2 decimal places instead of carrying the number all the way out to 10 decimal places. Is there an easy way to do this? Once again thanks for all the help.

Heath

Share this post


Link to post

Heath,

You are welcome. Yes. If your drawing units are set to 2 decimals then you can put back the Num2StrF(X-Xorig) function, but you'll get the units mark appended to the numbers if it is also selected in the Units setup. You may want this. Num2Str(2, X-Xorig) will give you 2 decimals without unit marks appended.

Raymond

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×