michaelk Posted March 24, 2021 Share Posted March 24, 2021 I have a simple point parametric object that is not event based. I use this little code snippet in almost every tool: resultStatus := GetCustomObjectInfo(objName,objHd,recHd,wallHd); ControlGeometry := GetCustomObjectPath(objHd); SetObjectVariableBoolean(objHd, 800, TRUE); If I have Event Based ticked in the properties of the tool, it returns an error until I get rid of those lines and the code runs twice - creating a default object and another object with the chosen parameters in the same location. I know I need to learn the ways of event based. But until then: Is this new in 2021? Or have I just been lucky enough not to check that box in the past? Quote Link to comment
_c_ Posted May 14, 2021 Share Posted May 14, 2021 (edited) Ciao @michaelk, no, nothing new there. I illustrate here the code that you mentioned: resultStatus := GetCustomObjectInfo(objName, objHd, recHd, wallHd); sets all basic variables to operate on the running plug-in code objName universal name of the running plug-in objHd handle of the running plug-in as instance of a definition (record, type 48) recHd handle of the running plug-in definition (record, type 47) wallHd for wall-insertable objects, handle of the parent wall (if any) ControlGeometry := GetCustomObjectPath(objHd); Handle to the custom path, an optional geometry that lives inside the path group of the plug-in. This is only relevant for path-based plug-ins or plug-ins where this has been enabled. Point, rectangular or linear plug-ins won't have a path group by default. For those who don't know, plug-ins can have special groups. Profile and path groups, such as for Extrudes along path where the path is used for extruding a given profile. The two special groups can be imagined as "outside" the document and the plug-in. As a repository available for that plug-in. Your plug-in might return an error if you try to use a NIL handle returned by GetCustomObjectPath, but there is no such special group. IF you enable Events, you will be able to code special actions for given events on your pio. For example you might want to be able to edit it as a polygon (and your PIO is a path pio). I posted an example of event enabled Plug-in using various events (such as disclosure widgets) a few weeks ago: SetObjectVariableBoolean(objHd, 800, TRUE); Enables text operations on the running pio. This will allow to set the text size and font of the pio using the usual text commands. Mind, this won't make it respond to anything else, such as horizontal and vertical text alignments. Every plug-in object runs "twice" when the developer mode is activated. Either in the VW prefs or by script using SetPref(21, TRUE); Edited May 14, 2021 by _c_ Quote Link to comment
michaelk Posted May 14, 2021 Author Share Posted May 14, 2021 Ciao @_c_ Thanks for that. I’m still learning and I’m trying to make 2021 the year I actually learn how to write event aware plug-ins. 🤓 The news about developer mode causing the “second run” is very enlightening. 1 Quote Link to comment
_c_ Posted May 14, 2021 Share Posted May 14, 2021 It will be such fun! Vectorscript is very rewarding, it will give you power and endless brainfood. I bring Vectorscript code 'problems' for my long runs. There is nothing better for forgetting yourself for a couple of hours. 1 Quote Link to comment
Vectorworks, Inc Employee Judah Warshaw Posted May 14, 2021 Vectorworks, Inc Employee Share Posted May 14, 2021 The main benefit of enabling "Run scripts in developer mode" is you can make changed to your script without having to relaunch Vectorworks. Once thing that may not be obvious - If you are handling the event kObjOnInitXProperties, you only get one shot at it. It will only execute once. If you have errors in your script and need to fix it, you will need to restart VW to have any properties set properly. 4 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.