Jump to content
Developer Wiki and Function Reference Links ×

X and Y coordinates


Recommended Posts

Help!

I am trying to create a symbol that inlcludes a text box which will automatically reference the X and Y coordinates from the OIP. I can't write Vector Scripts. Is this the only way of doing this and if so, has anyone written one I could use?

More generally, what is the best way to go about teaching myself Vector Script. Reading through these postings it seems like the thing to do!

Thanks

Grimster

Link to comment

Hi,

A VectorScript recipe for you...

- Go to Organise > Scripts > Create Plug-in...

- Press 'New...', give it a name, choose 'Point Object' and press 'OK'.

- Press 'Proprieties' and check 'Reset on Move' and 'Reset on Rotate'.

- Now press 'Script...' and paste this:

code:

	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;

Lous(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('(',Num2StrF(X),')(',Num2StrF(Y),')' ) {Note there is no ; at the end of this line}

EndText;

END;

RUN (XYText);
[/code]

Then you have to add it to your workspace (File > Workspace Editor), choose 'Edit a copy' and at the 'Tool' tab you'll find it under the 'Miscellaneus' category.

[ 06-07-2005, 10:01 AM: Message edited by: Alexandre B A Villares ]

Link to comment
  • 2 weeks later...

master Alexandre please assist me:

How does one update the 'REAL' XY in text to reflect the actual coordinates of XY? Although the symbol & text are placed properly, createText defaults to the page center origin 0,0 not the true setorigin.

_____________________

PROCEDURE BenchmarkTXT;

VAR

h : HANDLE;

X, Y : REAL;

BEGIN

CallTool(-221);

h := FSActlayer;

GetLocPt(h,X,Y);

TextOrigin(X+.01, Y+.01);

CreateText(Concat('E:', X, '? N:', Y));

Symbol('Benchmark',X,Y,0);

DSelectAll;

END;

RUN(BenchMarkTXT);

___________

thanx in advance eja

Link to comment

Thanx to All ... Here's the update:

________________________________

PROCEDURE BenchmarkTXT;

VAR

h : HANDLE;

X, Y : REAL;

n, i : INTEGER;

objectHand, recordHand, wallHand : HANDLE;

objectName : STRING;

BEGIN

h := FSActLayer;

REPEAT

UNTIL MouseDown(X,Y);

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;

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

FillPat(1); {Set Fill}

Createtext(Concat(' # ['' E:', Num2StrF(X), '?''N:', Num2StrF(Y),']'));

Symbol('Benchmark',X,Y,0);

DSelectAll;

END;

RUN(BenchMarkTXT);

Link to comment
  • 3 weeks later...

Hi islandmon,

I think I don't understand exactly what you want to do.

My example should work as a plug-in object, it shouldn't use MouseDown, and it should be set to regenerate (redraw) when moved, so retrieving it's own new position. The text inside de object should be set using it's internal coordinate system, that is 0,0 like my earlier exemple.

I didn't run your code yet but I think you must be running it as a tool. That's a very different approach.

To run as a tool, you should not use the GetCustomObjectInfo and would draw free standing text objects using the drawing coordinates, perhaps on the MouseDown position...

[ 09-08-2005, 01:25 PM: Message edited by: Alexandre B A Villares ]

Link to comment
  • 3 weeks later...

i am using the above script but am having two problems

1. the x,y values are not the user origin set values, it looks like it is use absalut x,y value. how can i change it to get the x,y based on the user origin.

2. can i create a togle in the object info pallet that changes the script to either get the x value OR the y value

your help is really appreciated

Link to comment
  • 2 months later...

that worked quite well.

Though now I have a new problem....

I select a bunch of objects, then run through them with a while statement.

h := FSActLayer;

while h <> NIL do begin

hCenter(h,x,y);

symbol(sym,x,y);

DelObject(h)

h := NextObj(h);

end;

this code will endlessly execute. Creating thousands of symbols. Because each time a symbol is created it is added to h and thus continues to execute.....Any ideas on how to stop this?

[ 10-12-2005, 01:37 AM: Message edited by: mattb_ ]

Link to comment

mattb,

just a guess...in your loop you are creating a new object each time with the "Symbol(sym,x,y)" call, meaning that you just added another object to the list. So your code will continue to find a NextObj. If you are only iterating over selected objects, deselect the newly created symbol reference, I think it's

"SetDSelect(LNewObj)"

or something like that.

If that doesn't fix the problem, you may have to structure the loop differently, maybe start with the last object and work backward with "PrevObj", or use a "For i:= 1 to ObjectCount do"

Hope this steers you in the right direction.

-Rick Francken

Link to comment

mattb,

It's good in this?

code:

{ code-1 }

Locus(0, 0);

hLoc:= LNewObj;

h := FSActLayer;

while h <> hLoc do begin

hCenter(h,x,y);

symbol(sym,x,y);

hNext:= NextSObj(h);{not NextObj}

DelObject(h);

h := hNext;

end;

DelObject(hLoc);

{ code-2: The symbol is inserted in each original order. }

h := FSActLayer;

while h <> NIL do begin

hCenter(h,x,y);

symbol(sym,x,y);

hSym:= LNewObj;

HMoveBackward(hSym, TRUE);

{ The symbol is moved to the background of object(h).

It's possible to omit this. }

hNext:= NextObj(hSym);

while hNext <> h do begin

HMoveForward(hSym, FALSE);

hNext:= NextObj(hSym);

end;

{ }

hNext:= NextSObj(h);

DelObject(h);

h := hNext;

end;

[/code]

I'm not confirming this code's execution.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...