[Closed] Custom attribute problem
Hi Folks,
I am doing an autorig in 3dsmax for my rigging tools, and after 2 years without touching anything in Maxscript, I decided to improve the tool, but I have a problem when adding a custom attribute.
The point is before the script was runing just fine, indeed it works fine, but when i isolate the function which add custom attribute, the function doesn’t work anymore…
here is the script:
fn addCA theNode =
(
NewAttr = EmptyModifier()
NewAttr.name="IK_Blend"
addmodifier theNode NewAttr
IKFK_CA = attributes ik_switch
(
parameters PRM_IKFK_CA rollout:IKSwitch
(
swtch_Ik_fk type:#float ui: (sp_IKFK) default: 1
stretchP type:#float ui: (stretchSp,stretchSl) default: 1
softP type:#float ui: (softSp,softSl) default: 0
pinP type:#float ui: (pinSp,pinSl) default: 0
fkBtn type:#boolean ui: (ui_FKIK) default: false
ikBtn type:#boolean ui: (ui_IKFK) default: false
freeOt type:#boolean ui: (freeOrient) default: false
freeElbo type:#boolean ui: (freeElbow) default: false
)
rollout IKSwitch "FK <---> IK"
(
button ui_FKIK "FK" width:30 height:30 align:#Left across: 3
spinner sp_IKFK "Blend" range:[0,1,1] fieldWidth: 40 align:#center across:1
button ui_IKFK "IK" width:30 height:30 align:#Right
spinner stretchSp "" range:[0,1,0]
slider stretchSl "Auto Stretch" range:[0,1,0] offset:[0,-20]
spinner softSp "" range:[0,10,0]
slider softSl "Soft IK" range:[0,10,0] offset:[0,-20]
spinner pinSp "" range:[0,1,0]
slider pinSl "Pin Elbow" range:[0,1,0] offset:[0,-20]
checkbutton freeOrient "Arm Free Orient" checked: false width:80 height:30 align:#center
checkbutton freeElbow "Free Elbow" checked: false width:80 height:30 align:#center
)
rollout CopyArms "Paste Pose to R side"
(
button CopyPaste "Paste Arms Pose" width:180 height:30
button CopyPasteHands "Paste Hand Pose" width:180 height:30
)
)
custattributes.add theNode.modifiers["IK_Blend"] IKFK_CA baseobject: False
)
the max error returned is:
-- Error occurred in anonymous codeblock; filename: H:\Personel\Autorig\Fonction addCA.ms; position: 1704; line: 51
-- Unknown property: "modifiers" in $selection
-- MAXScript callstack:
-- thread data: threadID:17928
-- ------------------------------------------------------
-- [stack level: 0]
-- In addCA(); filename: H:\Personel\Autorig\Fonction addCA.ms; position: 1705; line: 51
-- Parameters:
-- theNode: $selection
-- Locals:
-- theNode: $selection
-- IKFK_CA: <AttributeDef:ik_switch>
-- Externals:
-- owner: undefined
-- ------------------------------------------------------
-- [stack level: 1]
-- called from top-level
I am on max 2017.
Thanks
The problem is you are passing selection (a collection of objects) instead of an actual object in the theNode variable. Addmodifier can only take 1 object at a time not a collection.
-Eric
this is not an issue in you case but…
NEVER DEFINE A CUSTOM ATTRIBUTE WITHOUT UNIQUE ATTRIBUTE ID !!!
Hello,
Sorry, theNode in my function is for a specified node.
Anyway I ‘ve found my error, i miss the “#” before IK_Blend in
custattributes.add theNode.modifiers[“IK_Blend”] IKFK_CA baseobject: False Line.
Thanks.