Operator.DisconnectGroup

Introduced

v4.0

Description

Disconnects the object connected to a PortGroup instance.

C# Syntax

Operator.DisconnectGroup( Int32 in_group, Int32 in_instance, Boolean in_force );

Scripting Syntax

Operator.DisconnectGroup( Group, Instance, [Force] );

Parameters

Parameter Type Description
Group Long Which port group to disconnect
Instance Long Port group index to which the object is connected.
Force Boolean Force the disconnection of the object even if the port is not optional.

Default Value: False

Examples

JScript Example

/*
	This example demonstrates how to disconnect an object from a group in a runtime custom operator.
*/
NewScene( null, false );
var null1 = GetPrim( "null" );
var null2 = GetPrim( "null" );
var sop = XSIFactory.CreateScriptedOp( "myexpr", myexpr_Update.toString(), "JScript" );
sop.Debug = 1;
var group1 = sop.AddPortGroup( "MainGroup" );
sop.AddIOPort( null1.Kinematics.Local,"", group1.Index );
// Add a second group with an optional port
var group2 = sop.AddPortGroup( "SecondGroup", 0, 1 );
sop.AddInputPort( null2.Kinematics.Local, "", group2.Index, -1, siOptionalInputPort );
// Connect operator
sop.Connect( null1 + ";" + null2 );
// null2 will rotate with null1
Rotate( null2, 90 );
// Disconnect null2 from second port group
sop.DisconnectGroup( group2.Index, 0 );
// null1 is no longer constrained
Rotate( null2, 180 );
// This operator constrains the rotation of the connected (target) object to the
// rotation of the object connected through the second portgroup.
function myexpr_Update( ctx, out, inlocal1, inlocal2 )
{
	Application.LogMessage( "myexpr_Update: " + out.Name );
	Application.LogMessage( ""+(inlocal2) );
	var transfo = inlocal1.Value.Transform;
	// Is an object connected to this group?
	if ( ctx.Operator.GetNumInstancesInGroup( 1 ) )
	{
		var inlocal2 = ctx.Operator.PortAt( 0, 1, 0 );
		// Is the port connected?
		if ( inlocal2.IsConnected )
		{
			var rot = XSIMath.CreateRotation();
			inlocal2.Value.Transform.GetRotation(rot);
			transfo.SetRotation( rot );
		}
	}
	out.Value.Transform = transfo;
}
// Expected results:
//INFO : 4000 - myexpr<238> Evaluate frame(sec)=0.033367, Outlocal(null.kine.local)
//INFO : myexpr_Update: Outlocal
//INFO : undefined

See Also

Operator.ConnectToGroup