Notifications
Clear all

[Closed] Node transform monitor in Custom attribute

HI everybody,

First of all, i’d like to say that I am a begimmer in scripting, anyway, this is what I try to do.

I wrote an autorig, and in the ik Fk creation, I put a custom attribute in the arms controllers, that allow to do the switch beetween IK/FK, and I add a button to snapping the chains beetwen them.
Now, all works fine if I dont change the names of the controllers, as i use the explicit objects names.

I am trying to figure a better way to do this, I found the Paul Neal’s tutorial about the weak referencies, what he’s doing, is listing an array of nodes into a list by picking the objects nodes.
Well I would like to do the same, but without picking the nodes, just adding them from an array of nodes.
here’s the function i wrote, but it’s not working:


ikNodesLS = #($bone001,$bone002)
   
   fn addCA item   =
   (   
      NewAttr = EmptyModifier()
      NewAttr.name="Test_Attributes"
      addmodifier item NewAttr
      
      IKFK_CA = attributes nodesRef
      (
         parameters nodesP rollout:nodesR
         (
            refNodes type:#maxObjectTab tabSize:0 tabSizeVariable:true
         )
         
         rollout nodesR "Nodes"
            
         (
            listBox nodesListLb "Nodes:"
                        
            --Function to update the listBox when the UI is opened or a new node is added.       
            fn updateList=
            (
               nNames=for n in refNodes collect n.node.name
               nodesListLb.items=nNames
            )
            
            on nodesR open do
            (
               updateList()
            )
            
            for obj in ikNodesLS do
            (
               append refNodes(nodeTransformMonitor node:obj forwardTransformChangeMsgs:false)
            )
         )      
      
      )
      custattributes.add  item.modifiers[1] IKFK_CA baseobject:false
   )

Anyone can help me to understand what I am doing wrong?

Thank You.

3 Replies

first of all … do you know why it’s wrong to make a custom attribute without unique id? without specifying a unique id…

No… why?

Thanks.


-- lets say this is your array
curAr = #($IkControl1, $IKControl2, $IKControl3)
-- you can simply add it to a maxObjectTab by following the example you posted already
-- In your autoRigger you can just add them to the refNodes array once you have added the CA to a node:
for curItem in curAr do
(
   append theNodeWithCaDef.nodesRef.refNodes (nodeTransformMonitor node:curItem forwardTransformChangeMsgs:false)
)