Jump to content
Developer Wiki and Function Reference Links ×

Force reading of default parameter value for menu command?


Recommended Posts

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.

Link to comment

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

Link to comment

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.

Link to comment

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

Link to comment

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.

Link to comment

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 by DWorks
Link to comment

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

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