Page 1 of 1

Creating custom attributes - can we add help documentation?

Unread postPosted: Tue Nov 19, 2019 3:47 am
by bvz
We are creating a fair number of custom attributes on nodes now (thanks SeExpr!).

Can we add help documentation that would show up in the tooltip? There does not appear to be any way to do it via the UI, but could we edit the .project file and add it?

Thanks

Re: Creating custom attributes - can we add help documentati

Unread postPosted: Tue Nov 19, 2019 11:03 am
by anemoff
Hi,

This is possible using the SDK (Python or C++), but there are some limitations.

Attribute documentation is stored in the OfClass, therefore when you modify the documentation of an attribute it changes it on all attributes on all objects of that same class that. The catch is that Custom Attributes are stored per object, instead of per class like built-in attributes. Therefore it is totally possible to create a custom attribute with the same name but with different definitions (type, size, ..) on 2 objects of the same class. Exampe: attribute "Foo" of type string on Image object "Image1", and attribute "Foo" of type vec2d on Image object "Image2". In this particular case, you will want different documentation on each custom attribute but you can't.

Here is a Python example:

python code

# get the object hosting your custom attribute
obj = ix.get_item('project://scene/image')

# set the documentation for the custom attribute
# note: this affects all attributes "foo" for all objects of the same class! (i.e. if called multiple times
# on the same attribute, last call wins)
obj.get_class().set_attr_doc('foo', 'hello world')

# print the attribute documentation
print obj.get_attribute('foo').get_doc()


If the object is already selected, the doc won't show right away in the Attribute Editor, you'll need to refresh it.

There is already a feature request to allow having different custom documentation on custom attributes but there is no ETA yet (ID #5428).

I hope this helps.

Re: Creating custom attributes - can we add help documentati

Unread postPosted: Tue Nov 19, 2019 8:03 pm
by bvz
Excellent. Thank you.

In case anyone else is curious, you can also do this by editing the .project file in a text editor and adding the following info:

Code: Select all
                    attribute_group "parameter_values" {
                        percentage "diffuse" {
                            doc "Set the intensity of the diffuse color."
                            texturable yes
                            animatable yes
                            shading_variable yes
                            value 1
                        }


Note the line in there that reads:

Code: Select all
doc "Set the intensity of the diffuse color."


Thanks again!

Re: Creating custom attributes - can we add help documentati

Unread postPosted: Wed Nov 20, 2019 4:08 pm
by anemoff
Thanks for sharing this alternative solution. :)