I made a custom node using Python and API 1.0.
I added a custom Double3 attribute to it. The default value for the for Double3 is (0, 0, 0).
How can i change the default value to be (1, 1, 1)?
I tried the SetDataDouble3 of the MFnNumericAttribute, but I get an “AttributeError” error…
Warning: Failed to call script creator function
Error: AttributeError: file \OpenMaya.py line 54: setData3Double
nevermind, I need to read the docs more closely. Passing a single value of 1.0 when the attribute is created, sets all the values to 1.0
This begs the question, how would i set the default values for a double3 to three different values?
relevant passage from the docs:
As a convenience, MFnNumericAttribute will set the flags of child attributes as well when the flags of the parent attribute are set. This is important when creating a numeric pair or triplet. For example, if MFnNumericAttribute is used to create a 3 double attribute and the attribute is set to be keyable, then the three child attributes will also be marked as keyable.
SetDataDouble3 is a method on the MFnNumericData class, not the MFnNumericAttribute class. The method you’re looking for is MFnNumericAttribute.setDefault()
However that being said, I’m not sure how to set a double using it. If I pass setDefault a python float, I get an invalid type error. If I pass it a double via MScriptUtil (either using asDouble() or asDoublePtr()) I again get an invalid type error. setDefault works fine when setting the default value of a float attribute, so if you can get away with a float I at least know that will work.