FCurveKey.Constraint

FCurveKey.Constraint

説明

指定されたF カーブキーのコンストレイントが設定されているかどうかを示すBoolean値を設定したり、戻したりします。siFCurveKeyConstraint 値はタイプ Long です(指定可能な値のリストについては siFCurveKeyConstraint を参照)。

警告:Python では、このプロパティの取得および設定はサポートされていません。Python で特定のコンストレイントを設定する場合は、fcrvkey.SetConstraint( c.siLockConstraint, true )メソッド構文に"Set"プリフィックスを使用します。この操作については、以下の Python の例で説明します。特定のコンストレイントを取得する場合は、代わりに Python互換メソッド FCurveKey.GetConstraint2 を使用します。

C#構文

// get accessor

Boolean FCurveKey.get_Constraint( siFCurveKeyConstraint in_eConstraint );

// set accessor

FCurveKey.set_Constraint( siFCurveKeyConstraint in_eConstraint, Boolean out_pVal );

パラメータ

パラメータ タイプ 説明
Constraint siFCurveKeyConstraint 設定するか戻すF カーブキーコンストレイントのタイプ複数の値を同時に追加し、一度に複数のコンストレイントを指定できます。

たとえば、すべてのパラメータをロックして、左タンジェントと右タンジェントの長さを揃えるには、siParameterConstraint と siSameLengthTangentConstraint を使用します。

1. JScript の例

/* 

	This example illustrates how to create an fcurve with keys and then how to set a 

	constraint on one of the keys. 

*/ 

// ---------------------------------------------------------------------------------

// Functions and Setup

// ---------------------------------------------------------------------------------

function GetConsList(fckey,setchk)

{

	var dicConstraintTypes = new ActiveXObject( "Scripting.Dictionary" );

	dicConstraintTypes.Add( "LockParameter",		siParameterConstraint );

	dicConstraintTypes.Add( "LeftRightParameter",		siLeftRightValuesConstraint );

	dicConstraintTypes.Add( "G1Continuous",			siG1ContinuousConstraint );

	dicConstraintTypes.Add( "LeftRightTangentDirection",	siLeftRightTangentDirectionConstraint );

	dicConstraintTypes.Add( "LeftRightTangentLength",	siLeftRightTangentLengthConstraint );

	dicConstraintTypes.Add( "LockAll",			siLockConstraint );

	dicConstraintTypes.Add( "HorizontalTangent",		siHorizontalTangentConstraint );

	dicConstraintTypes.Add( "ExtremumHorizontalTangent",	siExtremumHorizontalTangentConstraint );

	dicConstraintTypes.Add( "AdjustedTangent",		siAdjustedTangentConstraint );

	dicConstraintTypes.Add( "ZeroLengthTangent",		siZeroLengthTangentConstraint );

	dicConstraintTypes.Add( "SameLengthTangent",		siSameLengthTangentConstraint );

	dicConstraintTypes.Add( "NeighborTangent",			siNeighborTangentConstraint );

	dicConstraintTypes.Add( "MirrorTangent",			siMirrorTangentConstraint );

	dicConstraintTypes.Add( "AutoPlateauTangent",		siAutoPlateauTangentConstraint );

	var strlist = "";

	var vbKeys = dicConstraintTypes.Keys();		// the Dictionary.Keys method returns a safearray

	var jsKeys = vbKeys.toArray();			// that you can convert with the toArray() method

	for ( var k=0; k<jsKeys.length; k++ ) {

		if ( setchk == fckey.Constraint( dicConstraintTypes.Item(jsKeys[k]) ) ) {

			strlist += jsKeys[k] + " ";

		}

	}

	return strlist;

}

// ---------------------------------------------------------------------------------

// Create new scene

// ---------------------------------------------------------------------------------

NewScene( null, false );

// Create a null

var n = Application.ActiveSceneRoot.AddNull()

// Add a custompvar to the null

var cpset = n.AddProperty( "Custom_parameter_list", false, "CustomPSet" );

// Add a double parameter to cpset

var x = cpset.AddParameter3( "X", siDouble, 0, -100, 100, 1 );

// Create a fcurve on posx

var fc = x.AddFCurve2( new Array(1,0.5), siStandardFCurve );

var fckey = fc.Keys(0);

// ---------------------------------------------------------------------------------

// Set the siLockConstraint ( time, value & tangents are locked )

// ---------------------------------------------------------------------------------

// Set the Constraint property 

fckey.Constraint( siLockConstraint ) = 1;

if ( fckey.Constraint(siLockConstraint) ) {

	Application.LogMessage( "fckey(" + fckey.Index + ") lock all constraints: true" );

} else {

	Application.LogMessage( "fckey(" + fckey.Index + ") lock all constraints: false" );

}

Application.LogMessage( "fckey(" + fckey.Index + ") constraints set: " + GetConsList(fckey,true) );

Application.LogMessage( "fckey(" + fckey.Index + ") constraints NOT set: " + GetConsList(fckey,false) );

// If you try and change the key value when the lock constraint is on it raises 

// an 'Access Denied' error.

try {

	fckey.Value = 5;

} catch(e) {

	if ( e.number ) {

		Application.LogMessage( "fckey(" + fckey.Index + ") set value failed: " + e.description );

	}

}

// ---------------------------------------------------------------------------------

// Expected results::

// ---------------------------------------------------------------------------------

//INFO : fckey(0) lock all constraints: true

//INFO : fckey(0) constraints set: LockParameter LeftRightParameter G1Continuous LeftRightTangentDirection LeftRightTangentLength LockAll AutoPlateauTangent

//INFO : fckey(0) constraints NOT set: HorizontalTangent ExtremumHorizontalTangent AdjustedTangent ZeroLengthTangent SameLengthTangent NeighborTangent MirrorTangent

//INFO : 2009 - fckey(0) set value failed: Access denied

2. VBScript の例

' 

' This example illustrates how to create an fcurve with keys and then how to set a constraint 

' on one of the keys. 

' 

' ---------------------------------------------------------------------------------

' Functions and Setup

' ---------------------------------------------------------------------------------

function GetConsList(fckey,setchk)

	set dicConstraintTypes = CreateObject( "Scripting.Dictionary" )

	dicConstraintTypes.Add "LockParameter",			siParameterConstraint

	dicConstraintTypes.Add "LeftRightParameter",		siLeftRightValuesConstraint

	dicConstraintTypes.Add "G1Continuous",			siG1ContinuousConstraint

	dicConstraintTypes.Add "LeftRightTangentDirection",	siLeftRightTangentDirectionConstraint

	dicConstraintTypes.Add "LeftRightTangentLength",	siLeftRightTangentLengthConstraint

	dicConstraintTypes.Add "LockAll",			siLockConstraint

	dicConstraintTypes.Add "HorizontalTangent",		siHorizontalTangentConstraint

	dicConstraintTypes.Add "ExtremumHorizontalTangent",	siExtremumHorizontalTangentConstraint

	dicConstraintTypes.Add "AdjustedTangent",		siAdjustedTangentConstraint

	dicConstraintTypes.Add "ZeroLengthTangent",		siZeroLengthTangentConstraint

	dicConstraintTypes.Add "SameLengthTangent",		siSameLengthTangentConstraint

	dicConstraintTypes.Add "NeighborTangent",		siNeighborTangentConstraint

	dicConstraintTypes.Add "MirrorTangent",			siMirrorTangentConstraint

	dicConstraintTypes.Add "AutoPlateauTangent",	siAutoPlateauTangentConstraint

	strlist = ""

	dkeys = dicConstraintTypes.Keys()

	for each k in dkeys

		if setchk = fckey.Constraint(dicConstraintTypes.Item(k)) then

			strlist = strlist & k + " " 

		end if

	next

	GetConsList = strlist

end function

' ---------------------------------------------------------------------------------

' Create new scene

' ---------------------------------------------------------------------------------

NewScene , 0

' Create a null

set n = Application.ActiveSceneRoot.AddNull()

' Add a custompset to the null

set cpset = n.AddProperty( "Custom_parameter_list", , "CustomPSet" )

' Add a double parameter to cpset

set x = cpset.AddParameter3( "X", siDouble, 0, -100, 100, 1 )

' Create a fcurve on posx

set fc = x.AddFCurve2( array(1,0.5), siStandardFCurve )

set fckey = fc.Keys(0)

' ---------------------------------------------------------------------------------

' Set the siLockConstraint ( time, value & tangents are locked )

' ---------------------------------------------------------------------------------

' Set the Constraint property 

fckey.Constraint( siLockConstraint ) = 1

if fckey.Constraint( siLockConstraint ) then

	Application.LogMessage "fckey(" & fckey.Index & ") lock all constraints: true" 

else

	Application.LogMessage "fckey(" & fckey.Index & ") lock all constraints: false" 

end if

Application.LogMessage "fckey(" & fckey.Index & ") constraints set: " & GetConsList(fckey,true)

Application.LogMessage "fckey(" & fckey.Index & ") constraints NOT set: " & GetConsList(fckey,false)

' If you try and change the key value when the lock constraint is on it raises 

' an 'Access Denied' error.

on error resume next

fckey.Value = 5

if Err.Number then

	Application.LogMessage "fckey(" & fckey.Index & ") set value failed: " & Err.Description

end if

on error goto 0

' ---------------------------------------------------------------------------------

' Expected results::

' ---------------------------------------------------------------------------------

'INFO : fckey(0) lock all constraints: true

'INFO : fckey(0) constraints set: LockParameter LeftRightParameter G1Continuous LeftRightTangentDirection LeftRightTangentLength LockAll AutoPlateauTangent

'INFO : fckey(0) constraints NOT set: HorizontalTangent ExtremumHorizontalTangent AdjustedTangent ZeroLengthTangent SameLengthTangent NeighborTangent MirrorTangent

'INFO : 2009 - fckey(0) set value failed: Access denied

3. Python の例

# 

# This example illustrates how to create an fcurve with keys and then how to set a constraint 

# on one of the keys. 

# 

# ---------------------------------------------------------------------------------

# Functions and Setup

# ---------------------------------------------------------------------------------

# Get the Softimage constants from win32com.client and error handling from pythoncom

from win32com.client import constants as c

from pythoncom import com_error as e

constrainttypes = [ \

	(c.siParameterConstraint,			"LockParameter"),\

	(c.siLeftRightValuesConstraint,		"LeftRightParameter"),\

	(c.siG1ContinuousConstraint,			"G1Continuous"),\

	(c.siLeftRightTangentDirectionConstraint,	"LeftRightTangentDirection"),\

	(c.siLeftRightTangentLengthConstraint,		"LeftRightTangentLength"),\

	(c.siLockConstraint,				"LockAll"),\

	(c.siHorizontalTangentConstraint,		"HorizontalTangent"),\

	(c.siExtremumHorizontalTangentConstraint,	"ExtremumHorizontalTangent"),\

	(c.siAdjustedTangentConstraint,			"AdjustedTangent"),\

	(c.siZeroLengthTangentConstraint,		"ZeroLengthTangent"),\

	(c.siSameLengthTangentConstraint,		"SameLengthTangent"),\

	(c.siNeighborTangentConstraint,			"NeighborTangent"),\

	(c.siMirrorTangentConstraint,			"MirrorTangent"),\

	(c.siAutoPlateauTangentConstraint,		"AutoPlateauTangent") ]

def GetConsList(fckey,setchk):

	strlist = ""

	for ( c, strc ) in constrainttypes :

		if fckey.Constraint(c) == setchk:

			strlist += strc 

			strlist += " " 

	return strlist

# ---------------------------------------------------------------------------------

# Create new scene

# ---------------------------------------------------------------------------------

Application.NewScene("", 0)

# Create a null

null = Application.GetPrim("Null", "", "", "")

# Add a custompset to the null

cpset = null.AddProperty("Custom_parameter_list",0,"CustomPSet")

# Add a double parameter to cpset

x = cpset.AddParameter3( "X", c.siDouble, 0, -100, 100, 1 )

# Create a fcurve on posx

fc = x.AddFCurve2( [ 1, 0.5 ], c.siStandardFCurve )

fckey = fc.Keys(0)

# ---------------------------------------------------------------------------------

# Set the siLockConstraint ( time, value & tangents are locked )

# ---------------------------------------------------------------------------------

# Notice how you have to use 'SetConstraint' for the Constraint property when setting

fckey.SetConstraint(c.siLockConstraint,1)

if fckey.Constraint(c.siLockConstraint) :

	Application.LogMessage( 'fckey(%d) lock all constraints: true' % (fckey.Index) )

else :

	Application.LogMessage( 'fckey(%d) lock all constraints: false' % (fckey.Index) )

Application.LogMessage( 'fckey(%d) constraints set: %s' % (fckey.Index,GetConsList(fckey,1)))

Application.LogMessage( 'fckey(%d) constraints NOT set: %s' % (fckey.Index,GetConsList(fckey,0)))

# If you try and change the key value when the lock constraint is on it raises 

# an 'Access Denied' error.

try:

	fckey.Value = 5

except e, (hr, msg, exc, arg):

	if exc and exc[2]: msg = exc[2]

	Application.LogMessage( 'fckey(%d) set value failed: %s' % (fckey.Index,msg))

# ---------------------------------------------------------------------------------

# Expected results::

# ---------------------------------------------------------------------------------

#INFO : fckey(0) lock all constraints: true

#INFO : fckey(0) constraints set: LockParameter LeftRightParameter G1Continuous LeftRightTangentDirection LeftRightTangentLength LockAll AutoPlateauTangent

#INFO : fckey(0) constraints NOT set: HorizontalTangent ExtremumHorizontalTangent AdjustedTangent ZeroLengthTangent SameLengthTangent NeighborTangent MirrorTangent

#INFO : 2009 - fckey(0) set value failed: Access denied

関連項目

FCurveKey.GetConstraint2