Notifications
Clear all

[Closed] custom attributes color problem

Hey guys,

     I have a problem with trying to control the diffuse color of an object with a custom attribute.
     
     This script works correctly until I save the resulting max file. When I reopen the file the custom attribute is no longer connected to the diffuse.
     
     Anyone have any ideas?

         sphere()
        $sphere01.material = standardmaterial()
        ca = attributes colorControls
            (
                parameters params rollout:LBR
                (
                    LA1 type:#color ui:LA1SP
                )
                
                rollout LBR "diffuse controls"
                (
                colorpicker LA1SP "" fieldwidth:25 height:25 --pos:[5,30]
                )
            )    
        select $sphere01
        modPanel.addModToSelection (EmptyModifier ()) ui:on
        custattributes.add $sphere01.modifiers[1] ca
                
        paramWire.connect2way $sphere01.material[#Shader_Basic_Parameters][#Diffuse_Color] $sphere01.modifiers[#Attribute_Holder].colorControls[#LA1] "LA1" "Diffuse_Color"   
             
5 Replies

seeing as it’s a two-way connection, I’m wondering if you’re running into this potential generic bug:

http://forums.cgsociety.org/showthread.php?f=98&t=735370 Garbage Collection Bug?

Thanks for the info Zeboxx

To test further I manually used the reaction manager to control the color from my custom attribute.

again saving loses the connection.

Since this is caused in the Paramter wire dialog and the reaction manager, I am now thinking I am doing my custom attribute wrong.

I still dont have a solution.

Hi,
Any special reason to use wire parameters ?
I’d use the ‘on <var> set val do …” paramblock handler

 

sphere()
$sphere01.material = standardmaterial()
ca = attributes colorControls
(
 parameters params rollout:LBR
 (
  LA1 type:#color ui:LA1SP
  on LA1 set val do ($sphere01.material.diffuse=val)
  on LA1 get val do (val = $sphere01.material.diffuse;val)
 )
 rollout LBR "diffuse controls"
 (
  colorpicker LA1SP "" fieldwidth:25 height:25 --pos:[5,30]
 )
)	
select $sphere01
modPanel.addModToSelection (EmptyModifier ()) ui:on
custattributes.add $sphere01.modifiers[1] ca


Thanks. But this still gives me the same error. Once I save the file and re-open it. The link is lost. Very strange.

Is there a way to reconnect the custom attributes to the material value after reload?