Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Creating Paths to Parts

Sometimes you will need a path down to one of the node kit parts—for instance, to replace a part with a manipulator as described in Draggers and Manipulators. Use the createPathToPart() method to obtain the path to the desired node for the manipulator.

C++ :

**createPathToPart**( *partName*, *makeIfNeeded*, *pathToExtend* );

C# :

**CreatePathToPart**( *partName*, *makeIfNeeded*, *pathToExtend* );

Java :

For example, after picking a node kit, replace the transform part with a trackball manipulator:

C++ :

SoPath* pickPath = myPickAction->getPath();
if((pickPath != NULL) &&
(pickPath->getTail()->isOfType(SoBaseKit::getClassTypeId()))
{
SoTrackballManip* tb = new SoTrackballManip;
SoBaseKit* kit = ( SoBaseKit* )pickPath->getTail();
// extends the pick path all the way down
// to the transform node
SoPath* attachPath = kit->createPathToPart( "transform", TRUE, pickPath );
tb->replaceNode( attachPath );
}

C# :

SoPath pickPath = myPickAction->GetPath();
if ( ( pickPath != null ) && ( ( pickPath.GetTail() ).GetType() == typeof( SoBaseKit ) ))
{
SoTrackballManip tb = new SoTrackballManip();
SoBaseKit kit = ( SoBaseKit )pickPath.GetTail();
// extends the pick path all the way down
// to the transform node
SoPath attachPath = kit.CreatePathToPart( "transform", true, pickPath );
tb.ReplaceNode( attachPath );
}

Java :

Note that using replaceNode() does more work for you than simply calling

C++ :

setPart( "transform", tb ) *

C# :

SetPart( "transform", tb ) *

Java :

setPart( "transform", tb ) *

Field values are copied from the existing “transform” part into the trackball manipulator's fields.

If the pathToExtend parameter is NULL or missing, createPathToPart() simply returns the path from the top of the node kit to the specified part (see Obtaining the Path to a Given Part ):

C++ :

SoPath* littlePath;
littlePath = myKit->createPathToPart( "transform", TRUE );

C# :

SoPath littlePath = new SoPath();
littlePath = myKit.CreatePathToPart( "transform", true );

Java :

Since makeIfNeeded is TRUE, the “transform” part will be created if it does not already exist. However, if makeIfNeeded is FALSE and the part does not exist, createPathToPart returns NULL.

If you want to view the full path, including hidden children, be sure to cast the SoPath to an SoFullPath.

Obtaining the Path to a Given Part

If the pathToExtend parameter is used, createPathToPart() extends the path provided all the way down to the specified part within the node kit (here, the “transform” node). (See Extending a Given Path to the Desired Part .) If the path provided as input (in this case, pickPath) does not include the specified node kit, bigPath equals NULL. If the path given as input extends past the specified node kit, the path will first be truncated at the node kit before extending it to reach the part.

C++ :

bigPath = myKit->createPathToPart( "transform", TRUE, pickPath );

C# :

bigPath = myKit.CreatePathToPart( "transform", true, pickPath );

Java :

To create a path to a child within a list part, use the same indexing notation as you would for setPart() or getPart():

C++ :

pathToListElement = createPathToPart( "callbackList[0]", TRUE );

C# :

pathToListElement = myKit.CreatePathToPart( "callbackList[0]", true );

Java :

Extending a Given Path to the Desired Part