Jump to content
Developer Wiki and Function Reference Links ×

How do I get the starting point and the end point of a linear object?


VvierA

Recommended Posts

Hi there,

I try to program a auto level dimension tool and I am using a linear plug-in object to do that. It draws a small triangle with some text showing the y-coordinate of the PIO.

The linear plug-in object ist defined (of course) by two mouse clicks.

If the first mouse click is more on the left than the second click everything works feine.

But: if the second click is more to the left everything becomes flipped so that the text and the small triangle are turned upside down. The angle indicator in the small object info palette shows 180?.

That's not intended. I like the POI behave exactly the same no matter if it is drawn from left to right or vise versa.

Can anybody help?

Maybe I should check if the x-coordinate of the first click is lower than the second? But how could I do that? How could I retrieve the x an y coordinates of the first and the second click of a linear object?

Or is there an easier way to prevent the POI from getting flipped over?

Thank you for help

kind regards

VvierA

Link to comment
  • Vectorworks, Inc Employee

Hi Carl,

Think of PIOs as a container with it's own origin and rotation. Everything you create within the PIO is made normal to the PIO and not the "outside world" of the document. The trick is to figure out how the PIO is oriented to the document. The trick is to use:

GetSymLoc( pioHandle, InsPoint.x, InsPoint.y );

and:

pioAngle := GetSymRot( pioHandle );

In your case, GetSymRot will return the angle so you can make adjustments accordingly.

HTH,

Matt

Link to comment
  • Vectorworks, Inc Employee

Some additional things:

In your situation, I would force the PIO to "unflip" itself if the angle is greater than 90d or less than -90d. I don't think there's a call that can directly get the endpoint, so you have to work with what you can get:

Get the first point:

GetSymLoc( pioHandle, InsPoint.x, InsPoint.y );

Get the angle:

pioAngle := GetSymRot( pioHandle );

Get the line length by calling the PIO's parameter:

pLineLength

I little math and you've got the second point.

Then you can use GetSymLoc and SetSymRot to adjust the PIO location and rotation.

Edited by Matt Panzer
Link to comment

Hi Matt,

thank you so much. With your help I think I will make it.

First I thought I have to "flip" every command and coordinate inside the PIO once I managed to figure out which way it is orientated.

It's a much better idea to unflip the PIO itself.

I will keep you up to date.

Thanks again,

VvierA

Link to comment
  • Vectorworks, Inc Employee

You're welcome.

I've been there before and yes, unflipping the PIO was much easier than reworking the geometry within. I suppose there may be certain circumstances where you may want to deal with it inside the PIO, but if you can get away with unflipping... :-)

Link to comment

I don't think you can move or rotate the "pio".

What you can do is move everything that is drawn inside the pio from the pio origin (easier if you draw in a group if it containst multiple items ) by using move(to) or hmove afterwards ?

You can also rotate whatever you draw inside the pio, not the pio itself.

Move(+10cm,0);
Line(10cm,10cm);

OR

Line(10cm,10cm);
Hmove(LNewObj,10cm,10cm);

Edited by hippothamus
Link to comment
  • Vectorworks, Inc Employee
I tried it but I failed.

I couldn't find the command 'SetSymRot' so I tried SetAngle but that didn't work.

I was also looking for something like SetSymLoc to move the PIO but I couldn't find something like that.

Maybe you have another hint for me?

Sorry about that. You're right. You should be able to use HMove and HRotate.

Link to comment
  • Vectorworks, Inc Employee

As far as I know, there's no simple answer for this. If anyone knows better, please chime in.

You'll need to think of (and test for) every possible "environment" that you think the PIO might be used. You'll then need to have the code check to see what "environment" the PIO is in. Use GetLayer( pioHandle ) to find the parent layer of the PIO. If the PIO exists on a design layer, GetLScale( GetLayer( pioHandle ) ) will get the scale. If it's not on a design layer, you'll have to continue searching. If it's on a sheet layer, you'll need to test to see if it's in a viewport's annotation space. If so, GetObjectVariableReal( viewportHandle, 1003 ) will return the viewport's scale. And so on...

Create a test file and place the PIO in every environment you can think of. Then test away.

There really should be a vectorscript call to simply return the scale of the PIO environment. Something for the wish list...

Good to hear you have the unflipping part working. Are you moving/rotating the PIO, or the geometry?

Link to comment
  • Vectorworks, Inc Employee
Well, concerning the rotation, I check for the rotation angle of the PIO.

If it's rotated every element gets rotated individually. That's not so elegant but it was easier for me to implement.

Thank you again,

VvierA

Glad to help.

Rotating the objects within is probably more of the prescribed method. I had a recent case where moving and rotating the PIO was easier. I think each method has their advantage. An alternative to rotating each object individually, you can also place them all in a group and rotate the group after everything is created.

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