Jump to content
Developer Wiki and Function Reference Links ×

How to set the default class of a custom plug-in object?


Recommended Posts

Hello everyone,

For Vectorscript/Python plugins you can set the default class in the graphical interface, So I figure there must be a simple way in the SDK to do this as well.

There is a function in the SDK : SetDefaultClass(InternalIndex classID), but I don’t understand how this can be used in combination with the plug-in definition in question.

Link to comment

Hi Nebeor,


afaik there's no way to set the default class in the plug-in definition. You can hardly define a default class beside "None" and "Dimension" as you don't know in advance which classes actually exist when the user creates a PIO. You may need to check all places in your code where you create your PIO and set the default class before calling CreateCustomObject. You may also try to change the class within the regeneration code when a PIO is regenerated for the first time, but beware of infinite recursion (setting the class may trigger another regeneration...).




Stefan Bender

Link to comment

I usually add a class parameter that overrides the object class on object recalculation. I only do this when the current class does not match the class of the parameter to avoid infinite recursion as mentioned above. Though it could be that setting a class does not reset the object anymore, something changed about it a couple versions back.

Edited by Hippocode
Link to comment

You can't set a default class to a plug-in via a built-in method, VS or SDK (or in the GUI).  Any classing options you have need to be coded from scratch.  I provide a preferences dialog that includes an option to specify the insertion class, which can be <active class>.  (The class pulldown includes an interface for creating new classes).  On the plug-in side, if the class preference isn't <active class>, I class the object instance on insertion.


In terms of preferences, there are three layers for retrieving a preference:

1. Check the document for a hidden pref. record with a field for that preference.

2. If it doesn't exist, check saved settings and create the hidden record and or field.

3. If the saved setting doesn't exist, pull the default value from the string resources and create the saved setting.


A "Make Default" check box in the preferences dialog also stored the data to saved settings.

Link to comment

Thanks for the suggestions.

I'm already using a workaround myself:

I added a hidden boolean parameter __isNew that triggers some code on first reset, this is where my default class is used.

Unfortunately i cannot set the default parameter value for __isNew to True because of backward compability, but that's ok!


Edited by Nebeor
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.

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