Notifications
Clear all

[Closed] hopw do I remove a constraint uasing a script?

I selcetd anewly created object and type this in the listener:

$.rotation.controller
>>Controller:Euler_XYZ

If I have an orient constrained object selected:

$.rotation.controller
>>Controller:Orientation_Constraint

How can I remove that Orientation_Constraint controller?

4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

change it to Euler_XYZ


if iskindof node.rotation.controller Orientation_Constraint do node.rotation.controller = Euler_XYZ()

Sweet! thanks.
I was leaving the I[/I] off of the Euler_XYZ()

I guess you can’t ‘remove’ a controller per se, you must reassign it…

I ran this function on my objects:


	fn removeConstraints obj =(
		obj.position.controller=position_XYZ()
		obj.rotation.controller=Euler_XYZ()
	)

and the positions and orientations spazzed out…I guess I need to read their current positions first, then specify these as I assign the positon_XYZ() and EULER_XYZ() controllers.

you have to store and restore node’s transform to keep the node in place. like:


 fn removeConstraints obj =(
      tm = obj.transform
      obj.position.controller=position_XYZ()
      obj.rotation.controller=Euler_XYZ()
      obj.transform = tm
  )

great, thanks again.