Access Attribute Holder Rollout Controls from external function not working

Hi everybody! Can anyone tell me why the function 'enableControl' is not working in this code?:

pt = Point()
 
addModifier pt (EmptyModifier())
 
myCA = attributes myData
(
    parameters main rollout:myRollout
    (
        myParam type:#boolean ui:ckbMyParam default:false
    )
    rollout myRollout "My Parameters"
    (
        checkbox ckbMyParam "My Param" enabled:false
    )
)
custAttributes.add pt.modifiers[#Attribute_Holder] myCA
 
 
function enableControl obj =
(
	obj.modifiers[#Attribute_Holder].myData.myRollout.ckbMyParam.enabled = true
)
 
enableControl pt

Thanks!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
victorgilbert's picture

i also think that the re

i also think that the re selecting will get it to its previous state, but not 100 percent sure...!

pixamoon's picture

`

actualy it was working after reselection, but not after saving and reopen...
Not wit should save setting, and load on reopen max file:

pt = Point()
 
addModifier pt (EmptyModifier())
 
myCA = attributes myData
(
    parameters main rollout:myRollout
    (
        myParam type:#boolean ui:ckbMyParam default:false enabled:false
	ckbMyParam_On type:#boolean
    )
    rollout myRollout "My Parameters"
    (
        checkbox ckbMyParam "My Param" enabled:(if ckbMyParam_On != undefined then ckbMyParam_On else false)
    )
)
custAttributes.add pt.modifiers[#Attribute_Holder] myCA
 
function enableControl obj a =
(
	obj.modifiers[#Attribute_Holder].myData.myRollout.ckbMyParam.enabled = a
	obj.modifiers[#Attribute_Holder].myData.ckbMyParam_On = a
)
 
enableControl pt false

Let me know it all works now.

Michele71's picture

--

I have not found a solution for my test script... the same problem...

pixamoon's picture

`

maybe this will help:

pt = Point()
 
addModifier pt (EmptyModifier())
 
myCA = attributes myData
(
	local a = (if a == undefined then false else a)
    parameters main rollout:myRollout
    (
        myParam type:#boolean ui:ckbMyParam default:false enabled:false
    )
    rollout myRollout "My Parameters"
    (
        checkbox ckbMyParam "My Param" enabled:a
    )
)
custAttributes.add pt.modifiers[#Attribute_Holder] myCA
 
 
function enableControl obj a =
(
	obj.modifiers[#Attribute_Holder].myData.myRollout.ckbMyParam.enabled = a
	obj.modifiers[#Attribute_Holder].myData.a = a
)
 
enableControl pt true

It just store extra local parameter to save on/off
Hope it helps
Pixamoon

rode3d's picture

--

That worked OK! Thanks a lot! :)

Just a comment: The first line of the function 'enableControl' now is not necessary. It can be erased.
Thanks Pixamoon!

pixamoon's picture

`

great :)

I think the line is needed when the object is selected and custom attributes are visible. It just refresh it

rode3d's picture

I realized the script actually works but...

I realized the script actually works but just temporarily and only if you have the point object selected. When you deselect the object and re-select it again then it goes back to previous state.

Any clue??

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.