## RemoveCns

### Description

Removes the specified constraints between objects.
Tip: If you want to remove all constraints matching a particular constraint type instead, use the RemoveCnsType command.

### Scripting Syntax

    RemoveCns( [ConstrainedObj], [ConstrainingObj], [ForceDeletion] );

### Parameters

Parameter | Type | Description
--- | --- | ---
ConstrainedObj | String | List of objects to be constrained. If you pass in a variable, the command returns a XSICollection of the constrained objects. Default Value: Selected objects
ConstrainingObj | String | List of constraining objects. If you pass in a variable, the command returns a XSICollection of the constrained objects. Default Value: User is prompted to pick if there is more than one constraining object for a constrained object
ForceDeletion | Boolean | True to delete all constraints (user is not prompted to pick constraining objects) Default Value: False

### Examples

#### VBScript Example

    '
    ' This example creates a little planetary scene and applies 2 constraints
    ' from the planet (Position constraints on the ring and the moon). Then
    ' it removes only the moon's constraint by using the RemoveCns command
    ' and verifies this by printing out a list of constraints on each object
    ' before and after removing the constraints.
    '
    ' Create a planet that will serve as the constraining object
    set oPlanet = CreatePrim( "Sphere", "NurbsSurface", "Planet" )
    ' Create a moon to be constrained by the planet and scale it
    set oMoon = CreatePrim( "Sphere", "NurbsSurface", "Moon" )
    Translate oMoon, -6, 4, -5, siRelative, siView, siObj, siXYZ
    Scale oMoon, 0.15, 0.15, 0.15, siAbsolute, siParent, siObj, siXYZ
    ' Create a ring to be constrained by the planet and scale it
    set oRing = CreatePrim( "Disc", "NurbsSurface", "Ring" )
    Scale oRing, 2.3, 1, 2.3, siAbsolute, siParent, siObj, siXYZ
    ' Apply a Position constraint on the ring and the moon from the planet.
    ' (The small sphere and the disc depend on the position of the larger sphere.)
    ' 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", oMoon.Name & "," & oRing.Name, "Planet", true
    ' Check to see which constraints are currently set
    getCnsInfo oPlanet
    getCnsInfo oMoon
    getCnsInfo oRing
    ' Remove the constraint on the moon but keep the constraint on the ring.
    ' Here too you have to pass the name of the object instead of the object
    ' variable.
    RemoveCns oMoon.Name, oPlanet.Name
    ' Check to see which constraints remain
    getCnsInfo oPlanet
    getCnsInfo oMoon
    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 Moon:"
    'INFO : "       Position Cns"
    'INFO : "Found the following constraints on the Ring:"
    'INFO : "       Position Cns"
    '
    ' ...after removing constraint:
    'INFO : "No constraints found on Planet"
    'INFO : "No constraints found on Moon"
    'INFO : "Found the following constraints on the Ring:"
    'INFO : "       Position Cns"

### See Also

RemoveCnsType RemoveAllCns SIApplyConstraint SIApplyCns