OutputPort.Value operator

説明

このプロパティは、Operatorの Update コールバック内でのみ使用できます。出力がパラメータかオブジェクトかによって、設定または読み取りのどちらかが行われます。

オペレータ OutputPort がParameterに接続されている場合に、このプロパティを使用すると、パラメータの値を設定できます(Parameter.Valueを使用して値を変更しようとすると、機能しないことがあります)。

オペレータOutputPort がオブジェクトに接続されている場合、このプロパティは出力に対応した SDk オブジェクトを戻します。

注:複数の出力を持つオペレータの場合は、現在評価している出力ポート上のこのプロパティにのみアクセスできます。

JScript の例

/*
        This example illustrates how to use the OutputPort.Value property within 
        the context of the _Update function of a runtime scripted operator
*/
NewScene( null, false );
var oObject = Application.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" );
apply_taper( oObject );
// This is the _Update callback used for the 'MyTaper' runtime operator
function MyTaper_Update( ctx, Out, InGeom )
{       
        // Get the taper factor.
        var dFactor = ctx.Parameters("Factor").Value
        // Get the array of point positions.
        var aPnts = InGeom.Value.Geometry.Points.PositionArray.toArray();
        // Taper
        for ( var i = 0; i < aPnts.length / 3; i++ )
        {
                var dTaper = (1 - ( aPnts[1 + (i*3)] * dFactor ))
                aPnts[0 + (i*3)] = aPnts[0 + (i*3)] * dTaper;
                aPnts[1 + (i*3)] = aPnts[1 + (i*3)];
                aPnts[2 + (i*3)] = aPnts[2 + (i*3)] * dTaper;
        }
        // Set the points by accessing the geometry via
        // the OutputPort.Value property
        Out.Value.Geometry.Points.PositionArray = aPnts;
}       
// This function creates the 'MyTaper' operator on the fly and then connects it
// immediately to the input object.
function apply_taper( oObject )
{
        var op = XSIFactory.CreateScriptedOp( "MyTaper", MyTaper_Update.toString(), "JScript" );
        // Define connections
        var ioport = op.AddIOPort( oObject.ActivePrimitive, "Geom" );
        // Define parameters
        var pdef = XSIFactory.CreateParamDef2( "Factor", siDouble, 0.5, 0, 1 );
        op.AddParameter( pdef );
        // Connect operator
        op.Connect( oObject );
}

関連項目

Parameter.Value OperatorContext.OutputPort OperatorContext.OutputTarget