Edge Constraint Toggle

Hi guys!

So, I started to make a script that basically shows me on the UI if the edge constraint it ON or OFF on the selected object.

Basically I have it as a button on the UI, and when I have an object selected and I press the button It toggles it and enables Edge constraint to edge and stays lit up. But when I deselect the object the toggle is still on.

Would it be possible for the Toogle button to make the test on the object i select and see if the edge constraint is on and toggle it acordingly.
Obviously if its a group of object it wouldnt do anything, i think.

This is what i have.

macroScript test category:"Tests"
(
	local isOn = false --initialize to false (closed)
 
	on execute do (
		if ( $ != undefined) then (
			if isOn == true then ( --if open, close it
				isOn = false--and lower the flag
				$.constrainType = 0
			) else ( --if closed, open it
				$.constrainType = 1
				isOn = true --and raise the flag
			)
		)
	)
		on isChecked return isOn --return the flag
)

i have both the script as a button and a shortcut, so basically it runs the script on the object and togles the button on or off.

Cheers!
-P

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

This

selection[1].constrainType

will print in the listener the current active Cosntraynt type.
So when you press the button/hotkey you can check the active constraint type and can change it or not.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.