Jump to content
Developer Wiki and Function Reference Links ×

Get2DPt


Bill

Recommended Posts

I am still using VectorWorks v8.5 so it may be too old to waste any brain cells on this question.

I wrote a little script to list some information for all the objects on all the layers. One of the pieces of info I wanted was an x and y coordinate so I tried Get2dPt. According to its help:

"Get2DPt returns the coordinates of a specified vertex in the referenced object."

But it always returns the same x and y values for every object, even though other functions that provide info like GetType, GetName, GetClass work fine for each object so I know I'm passing Get2DPt a valid handle. I've run it against lines, polygons, circles and symbols.

What is also wierd is that the x and y values, though the same for each object during a given invocation of the script, may vary during different vectorworks sessions. I.e. the x & y numbers for yesterday morning were differnt from those that from last night.

The x & y values are for locations that are way off the drawing. I used the Locus function to create a locus at the point. The Object Info palette shows the locus but I can' scroll to it.

GetSymLoc works fine for a real symbol. However when I point it to a non symbol it also returns wierd x & y values that appear to be way off the drawing.

Question

Has any one tried using Get2DPt in version 8.5 or v 10 and had it work correctly?

Link to comment

What index are you passing to the second argument? It is a one-based index, so the function will fail if you pass in zero.

Unfortunately there is not return value to indicate that it failed. Perhaps if you initialize your point variable to some known value before you call Get2DPt( ) and then test for that same value after the call you can determine if it succeeded.

Jeff

Link to comment

I use heavily the Get2DPoint(), and a few workstations run the scripts all day long with out any problems.

Is good to use the debug, and he will show you if the handle or the index have any kind of problem (like NIL), and where from come your x and y values.

Sometimes, if I'm not sure if the script goes to find a handle to get get a read, I place a

IF h<> NIL THEN Procedure() ELSE Procedure()

The procedures carry a boolean that will tell me if anything went wrong.

You could try your script on a poly using GetPolyPt(h,i,x,y), and if he doesn't work is definitively something with your script. You can post a sample of the code and we have a look at it: is always a good way to solve thinks fast and create a learning curve for everybody.

JKoppi, is good to know you are around.

Link to comment

Jeff,

Thanks for responding.

I updated the script to execute Get2DPt three times:

Get2DPt (theObjh, 0, locX, locY);

Get2DPt (theObjh, 1, locX, locY);

Get2DPt (theObjh, 2, locX, locY);

For each I zeroed locX & locY before the call and printed the contents after. They all returned the same non zero value for x & y

Get2DPt didn't fail with an index of 0.

Link to comment

Kiwi,

Thanx for the code. I added some writeln's to it and it now looks like:

code:

Procedure Fozz;

VAR

x,y :REAL;

h: HANDLE;

n,i: INTEGER;

filename : string;

layerh : handle;

BEGIN

filename := 'd:\wff\vw\bug.Get2Dpt.objects';

rewrite(filename);

layerh := ActLayer;

h := FSActLayer;

n := getVertNum(h);

writeln ( 'Layer = ', GetLname(layerh),

' has ', NumObj(layerh), ' objects'

);

writeln ( 'First selected symbol has ',

n, ' vertices'

);

FOR i:=1 TO n DO BEGIN

Get2DPt(h,i,x,y);

Locus(x,y);

writeln ('vertex ', i, ' : x = ', x, ', y = ', y);

END;

END;

Run (Fozz);
[/code]

I created a new layer and zoomed all the way out so that I could see the white drawing area surround by the grey background, non drawing area. I positioned the origin at the lower left have corner. The dimensions of the drawing area are about 440' x 440'. The layer scale is 1/4" to a foot.

Then I created and selected a square and ran the script. According to getvertnum, it doesn't have any vertices which I guess makes sense.

I then created and selected polygon, a triangle. This is the output showing the vertices all have the same x & y.

Layer = Kiwi has 2 objects

First selected symbol has 3 vertices

vertex 1 : x = 21841.4, y = 4362.57

vertex 2 : x = 21841.4, y = 4362.57

vertex 3 : x = 21841.4, y = 4362.57

When I used Organize, Custom Selection to select the locus that were created, the Obj Info palette tells me there are three and they are each located at the same spot, which is the basic problem I am having.

x = 1820'1.41913"

y = 363'6.56864"

The y value is within the drawing area but the x is way outside.

If I execute the code again, it now tells me there are 5 objects, which makes sense. The first two were a square and a polygon, the next three are the locus that were created by the first invocation.

I'm running VectorWorks v8.5.2 with Windows 2000 (5.00.2195, service pack 2). Given that your simple script there is not much program wise that can go wrong, so there is probably a bug somewhere in VectorWorks.

I changed the Get2DPt to GetPolyPt and that worked correctly for polygons.

What I was trying to do was be able to print something for an object that would tell me where it was located in the drawing. I'll look at some of the other 'Get' functions to see if any of them will help.

Thanks for the help.

[ 12-12-2003, 12:37 PM: Message edited by: Fozz ]

Link to comment

I leave your code almost intact, just add a putfile() to make easier for me to test the script, and a close() to close the txt file.

the text outputfile (for two triangles, one selected)t:

Layer = Layer-1 has 2 objects

First selected symbol has 3 vertices

vertex 1 : x = -655, y = -805

vertex 2 : x = -1025, y = -2235

vertex 3 : x = 285, y = -1945

And he looks right to me, I'm not sure if the glitch is on your version of VW... the only way I can see is you send me the file and I will try to work that out: is quite interesting and maybe our moderator could say more than me about what's going wrong.

This code write a file defining any kind of object out, in or over the edge of the drawing, I'm not sure if he will work on older versions of VW (10.5), but he may give you the main idea for find objects out of the drawing boundaries. You could add any kind of identification for each object.

text file (for 4 objects):

Layer = Layer-1 has 4 objects

object over

object in

object out

object out

code:

Procedure Fozz; 

VAR

s :REAL;

pd1,pd2: POINT;

filename : string;

layerh : handle;

Procedure InclObj(h:HANDLE);

VAR

p1,p2: POINT;

o,u: BOOLEAN;

BEGIN

GetBBox(h,p1.x,p1.y,p2.x,p2.y);

o:=PtInRect(p1.x,p1.y,pd1.x,pd1.y,pd2.x,pd2.y);

u:=PtInRect(p2.x,p2.y,pd1.x,pd1.y,pd2.x,pd2.y);

IF u & o THEN writeln('object in');

IF (NOT u) & (NOT o) THEN writeln('object out');

IF u & (NOT o) THEN writeln('object over');

IF (NOT u) & o THEN writeln('object over');

END;

{main}

BEGIN

PutFile('fileto write','none',Filename);

layerh := ActLayer;

s:=GetLScale(Layerh);

GetDrawingSizeRect(pd1.x,pd1.y,pd2.x,pd2.y);

writeln ( 'Layer = ', GetLname(layerh), ' has ', NumObj(layerh), ' objects' );

ForEachObject(InclObj,SEL=True);

Close(Filename);

END;

Run (Fozz);
[/code]

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...