Heath Posted December 1, 2005 Share Posted December 1, 2005 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. Quote Link to comment
MullinRJ Posted December 1, 2005 Share Posted December 1, 2005 Use the following and subtract these values from your point. GetOrigin(Xorig, Yorig); Raymond Quote Link to comment
Heath Posted December 1, 2005 Author Share Posted December 1, 2005 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); Quote Link to comment
MullinRJ Posted December 1, 2005 Share Posted December 1, 2005 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 Quote Link to comment
MullinRJ Posted December 2, 2005 Share Posted December 2, 2005 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 Quote Link to comment
Heath Posted December 2, 2005 Author Share Posted December 2, 2005 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 Quote Link to comment
MullinRJ Posted December 2, 2005 Share Posted December 2, 2005 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.