J. Miller Posted December 19, 2013 Share Posted December 19, 2013 Hello, I am trying to determine if a user has moved a certain Control point. When would I collect the original position location of the control point (prior to user movement) and where would I collect the new position of the control point (after the user has moved it). this is an event enabled PIO. Thanks, Jeff Miller Quote Link to comment
Miguel Barrera Posted December 20, 2013 Share Posted December 20, 2013 The following link shows how to monitor parameter changes: State notifications and the type of notification you want is: kParameterChangedReset (3)-- Parameter has been changed. Quote Link to comment
Hippocode Posted December 20, 2013 Share Posted December 20, 2013 (edited) Hello, I am trying to determine if a user has moved a certain Control point. When would I collect the original position location of the control point (prior to user movement) and where would I collect the new position of the control point (after the user has moved it). this is an event enabled PIO. Thanks, Jeff Miller That depends on what you want to do with it. Is it only the first time the user moved it, or each time( each object refresh) the position doesn't match the original ? OR Each time moved, not always on object refresh ? You could also add the startposition on the object creation event into a second field, this way you can compare that value with the current stored value each time the script gets calculated. Another way is mentioned in the above post and this will only trigger an event when the point is CHANGED, and not on each object refresh. Choose wisely Edited December 20, 2013 by hippothamus Quote Link to comment
J. Miller Posted December 20, 2013 Author Share Posted December 20, 2013 I want to move another control point if the control point in question is moved by the user. (Similar to a dimension, moving the text in relation to the dimension line, but allowing the user to place text where they want it. So it (the text) would have to change each time the user moves the control point (dimension line) in question. I need to determine the offset distance between the two control points prior to movement and relocate the second control point (the text) after the movement based on the original offset distance. I am hoping the vsoStateGetParamChng function will work for me. Jeff Quote Link to comment
JBenghiat Posted December 20, 2013 Share Posted December 20, 2013 vsoStateGetParamChng will do what you want. One thing to note - the expected parameter index assigns and index to the x and y of the control point, but if you look at the parameter list in the Plug-In Editor, each pair only gets one ID. In other words, if you're looking at IDs in the Editor, add one at every ControlPoint0nY. I believe there are other posts in this forum on using states. -Josh Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 20, 2013 Vectorworks, Inc Employee Share Posted December 20, 2013 The problem with using vsoStateGetParamChng in VS with control points is that a control point consists of 2 parameters (X and Y). You only get one parameter change notification per event with VS so you can see that X has changed but you don't know about Y, or the previous value of Y. (I don't even know if control points changes send any info for vsoStateGetParamChng because of this limitation in VS.) I think you may still need to rely on the old methods and store the old values in another set of fields and compare them during the reset event to determine if the control points have been moved and how far. You may be able to use event notifications to tell the object was reset by a control point move but you won't be able to determine the previous value unless you store it. Quote Link to comment
Miguel Barrera Posted December 20, 2013 Share Posted December 20, 2013 When the user moves the first control point it will trigger the parameter change event. In turn you can then set the location of the second control point and the text with SetRField. Quote Link to comment
J. Miller Posted December 20, 2013 Author Share Posted December 20, 2013 so when or where in the script can i determine the existing difference between the two Control points (prior to the user move)so that I can store this information in a field for later use vsoStateGetParamChng( objectHan , widgID, paramIndex ,oldValue) returns an "unknown" when a control Point is moved. Jeff Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 20, 2013 Vectorworks, Inc Employee Share Posted December 20, 2013 You can't get the previous value so you have to store the "current value" from the reset as the "old value" to be examined in the next reset if that makes any sense. You can do the compare in the beginning of the reset event. You have to check for IsNew to see if it's the first time the object is being placed and handle that case separately since there will be on "old value" In the reset compare the "old value" that you have stored in another parameter(s) (based on the previous reset event with) the values currently in the control point. If they are different you know the user has moved to control point and you can calculate the difference using the "old value" and the current value. At the end of the script always copy the current control point values into the "old value" fields so they will be ready for the next possible move. Quote Link to comment
J. Miller Posted December 20, 2013 Author Share Posted December 20, 2013 Thanks for all the input. I give this a shot. Providing an offset parameter is another way, its just not as robust. Jeff Quote Link to comment
Hippocode Posted December 21, 2013 Share Posted December 21, 2013 From what you describe what you want it is very easy. Your plugin will reset (I think) when the user changes the position of the controlpoint 1. All you have to do is place CP2 on a distance from CP1. When CP1 changes, CP2 will change the same way. No need for special event stuff. Quote Link to comment
Recommended Posts
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.