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

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

Share this post


Link to post

Do you want to reference the X and Y coordinates of the currently selected object? Or one specific object?

Elaborate a bit more on what you want it to do.

Share this post


Link to post

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 ]

Share this post


Link to post

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

Share this post


Link to post

EJ

Your script works as it should on my system. Not sure why...some preference setting perhaps?

BTW...have a look at MouseDown. Unless you have some other need of these loci, it would replace CallTool,FSAct and GetLoc.

Later

Charles

Share this post


Link to post

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);

Share this post


Link to post

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 ]

Share this post


Link to post

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

Share this post


Link to post

I'm having a similar problem.

How do I get the location of a group centre?

I need to convert a group to a symbol, but can't get the group location in xy.....help?

Share this post


Link to post

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_ ]

Share this post


Link to post

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

Share this post


Link to post

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.

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.

×