Jump to content
Developer Wiki and Function Reference Links Read more... ×
michaelk

control points 101

Recommended Posts

How do you assign an object to a control point?

Share this post


Link to post

Wow.  MoveTo(ControlPoint01X,ControlPoint01Y); works!

 

Amended question:  Can I give ControlPoint01X and Y a default value relative to the control geometry of a parametric object?

Share this post


Link to post

I thought that all references to the control points were within the internal PIO coordinate system. But I am probably wrong.  If I am wrong, you should be able to use the GetCustomObjectInfo to find the insertion point of the object and then set the control point offsets from there.

  • Like 1

Share this post


Link to post

Pat

 

If you do MoveTo(ControlPoint01X,ControlPoint01Y); the object appears at the 0,0 of the control object.  But what if I want it someplace else relative to the control object?

 

I'm assuming if I write an offset from that it will regenerate to that offset even after the user moves the control point.  But I'm not sure.

Share this post


Link to post

MoveTo(ControlPoint01X + <X-value>,ControlPoint01Y +<Y-value>) should work.

ControlPoint01X and ControlPointY01 are considered coordinates from the PIO origin. So they are just reals.

  • Like 1

Share this post


Link to post

In other words add the insertion point X,Y to the control point X,Y.

  • Like 1

Share this post


Link to post

But when you do that the object is offset from the control point.  I'm looking for a way to do what the window and door tools do.  The label is not at 0,0 and the control point is in the middle of the label.

Share this post


Link to post

ControlPoint01X:=ControlPoint01X+Blah;

ControlPoint01Y:=ControlPoint01Y-Fargh;

Then insert text at the new control points.

 

Completely untested. VW not even running right now.

  • Like 1

Share this post


Link to post
5 minutes ago, Pat Stanford said:

Completely untested. VW not even running right now.

😀

 

But the control point is a parameter of the tool.  If I understand correctly you can't assign a value to it in the script, you would have to write it to a record field.

 

I guess what I'm asking is how does the door label get offset from the insertion point of the door by default and the door label appears to be centered on the control point?

Share this post


Link to post

So maybe it is

 

SetRField(MyObjectHandle,MyPIOName,'ControlPointO1X',Concat(ControlPoint01X+Blah));

 

I know i have moved he control point inside a script before. I just can't remember where or even what name to search under.

 

Sorry.

  • Like 1

Share this post


Link to post

I don't think you can assign control point values to a tool, because there is no object instance, but I have never tried.

 

I move the control points of PIO objects all the time.

 

OffsetX := 10;

OffSetY := 5;

GetSymLoc(theObject, ObjX, ObjY)

SetRField(theObject, 'TheObjectPIOName',  'ControlPoint01X',  ObjX + OffsetX)

SetRField(theObject, 'TheObjectPIOName',  'ControlPoint01Y',  ObjY + OffsetY)

 

  • Like 1

Share this post


Link to post

Is the object you are trying to relate to the control point part of the custom object with the control point or a second object that you are relating in a parent/child relationship?

 

In general, there is nothing special about a control point: think of it as a dimension field measuring from the origin (insertion point) of the PIO. The only difference is that in addition to manually typing a value in the OIP, the user can set those distance values via clicking on the drawing.

 

 

  • Like 1

Share this post


Link to post

In this example I have a custom path object.  I'd like to place labels offset from the beginning and end of the path object..

 

I've never used control points before and just discovered that MoveTo(ControlPoint01X,ControlPoint01Y); before creating the text object works.  I didn't realize - and probably don't fully understand yet - that you should write the offset to the record.  Doing the math in the MoveTo function puts the label in the correct place, but makes the labels not coincident with the control point.

Share this post


Link to post

So just use the SetRField to set the control point to be where you want the label and then use the control points to set the location of the text.

 

But actually that might not work. I seem to remember that setting values to parameters are not stored until the end of the PIO execution. So you probably need to read the original control points into variables and then modify the variables to get the location to write the text and to also set the control point values before the end of the PIO.

  • Like 1

Share this post


Link to post

Do you want the labels to be part of the object ?

 

If yes, then: (I do the following with cable objects all the time.)

Do you want the user to be able to change the location of the label based on the user moving the control point?

If not, forget about the control point and write the place at the location of the first vertex and the last vertex.

If so, on creation, set the control points to the location of the first vertex and the last vertex, and from then on always place the text at the location of the control points. GetRField(theObj, theObjPIOName, 'ControlPoint01X').   

 

If no, then: (I do the following with Truss Labels all the time);

just find the location of the path object vertices and write the labels to those locations.

 

  • Like 1

Share this post


Link to post

I'm still not clear if the text blocks are part of the path object or separate objects on top of the path object.

 

I'm also not sure about your scenario: you say that you're inserting text at the control point, but that the control point needs to be moved to the text (?).

 

Or are you trying to set the label center to a default location on insertion that is based on the object's geometry?

  • Like 1

Share this post


Link to post

Thanks, Sam.  I'll try that.

 

Josh, I'm trying to place 2 text labels with control points so the user can adjust.  One is offset -xx,yy from the beginning of the custom path object and one is offset xx,yy from the end of the custom path object.

 

So the second option.   A default location based on the object's geometry.

Share this post


Link to post

Using the second option the labels will not move when the path object is moved or edited, but it will place the labels at the beginning and end and allow the user to adjust the location of the labels to any place they wish.

  • Like 1

Share this post


Link to post

Thanks, Sam.  It's perfectly fine if they don't move with the object.  There are options for 2 other labels and I want to avoid a pile of labels at the object 0,0.  🙂

 

Share this post


Link to post

So, do I assume correctly that the labels are part of the object?

 

You're going to want to define four dimension parameters to display the object. Hide the control point fields from the user in the OIP. The real work comes with enabling state events for your object and parsing them in the reset event.

 

If the object is created: use PointAlongPoly() to find initial control point values and write them to both the control point and the offset fields. Label 1, the control point = the offset. Label 2, the control point = the coordinate of the endpoint + the offset.

 

If the user has edited one of the offset fields: calculate the control point and write to field. Just treat the control point field like any other distance field.

 

If the user has edited one of the control point fields: calculate the offsets and write to the offset fields.

  • Like 1

Share this post


Link to post

Thanks Joshua.

 

Wish I didn't have to work right now so I could try all this out!

 

 

Share this post


Link to post

So it would seem that the trick for you is to get a handle to the path of the path object.

For a path object:

your first vertex will be (0,0) so just add the offset to that (negative numbers to move left or down).

your last vertex will be Get 

     NumVertices:= GetVertNum(PathHd);

     GetPolyPt(PathHd,NumVertices,LastVertX, LastVertY);

          add the offset to that (negative numbers to move left or down).

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

 

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.

×