RemoveCnsType

Description

Removes all constraints of a specific constraint type from one or more objects without affecting any constraints of a different type on the object.

Tip: If you want to remove constraints by name instead, use the RemoveCns command.

Scripting Syntax

RemoveCnsType( Type, [ConstrainedObj] )

Parameters

Parameter

Type

Description

Type

String

Type of constraint to remove.

ConstrainedObj

String

List of constrained objects.

Default Value: Selected objects

Examples

VBScript Example

'
' This example creates a little planetary scene and applies 2 constraints
' from the planet to the ring: a Position and a Scaling constraint. Then
' it removes only the Scaling constraint by using the RemoveCnsType command
' and verifies this by printing out a list of constraints on each object
' before and after removing the constraints.
'
' Create a sphere that will serve as the constraining object 
set oPlanet = CreatePrim( "Sphere", "NurbsSurface", "Planet" )

' Create a ring to be constrained by the planet and scale it
set oRing = CreatePrim( "Disc", "NurbsSurface", "Ring" )
Scale , 2.3, 1, 2.3, siAbsolute, siParent, siObj, siXYZ

' Apply a Position constraint between the ring and the planet. Notice that 
' you have to pass the name of the object instead of its object variable with
' this command because the command changes that variable to a different type
ApplyCns "Position", oRing.Name, oPlanet.Name, true

' Now apply a Scaling constraint between the ring and the planet
ApplyCns "Scaling", oRing.Name, oPlanet.Name, true

' Check to see which constraints are currently set 
getCnsInfo oPlanet
getCnsInfo oRing

' Remove only the Scaling constraint of the ring, 
' (the Position constraint is kept automatically)
RemoveCnsType "Scaling", oRing

' Check to see which constraints remain
getCnsInfo oPlanet
getCnsInfo oRing

' Display the constraint relationship in all the default views and
' the default camera view. This is the equivalent of turning on 
' "Relation" and "Relation Info" in the view visibility options.
SetValue "Views.*.*.camvis.*constraint*", True 
SetValue "Camera.camvis.*constraint*", True



' This function just saves us time and typing
function getCnsInfo( in_constrained_obj )
   set oFoundCns = in_constrained_obj.Kinematics.Constraints
   if oFoundCns.Count > 0 then
       LogMessage "Found the following constraints on the " & in_constrained_obj & ":"
       for each c in oFoundCns
          LogMessage vbTab & c.Name
       next
   else
       LogMessage "No constraints found on " & in_constrained_obj
   end if
end function



' Output of the above script:
' 
' ...before removing constraint:
'INFO : "No constraints found on Planet"
'INFO : "Found the following constraints on the Ring:"
'INFO : " Position Cns"
'INFO : " ScalingCns"
' 
' ...after removing constraint:
'INFO : "No constraints found on Planet"
'INFO : "Found the following constraints on the Ring:"
'INFO : " Position Cns"

See Also

RemoveAllCns

SIApplyCns

SIApplyConstraint



Autodesk Softimage v7.5