Access a custom attribute (node type) via scripting

Access a custom attribute (node type) via scripting

Anonymous
Not applicable
2,568 Views
6 Replies
Message 1 of 7

Access a custom attribute (node type) via scripting

Anonymous
Not applicable

I notice when I add a Float custom attribute to an object, I can see it show up in the Track View editor as a selectable track.

 

However if I add a Node type custom attribute, no track shows up.

 

How can a Node type custom attribute be accessed via Maxscript if it's not a revealed track?

 

 

0 Likes
Accepted solutions (1)
2,569 Views
6 Replies
Replies (6)
Message 2 of 7

Swordslayer
Advisor
Advisor

By its name, just like all the others. Note that you CAN make #node property visible in trackview if you use subAnim:true, just like you can hide any other property using invisibleInTV:true. All the specific details are mentioned in the Scripted Plug-in Clauses topic.

0 Likes
Message 3 of 7

Anonymous
Not applicable

Okay, thank you.  That answers part of my question, however your mention of "subAnim:true" relates to Scripted Plugins. 

 

I'm not using that functionality (don't know much about it).   I'm just creating the custom attribute using the Parameter Editor tool.  What is the syntax of the command that would allow that custom attribute to appear in track view?

 

 

0 Likes
Message 4 of 7

Swordslayer
Advisor
Advisor
Accepted solution

Ah, okay, I don't use that so I'm only used to writing them directly with full control. In that case you'd need to edit the custom attribute source - not sure if that's worth your while. For example if it was the only custom attribute definition added to a selected object, evaluating:

custAttributes.getDefSource (custAttributes.getDef $ 1)


in the listner will return the definition. You can then look inside the parameters, find those that use type:#node and insert subAnim:true. The whole text will start and end with quotes and you have to escape the inner quotes (put \ in front of them so all the inner quotes are now \"). Replacing the definition is then if we continue with the example (where .object is the #node parameter):

custAttributes.redefine (custAttributes.getDef $ 1) \
"attributes Custom_Attributes version:0
(
    parameters main rollout:params
    (
        object Type:#node subAnim:true UI:pbNodeParam
    )

    rollout params \"Attributes\"
    (
        pickButton pbNodeParam \"OBJECT\" autoDisplay:true
    )
)"


Note that the parameter will only appear in trackview when a node is stored there, otherwise it will be still hidden.

Message 5 of 7

Anonymous
Not applicable

Okay, I used your line to retrieve the current definition... then I took the relevant portion of your redefinition text (the subAnim part) and fit it into what was already there.

 

I see that the + sign next to Custom_Attributes showed up in track view after running this redefinition... however even if I choose a Node, the actual track name (TargetObject) still doesn't appear underneath Custom_Attributes.  Any ideas?

 

Here is the redefinition I used...

 

custAttributes.redefine (custAttributes.getDef $ 1) \
"attributes Custom_Attributes version:0
(
    parameters main rollout:params
    (
        'TargetObject' Type:#node subAnim:true UI:'TargetObject'
    )

    rollout params \"Choose Target\"
    (
        pickbutton 'TargetObject' \"TargetObject\" Width:150 Height:25 Align:#Center Offset:[0,0] Type:#node autoDisplay:true
    )
)"

 

0 Likes
Message 6 of 7

Swordslayer
Advisor
Advisor

You're right, the subAnim parameter doesn't work as expect, contrary to what the documentation says... Could you file a bug? I don't have an advice on how to make it work, unless it would be a workaround - what did you plan to use it for?

Message 7 of 7

Anonymous
Not applicable

What was I going to use it for?  Good question.  It was mostly an experiment. 

 

Originally, I had the idea because I was going to directly select the track as a variable in a script controller (so I wouldn't have to worry about explicit name dependence).

 

However based on another thread in this forum -- you gave me the idea of just selecting the parent as an object variable (i didn't think i could self-reference an object when the script controller was already in the  object -- but it of course worked).

 

 

0 Likes