Notifications
Clear all

[Closed] Custom Attributes With Node Reference

Hi

Im not massively familiar with custom attributes so,

Is it possible to add a node reference in a scripted custom attributes definition that is assigned to when the custom attributes are created? Preferably without the pick button you get when adding attributes though the UI.

Cheers
Dave

7 Replies

if you have defined the maxobject or maxobjectTab in your parameter block, you can create an instance (or array) of the nodetransformmonitor class, passing the node in the constructor. You can then add these programatically to the CA.

nodetransformMonitor node:<the object>

Hi and thanks for the reply

It was a little more involved that i needed but the function you mentioned lead me to a solution so thanks

This is just test code but it works

ca = attributes c
(
	parameters main
	(
		obj type:#node
	)
)
attriHolder = EmptyModifier()
addModifier $ attriHolder
custAttributes.add attriHolder ca #unique
attriHolder.c.obj = selection[1] -- must be a different object

selection[1].modifiers[1].c.obj

because there is no rollout defined it holds the reference to the node but there is no UI so it cant easily be changed and is stored between sessions

I previously believed that you MUST supply a rollout but it works without so

Cheers
Dave

1 Reply
(@lonerobot)
Joined: 11 months ago

Posts: 0

Well, I needed to give you something to figure out, didnt I?

Firstly, yes there is no need for a rollout unless you want the user to somehow interact with the data stored in the parameter block.

Secondly, you were asking about node references but the maxobject type is also a node reference. Instead of a node, nodeTransformMonitor is a special parameter type that avoids dependency issues by encapsulating a reference to the node. The code below should illustrate how it is possible to do what you couldn’t do with the previous type.

ca = attributes c
(
	parameters main
	(
		obj type:[B]#maxObject[/B]
	)
)
attriHolder = EmptyModifier()
addModifier selection[1] attriHolder
custAttributes.add attriHolder ca #unique
attriHolder.c.obj = nodetransformmonitor node:selection[1] 
selection[1].modifiers[1].c.obj.[B]node[/B]

Although it is just a hypothetical example, why would you need to store the node in a modifier that is on the node? In the past I have found this method is useful if you need to adjust properties on the node itself without using

refs.dependentNodes

and filtering the results.

Hi

I didnt mean to com across as offensive or anything, your reply was useful and did help me out so i am grateful.

The test code i posted was not very descriptive sorry, the node that was being added was any other node in the scene, not itself which was not clear with the selection[1] being anything.

Im not actually storing a reference to itself what im doing is working on some rigging tools so the result is an IkFk blend and im storing the references to the IkFk bones on the blend bones in the custom attributes.

I clearly didnt understand the #maxObject type correctly because when Itried it out it returned a Editable Poly type which makes sense now i see that i should have added a .Node to it.

1 Reply
(@lonerobot)
Joined: 11 months ago

Posts: 0

Hi Dave,

You didn’t in the slightest! My reply was meant as a joke. I’m glad that you have found a solution. Whilst you didn’t need to store a reference to the node itself in your custom attribute, it is still worth bearing in mind the differences in #node and #maxObject, especially in a rigging context. Node storage in rigs is super useful, so there will be times when #node may give you problems with dependencies. Just something to bear in mind!

oh good, its sometimes difficult to get the feeling of a message though just text

Thanks for the clarification on the difference between node/maxObject that is good to know

Thanks for the help and you blog is awesome

Dave

the solution of what type of parameter to use depends on what you want to do with the stored node.
storing a node as NodeTransformMonitor or NodeMonitor have some limitation. The parent node (CA in your case) doesn’t receive ‘node deleted’ notification message for example when stored node was deleted.