Constrains an object to one or more constraining objects. Constraints are placed under the kinematics property of the constrained object. SIApplyCns differs from ApplyCns in that it does not display the constraint's property page.
oReturn = SIApplyCns( PresetObj, [ConstrainedObj], [ConstrainingObj], [Compensation] ); |
Returns an XSICollection of Constraint objects.
Parameter | Type | Description |
---|---|---|
PresetObj | String or a preset object (see SIGetPreset) | Constraint preset. Warning: The preset name is case-sensitive on Linux. |
ConstrainedObj | String | List of objects to be
constrained. If you pass in a variable, the command returns a
XSICollection of the
constrained X3DObjects.
Default Value: Selected objects |
ConstrainingObj | String | List of constraining
objects. If you pass in a variable, the command returns a XSICollection of the constraining
X3DObjects.
Default Value: User is prompted to pick |
Compensation | Boolean | True to turn on compensation
Default Value: False |
' ' Orientation constrain two cones to a cube, compensating one of them. ' dim oCube, oConeCompensated, oConeUncompensated ' ' get a cube and rotate it so we can see how orientation is being constrained. ' set oCube = GetPrim("Cube") oCube.length = 2 Scale oCube, 0.5, 3, 0.5, siRelative, siLocal, siObj, siXYZ Rotate oCube, 45, 0, 45, siRelative, siAdd, siObj, siXYZ ' ' create the two cones and put on either side of the cube ' set oConeCompensated = GetPrim("Cone") Translate oConeCompensated, -4, 0, 0, siAbsolute, siParent, siObj, siXYZ set oConeUncompensated = GetPrim("Cone") Translate oConeUncompensated, 4, 0, 0, siAbsolute, siParent, siObj, siXYZ ' ' Apply the constraints ' SIApplyCns "Orientation", oConeCompensated, oCube, true SIApplyCns "Orientation", oConeUncompensated, oCube, false ' ' display the constraint relationship in the camera view ' SetValue "Camera.camvis.*constraint*", True ' ' log the constraint offsets to show ' that one has been compensated ' dim comp_x,comp_y,comp_z,uncomp_x,uncomp_y,uncomp_z comp_x = GetValue( oConeCompensated&".kine.oricns.offx") comp_y = GetValue( oConeCompensated&".kine.oricns.offy") comp_z = GetValue( oConeCompensated&".kine.oricns.offz") uncomp_x = GetValue( oConeUncompensated&".kine.oricns.offx") uncomp_y = GetValue( oConeUncompensated&".kine.oricns.offy") uncomp_z = GetValue( oConeUncompensated&".kine.oricns.offz") logmessage "Compensated cone offsets: x= " & comp_x & " y= " & comp_y & " z= " & comp_z logmessage "Uncompensated cone offsets: x= " & uncomp_x & " y= " & uncomp_y & " z= " & uncomp_z 'Results of running this script: 'INFO : "Compensated cone offsets: x= -35.2643896827547 y= -30 z= -35.2643896827547" 'INFO : "Uncompensated cone offsets: x= 0 y= 0 z= 0" |