2 Replies Latest reply on Nov 9, 2017 11:28 PM by akanoo RSS
    akanoo Newbie

    Change Color of a ModelItem


    What I want to do is to have a button, which when clicked changes the part color during the experience.

    I have applied model item widget to the part for which I want the color to change. given the desired color . Placed a toggle button and binded it to the model item color property.  But in the preview it doesn't work.

    Alos, I followed the steps in the Article - CS251748 and still couldn't achieve my goal .

    Kindly assist.

      • Re: Change Color of a ModelItem
        rolandr Explorer

        Hi Abihishek,

        I tested the suggested techniques in article  and it was working fine:

        There the example shows e:

        1.)slider value changed the value of app parameter

        HERE the binding of the parameter has an filter defined as return 'rgba(' + value+ ',0,0,0.4);'; - which means it is the value of the paramter

        So far I know it could has a value of 0-240 if we follow the user interface

        2.)parameter is binded to the value of the Model Item property

        So when we change the now the slider from 0-240 value it will change the red color

        So back to your question in your case the click of your button should change for example the value of the parameter

        app.params['ItemColor']between value of 1 and 0

        in this case you can define a filter  e.g.:

        if(value ==1)

        return 'rgba(240,0,0,0.5);';

        else

        return 'rgba(0,0,240,0.3);';


        This will change  the color depending of this if the button is clicked or not