Nebeor Posted February 22, 2018 Share Posted February 22, 2018 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. Quote Link to comment
Stefan Bender Posted February 22, 2018 Share Posted February 22, 2018 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...). Hth, Stefan Bender Quote Link to comment
Hippocode Posted February 22, 2018 Share Posted February 22, 2018 (edited) 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 February 22, 2018 by Hippocode Quote Link to comment
JBenghiat Posted February 22, 2018 Share Posted February 22, 2018 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. Quote Link to comment
Nebeor Posted February 26, 2018 Author Share Posted February 26, 2018 (edited) 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 February 26, 2018 by Nebeor 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.