Use vrConstraintService
, as well as vrdConstraintNode
, when working with constraints via Python.
We have added an example file, SimpleConstraint.vpb
, that demonstrates how to use the following Python contraint functions. To access the example file, select File > Open Examples... > SimpleConstraint.vpb.
Python Constraints Video Captions: In VRED 2020, we have implemented the ability to create constraints using the scripting language Python. For working with the constraints, please use the Python documentation. Here you will find all important information on how to create and use the constraints. The simple constraint example shows different constraints and their effects.
The following objects and functions are supported:
These are the supported objects:
These are the vrConstraintService
functions:
createPositionConstraint
Creates a positional constraint.createOrientationConstraint
Creates an orient constraint for limiting and controlling the rotation of the constrained object.createAimConstraint
Creates an aim constraint for limiting and controlling the rotation and aim of the constrained object. Use an aim constraint for constraining one object, so it always points at its target.getConstraints
Returns a list of all constraints.findConstrainedNode
Returns a list of all constraints with an assigned constrained node.deleteConstraint
Deletes the specified constraint.vrdConstraintNode (base class)
is used for constraining the position or orientation of one object to another. Try imposing limits on objects and automating animated processes.
These are the vrdConstraintNode
functions:
setActive
Sets the constraint as active or inactive.
isActive
Returns if the constraint is active.
setTargetNodes
Sets the constraint's target nodes.
getTargetNodes
Returns a list of target nodes.
clearTargetNodes
Clears the constraint target nodes.
setTargetNodeWeight
Sets the weight for a target node. The weight controls the object's influence over the target point, orientation, scale, vector, and so on. The resulting weighted average drives the constrained object’s position, orientation, and so on.
Use constraint weights only with multiple target objects. When used with only one target object, any weight greater than 0 will be interpreted as full influence. Therefore, the single target will have 100% influence over the constrained object.
getTargetNodeWeight
Returns the weight of the target node.
setConstrainedNode
Sets which node is the constrained node.
getConstrainedNode
Returns the name of the constrained node.
clearConstrainedNode
Clears the constrained node.
vrdPositionConstraintNode
makes an object move and follow the position of another object or the average position of several. Use this for matching the motion of objects with that of another.
Try using a position constraint to animate an object to follow a series of others.
These are the specific vrdPositionConstraintNode
functions:
setMaintainOffset
Sets to preserve the original (state prior to constraining), relative translation of the constrained object. Use this option to maintain spatial relationships between constrained objects.getMaintainOffset
Returns if the maintain offset is set.vrdOrientationConstraintNode
is for an orient constraint. It matches the orientation of an object to one or more other objects. Use it for making several objects orient, simultaneously. For example, make a group of objects, such as the steering wheel, tires, and headlights, rotate in the same direction, at the same time. Animate the steering wheel, then constrain the tires and headlights to the animated steering wheel.
vrdAimConstraintNode
is for an aim constraint, which constrain an object’s orientation and aims the object at other objects. Use it to aim a camera or light at an object or group of objects.
These are the specific vrdAimConstraintNode
functions:
setUpVectorTargetNodes
Sets the target nodes which define the up-vector position.getUpVectorTargetNodes
Returns the up-vector target nodes.clearUpVectorTargetNodes
Clears the up-vector target nodes.setUpVectorTargetNodeWeight
Sets the weight for an up-vector target node.getUpVectorTargetNodeWeight
Returns the weight for an up-vector target node.