Toggle value between 0 and 1 to blend constraint´s weight

Discussions concerning programming of SOFTIMAGE©
User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Toggle value between 0 and 1 to blend constraint´s weight

Post by sirdavid32 » 31 Aug 2010, 16:13

Hello everyone. I am trying to create a synoptic button that when pressed once,
will enable the current weight influence of a constraint to 1 and when I press it again
it will roll it back to zero.

I checked the toggle value command on the script editor, but I think I´m not approaching
the problem and the syntax correctly (im using VB):

ToggleValue ("Rig.Ctrl2_Hand_LFT_IK1.kine.posecns.blendweight, 1");

Could anyone please help me to code that button, please?
Thanks.

David.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Toggle value between 0 and 1 to blend constraint´s weight

Post by sirdavid32 » 31 Aug 2010, 17:20

Im switching to JS now, I got this:

if ("Rig.Ctrl2_IK1.kine.posecns.blendweight = 0") then
SetValue ("Rig.Ctrl2_IK1.kine.posecns.blendweight", 1);

But I get an error on the first line.
Any ideas?

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Toggle value between 0 and 1 to blend constraint´s weight

Post by xsisupport » 31 Aug 2010, 17:56

In your IF statement, all you have is a string.



You need something like this (in Jscript)

Code: Select all

if ( GetValue("Rig.Ctrl2_IK1.kine.posecns.blendweight") = 0 ) 
         SetValue ("Rig.Ctrl2_IK1.kine.posecns.blendweight", 1);
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Toggle value between 0 and 1 to blend constraint´s weight

Post by sirdavid32 » 31 Aug 2010, 18:24

Thank you my coded now it´s working after adding the second =
Great! now I´ll go experiment with the boolean value.

agedito
Posts: 6
Joined: 16 Mar 2010, 07:28

Re: Toggle value between 0 and 1 to blend constraint´s weight

Post by agedito » 01 Sep 2010, 07:39

A classic mathematic trick:

1 - 0 = 1
1 - 1 = 0

Code: Select all

oldValue = GetValue("Rig.Ctrl2_IK1.kine.posecns.blendweight")
SetValue ("Rig.Ctrl2_IK1.kine.posecns.blendweight", 1 - oldValue );