Hi there,
I have this problem with dynamic attributes:
I have an attribute of type kTime and create it in one place:
MFnUnitAttribute unitAttrFn;
MStatus stat;
MObject newAttr = unitAttrFn("long", "short", MFnUnitAttribute::Type::ktime, 0, stat);
In another funtion (for code reuse, can’t do everything in one funtion), I want to set the attribute flags.
Now I pass the MFnUnitAttribute there by reference, but also tried to construct it a new from the MObject “newAttr”, which logically should do the same, but with this API I don’t trust there is any logic.
void StandardNode::setAttributeProperties(MFnAttribute& attrFn/*, MObject& newAttr*/)
{
MStatus stat = MStatus::kSuccess;
//tried this as well
//MFnAttribute attrFn2(newAttr);
//then used attrFn2 instead of attrFn
stat = attrFn.setStorable(true);
stat = attrFn.setHidden(false);
stat = attrFn.setReadable(false);
stat = attrFn.setWritable(true);
stat = attrFn.setKeyable(true);
stat = attrFn.setCached(true);
stat = attrFn.setConnectable(true);
}
After that I want to add it to the node
MFnDependencyNode nodeFn(nodeObject);
nodeFn.addAttribute(newAttr, MFnDependencyNode::kLocalDynamicAttr);
I know there is MFnDependencyNode::kNormalAttr andMFnDependencyNode::kExtensionAttr , but they give me a MStatus fail with MFnDependencyNode::addattribute().
The attributes are added. Works!
setHidden(true) makes the attribute disapear from the node in the nodeeditor. Works!
BUT setReadable(false) does not make the output pin disappear. FAIL!
BUT setWritable(false) does not make the input pin disappear. FAIL!
In this case I don’t trust setCached(false) to work, which I need as well for my custom nodegraph implementation.
It works fine with static attributes, but for dynamics it fails as described.
Please give me some advice what to do different with dynamic attributes,
which I need for a node that has a dynamic number of inputs.
Is the order okay, or do I need to set properties after adding the attribute to the node,
I tried that as well.
Best,
Kai
p.s.
screen that shows the problem: