オブジェクト間の指定のコンストレイントを削除します。
ヒント: 指定のコンストレイントではなく、特定のコンストレイントタイプに合致するすべてのコンストレイントを削除する場合は、RemoveCnsType コマンドを使用します。
RemoveCns( [ConstrainedObj], [ConstrainingObj], [ForceDeletion] ); |
パラメータ | タイプ | 説明 |
---|---|---|
ConstrainedObj | 文字列 |
拘束されるオブジェクトのリスト。変数を渡すと、コマンドは拘束されるオブジェクトの XSICollection を戻します。 デフォルト値: 選択されたオブジェクト |
ConstrainingObj | 文字列 |
コンストレイント オブジェクトのリスト。変数を渡すと、コマンドは拘束されるオブジェクトの XSICollection を戻します。 デフォルト値:1つの被拘束オブジェクトに対し、拘束する側のオブジェクトが複数あるかどうかをユーザに問い合わせます。 |
ForceDeletion | Boolean |
True を設定すると、すべてのコンストレイントが削除されます(ユーザは、コンストレイントしているオブジェクトの選択を要求されません)。 デフォルト値: False |
' ' 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" |