JoelS Posted May 16, 2012 Share Posted May 16, 2012 Is there a way to force the reading of the default parameter value instead of the value previously saved? Programmatically reverting to the default value would be useful if an error is detected that makes the value that would have been saved to the parameter invalid. It seems that once a menu command has run for the first time after parameter creation and the default value read, changing the default value subsequently in the VS PIE has no effect, even if the parameter value is never saved in the script. TIA Joel. Quote Link to comment
JBenghiat Posted May 16, 2012 Share Posted May 16, 2012 Joel, Each plug-in (of all flavors) creates a record with its name where it records parameters. You can use SetRField(NIL, [Plug-In Name], [Parameter Name], value) to set the defaults. Note that parameters are turned into constants when a script starts, so using PParameterName after setting the parameter with SetRField will return the original value. HTH, Josh Quote Link to comment
JoelS Posted May 16, 2012 Author Share Posted May 16, 2012 Josh, Thanks for that, but I'm hoping to have access to default value rather than change it and have the script read the default instead of the current value. You gave me the idea of trying: GetRField(PIORecHandle, PIORecName, PIOFieldName); instead of pFieldName but it returns nothing even though there is a default string in the parameter def. There have to be two values stored for each field, the default and the current. How to get access to the former? Joel. Quote Link to comment
JBenghiat Posted May 16, 2012 Share Posted May 16, 2012 Joel, I assume by "default value" you mean the parameter values set in the VS plug-in editor. When you run a plug-in for the first time, it creates it's record and uses the default values from the plug-in editor. Once that record exists, there is no way to access the plug-ins defaults, and defaults are now document based. You can try deleting the record and having the plug-in recreate its record, but that may cause some unwanted behavior. If you really want control over user-wide default values, your best option is to write to the settings file or to your own settings file, read values from setting instead of parameters, and provide your own interface for setting defaults. HTH, Josh Quote Link to comment
JoelS Posted May 16, 2012 Author Share Posted May 16, 2012 Josh, Ah well, it was a nice idea. There is a suggestion in the remarks for GetPluginInfo that getting the rec definition (type 47) from the PIO by using GetObject(PIOName) might return the object with the values I was looking for but that is also blank, as per your explanation. Normally I use the PIORecHandle (type 48) returned by GetPluginInfo to save the parameter data with SetRField(). I have such a system for some default values but I didn't want divergence between the default values assigned in every PIE def and those in my file, which also loses the flexibility of per-document settings, for which I have yet another scheme. No matter, I'll concoct something to store these values somewhere. Many thanks for your help. Joel. Quote Link to comment
Dieter @ DWorks Posted May 17, 2012 Share Posted May 17, 2012 (edited) If you get the handle to the plug-in definition, you can set/get the default values you want with that handle. Keep in mind that when GetObject(pioName) doesn't return a handle, the object record definition hasn't been created yet in the document, so you'll need to create it by using CreateCustomObjectN and then deleting it again. I use this a lot to set default values on menu commands. Edited May 17, 2012 by DWorks Quote Link to comment
JoelS Posted May 17, 2012 Author Share Posted May 17, 2012 DWorks, Thanks, I'll have a look at that and see how I can make use of it. Joel. Quote Link to comment
JBenghiat Posted May 18, 2012 Share Posted May 18, 2012 Just to clarify, the record still sets document defaults. Once the plug-in record exists, there is no way to get the original application plug-in defaults. How many users will use this plug-in. One simple solution is to include the default settings as a series of constants in an included .vs file. To edit the defaults, just edit the text file. -Josh 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.