# formula for symbol's insertion point x and y coordinates

## Recommended Posts

What's the formula for a cell in database header row to get the symbol's insertion point X or Y value? The one which is in OIP?

=XCenter or =YCenter are wrong because they give something like coordinate of center of all geometry the symbol has, not insertion point coordinates.

If you use the criteria = SymbolName, then use the functions =XCenter, YCenter

in the formula cells. The insert point of the Symbol with be the result:

=DATABASE(INSYMBOL & (S='Symbol-1'))

I am not seeing that. I am getting the center of the symbol using the criteria given above. I am getting the same results using the symbol name as I am using a simple T=Symbol criteria.

Tested with a square made into a symbol with the insertion point located at one corner.

If you use the criteria = SymbolName, then use the functions =XCenter, YCenter

in the formula cells. The insert point of the Symbol with be the result:

=DATABASE(INSYMBOL & (S='Symbol-1'))

I did use =XCenter and YCenter and I'm getting wrong coordinates. What I entered (and what I see in OIP) is:

Nr. _ X __ Y

9 _ -15 __ -20

10 _ 55 __ 21

11 _ 10 __ 50

12 _ 75 _ 115

13 _ 13 _ 113

What I get from worksheet is:

Nr. ___ X ______ Y

9 ___ 2.425 __ -0.137

10 _ 72.425 __ 40.863

11 _ 27.425 __ 69.863

12 _ 92.425 _ 134.863

13 _ 30.425 _ 132.863

See attached file.

NNA gurus - what's your opinion about retrieving X, Y (and Z) coordinates of symbols in a worksheet?

Edited by Yancka

I believe you'll need a data record and a script that puts the coordinates into the record. In VectorScript, there is the call

GetSymLoc3D(xLoc, yLoc, zLoc);

for the purpose.

Depending on your situation, x/y/z coordinates could either be a part of "bigger" data record (recommended approach) or in a specific record (which could have other purposes as well.)

Since the values do not go into the data record automatically, you will need also a menu command.

And so on and so on and scooby-dooby doo-be? Diff'rent strokes for dff'rent folks. This everyday people would just like to be able to report the insertion point coordinates, despite his ability to script things. Totally, shockingly stupid that it's not immediately possible.

So, let's see. This may or may not work:

[font:Courier New]PROCEDURE LetTheRecordShowTheCoordinates;

{ ? Petri Sakkinen 2009, some sort of a licence to use etc etc }

CONST

????recordName = 'your_data_record';

????xCoordField = 'of_the_number_type_for_X';

????yCoordField = 'of_the_number_type_for_Y';

????zCoordField = 'of_the_number_type_for_Z';

VAR

????xLoc, yLoc, zLoc : REAL;

????

PROCEDURE PutData (h : HANDLE);

BEGIN

????GETSYMLOC3D(h, xLoc, yLoc, zLoc);

????SETRECORD(h, recordName);

????SETRFIELD(h, recordName, xCoordField, NUM2STRF(xLoc));

????SETRFIELD(h, recordName, yCoordField, NUM2STRF(yLoc));

????SETRFIELD(h, recordName, zCoordField, NUM2STRF(zLoc));

END;

BEGIN

????FOREACHOBJECT(PutData, T=Symbol);

END;

RUN(LetTheRecordShowTheCoordinates);

[/font]

In the report you then need to have formulae that refer to 'your_data_record' and the relevant fields.

Indeed "shockingly stupid that it's not immediately possible" and extra step is necessary to "update" the coordinates. Thanks Kool Aid for making this step as one-click-foolproof-step instead of mumble-jumble all the time!

Me wonders - haven't functions for retrieving symbol insertion point coordinates into worksheet been wish list request? Ever? Never?

And the final solution is to create a symbol in a very special way - so that symbol has an extra objects which are symmetric to 0,0 coordinate and parts which are not desirable to be seen are in non-plot or turned out class. This way Xcenter and YCenter have same value as insertion point coordinates.

Haven't tested yet but I believe it should work.

Now I did the test and it works. Just note that the mirroring can't be done at 45 degrees straight away, it must be done twice - horizontally and vertically to have geometry symmetric to 0,0.

Edited by Yancka

And the final solution is to create a symbol in a very special way

This is a possibility, but only when you are in control of all the symbols you wish to include in the report and accept the funny look. Of course modifying the symbol definitions in this way is also scriptable?

Looking at the script I posted: it must be quite nebulous to a non-scripter and I have duly slapped my wrist with a ruler.

The lines after the word CONST refer to program constants. (How am I going to navigate out from this nebula? Engage: warp speed! )

The phrases between the single quotation marks in the said section are to be replaced with the names you use: the record name & the field names.

For better or worse, the script attaches the record to every instance of each symbol, but as you say, one has to run the script or menu command every time and that is not likely to happen!

Now, VW is a quite capable spatial information system program (GIS), but implementing all the crucial features is not exactly easy. For your information, the LOC(ation) function of VectorScript uses the insertion point of symbol instances. If you have eg. polygons that have names, you can perform tasks, including worksheet database reports, based on LOCation.

Nebulously yours,

Kool Aid, a.k.a. the Sanity Clause.

EDIT

Did the script actually work? I'm surprised?

Edited by Kool Aid

Did the script actually work? I'm surprised?

Guess what... I never tried it.... because the architect I work for won't handle such a complicated and rarely-to-use thing as a script for setting coordinates of symbol into record format. The other reason is that I don't quite accept idea to push the button (your script) every time I want to have coordinate records updated.

Shame on me...

What came into my head are 2 possible scripts that could be useful in this workaround.

1. Script that mirrors geometry against 0,0 and the mirrored part makes invisible (attributes palette, not special class I thought before).

2. Script that checks if insertion point X, Y matches XCenter and YCenter, in other words - if the symbol is good to go.

Ahh, but you and your employer are absolutely right! This is one of the many reasons why one should not use symbols as such at all, only parametric objects, if coordinates are important. I think I have somewhere a half-baked parametric object for the sole purpose of coordinates: one can use a symbol in it, but it does little else.

And all this only because the talented programmers in Maryland, U.S. of A., can't produce a simple worksheet database function??

And all this only because the talented programmers in Maryland, U.S. of A., can't produce a simple worksheet database function??

rofl :D

My guess is that they must have been considering this some day (or even more than once) but for some reason haven't produced it or included it in VW.

But they have: with VectorScript, one can get the x/y/z -coordinates. So, it's there, but not available to you mere mortals.

## Create an account

Register a new account