[Sidefx-houdini-list] Using HDK to get a constant parameter on a SOP

Harry Biddle hb at dneg.com
Fri Jul 5 06:30:31 EDT 2013


Hi Frederic,

Thanks for the code snippets. I gave this a go and it almost almost 
works: you now can't change the value off its default, which is great, 
but the only issue is when opening a saved scene: when Houdini sets the 
parameter value from the one saved in the file, it doesn't go through 
this callback function, and the parameter ends up with the value that 
was saved in the scene, rather than the value corresponding to the 
plugin you've just loaded.

I'm wondering if there are any "post creation from saved file" callbacks 
that we can hook in to....I found OP_Node::onCreated which is called 
when nodes are created, but unfortunately it seems to be called before 
Houdini populates the node with the saved values.


On 04/07/13 01:42, Frederic Servant wrote:
> Hi Harry,
>
> I had the same issue, I used a PRM_STRING, I did not disable it since it
> makes it less legible and more difficult to copy and paste.
>
> You are right to set your version in the default value, this ensures the
> version displayed is the current SOP dso's version and not the version the
> SOP instance was created with initially.
>
> Now all you need to do is to prevent any changes to the parameter, I used a
> callback for that:
>
> // restore defaults callback
> static int restoreDefaults(void *data, int index, float time, const
> PRM_Template *tplate)
> {
>      UT_String token;
>      tplate->getToken(token);
>      SOP_MySop* sop = reinterpret_cast<SOP_MySop*>(data);
>      sop->getParm(token.buffer()).revertToDefaults(time);
>      return 1;
> }
>
> // parameter definitions
> static PRM_Name versionName("version", "Version");
> static PRM_Default versionDefault(0, MY_VERSION);
> static PRM_Template parameterTemplates[] =
> {
>      // some parameters here...
>      PRM_Template(PRM_STRING | PRM_Type(PRM_Type::PRM_BEHAVIOR_NOREFRESH) |
> PRM_Type(PRM_Type::PRM_BEHAVIOR_NOCOOK), 1,&versionName,&versionDefault,
> 0, 0, restoreDefaults),
>      // more parameters...
>      PRM_Template()
> };
>
> Hope this helps,
> --
> Fred
>
>
>
> On Wed, Jul 3, 2013 at 10:31 AM, Harry Biddle<hb at dneg.com>  wrote:
>
>> Hi guys,
>>
>> I've been trying to build a SOP in C++ land that has a constant string
>> parameter on it---I'm using this to display the version number of the SOP.
>>
>> I can do this with a PRM_STRING or PRM_LABEL, setting a default on
>> compile-time. But it ends up as a node parameter, that gets saved along
>> with the scene, and can be overwritten by the user!
>>
>> Does anybody know if there some kind of a flag that says 'this label is
>> constant; its value can never be changed from the default value'?
>>
>> Thanks,
>>
>> Harry
>> ______________________________**_________________
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
>> https://lists.sidefx.com:443/**mailman/listinfo/sidefx-**houdini-list<https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list>
>>
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list



More information about the Sidefx-houdini-list mailing list