Scripting: Toggling the constraint compensation mode


Here’s one way, using the not operator.

si = Application
si.SetUserPref( "SI3D_CONSTRAINT_COMPENSATION_MODE", not si.GetUserPref("SI3D_CONSTRAINT_COMPENSATION_MODE") )

The “problem” with this approach is that you’re toggling between 0 and -1, not between 0 and 1 (when you click the CnsComp button in the UI, you set the pref to either 0 or 1). The -1 happens because not 0 is -1.

Application.LogMessage( True == 1 )
Application.LogMessage( False == 0 )
Application.LogMessage( not False == -1 )
# INFO : True
# INFO : True
# INFO : True

So here’s a couple of other ways to toggle the preference value:

si = Application
si.SetUserPref( "SI3D_CONSTRAINT_COMPENSATION_MODE", 0 if si.GetUserPref("SI3D_CONSTRAINT_COMPENSATION_MODE") else 1 )
si = Application
toggle = [1,0]
si.SetUserPref( "SI3D_CONSTRAINT_COMPENSATION_MODE", toggle[si.GetUserPref("SI3D_CONSTRAINT_COMPENSATION_MODE")] )

One thought on “Scripting: Toggling the constraint compensation mode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s