Jump to content
Developer Wiki and Function Reference Links ×

Event Based question


Recommended Posts

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?

Link to comment
  • 1 month later...

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);

 

430277315_Screenshot2021-05-14at08_08_54.thumb.png.72f120af873707c5c16261982ab5905a.png

 

 

Edited by _c_
Link to comment

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.

  • Like 1
Link to comment
  • Vectorworks, Inc Employee

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.

  • Like 4
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...