ScriptSpot

Forum topic · General Scripting

Access Attribute Holder Rollout Controls from external function not working

By rode3d · 2015-05-27

Description

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 (7)

victorgilbert · 2015-06-04

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

`

pixamoon · 2015-06-04

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 · 2015-06-01

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

`

pixamoon · 2015-06-02

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 · 2015-06-03

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 · 2015-06-03

great :)

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

rode3d · 2015-06-01

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??