Programming with constraints

Blender has many constraints that you may apply to an object. Some of them are quite like drivers, in the sense that they do not restrict a motion of an object but copy some parameters such as rotation or location. From a developer's point of view, each Blender Object has a constraints attribute that is a sequence of constraint objects. This sequence can be appended and items from this sequence can be deleted. It is also possible to alter the order of the items.

Method

Action

Example

append(type)

Appends a new constraint to an object and returns the constraint

ob.constraints.append( Constraint.Type.TRACKTO)

remove(constraint)

Removes a constraint from an object

ob.constraints.remove( ob.constraints[0])

moveUp(constraint)

moveDown(constraint)

Change the position of a constraint in the list of constraints

ob.constraints.moveDown( ob.constraints[0])

[]

Accesses an attribute of a constraint

Con = ob.constraints[0]

Con[Constraint.Settings. TARGET] = other

New Constraint objects are not instanced by way of a constructor, but by calling the append() method of the constraints attribute with the type of the constraint to add. append() will then return the new Constraint whose settings may then be altered.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.211.92