Interface PartInstanceInfoInterface

The PartInstanceInfoInterface interface is used to store properties about a part instance and its genealogy.

The PartInstanceInfoInterface is retrieved when using a retrieveIdCard i.e. when the metadata attached to a part instance are retrieved.

The interface provides information about

The following code snippet allows to get the metadata of a part instance by the IdCardGetterInterface. Such a code may be triggered while receiving the IdCardReady of the IdCardGetterInterface.

WARNING : there is a unique instantiation chain from the root to a part instance, as such, if you query multiple part instances when using retrieveIdCard, getPartInstanceInfos will return an array of PartInstanceInfoInterface of the same size.

/** 
* Sample to illustrate the use of an IdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
VisibilityContextInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal,
InfiniteEvent, PartInstanceInfoInterface, PartInstanceInfoStatusFlag, DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lVisibilityContext : VisibilityContextInterface;
// the `part instance id` to get
let lPartInstanceId : number;
// what to do when we have retrieved id card information ?
let onIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// create an idCardGetter
const lIdCardGetterInterface : IdCardGetterInterface = lDataSession.createIdCardGetter();
// what to do when result is ready ?
lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady);

// onIdCardReady will be called when data is available
onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lIdCardGetterInterface.getLastError().length !== 0) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbAncestors : number = lCurrentChain.getAncestors().length;
const lOffsetToPartInstance : number = lNbAncestors - 1;
// we get the `part` metadata of the given `part instance` (and not their parents - grand parents) => lNbAncestors-1
const lPartMetadata : Object = lCurrentChain.getIdCardHierarchy().partmd[lOffsetToPartInstance];
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the flags in order to get information about the `part instance`
const lFlags : number = lCurrentChain.getAncestorsStatusFlags()[lOffsetToPartInstance];
if ((lFlags & PartInstanceInfoStatusFlag.PI_Displayable) !== 0)
{
console.log('this part instance is displayable')
}
}

// trigger the retrieval
lIdCardGetterInterface.retrieveIdCard(lPartInstanceId, lVisibilityContext);

or with async calls :
/** 
* Sample to illustrate the asynchronous use of an IdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
VisibilityContextInterface, IdCardGetterInterface, AsyncPartInstanceInfoResult,
AsyncResultReason, PartInstanceInfoInterface, PartInstanceInfoStatusFlag, DataSessionInterface
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lVisibilityContext : VisibilityContextInterface;
// the `part instance id` to get
let lPartInstanceId : number;
// what to do when we have retrieved id card information ?

// create an idCardGetter
const lIdCardGetterInterface : IdCardGetterInterface = lDataSession.createIdCardGetter();

const fetchIdCard = async () : Promise<any> =>
{
// trigger the retrieval
const lResult : AsyncPartInstanceInfoResult = await lIdCardGetterInterface.asyncRetrieveIdCard(lPartInstanceId, lVisibilityContext);
if (lResult.reason !== AsyncResultReason.ARR_Success) {
// do nothing in case of error
// perhaps some GUI code ?
}

const lPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos();
console.assert(lPartInstanceInfos === lResult.value);
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbAncestors : number = lCurrentChain.getAncestors().length;
const lOffsetToPartInstance : number = lNbAncestors - 1;
// we get the `part` metadata of the given `part instance` (and not their parents - grand parents) => lNbAncestors-1
const lPartMetadata : Object = lCurrentChain.getIdCardHierarchy().partmd[lOffsetToPartInstance];
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the flags in order to get information about the `part instance`
const lFlags : number = lCurrentChain.getAncestorsStatusFlags()[lOffsetToPartInstance];
if ((lFlags & PartInstanceInfoStatusFlag.PI_Displayable) !== 0)
{
console.log('this part instance is displayable')
}
}

fetchIdCard();

Please make sure the destination browser supports promises before using async calls.
Data Retrievers

See

Hierarchy

  • PartInstanceInfoInterface

Methods

  • Gets the Axis Aligned Bounding Box of the part instance this object refers to.

    DO NOT modify in place this object, this results in undefined behavior.

    Returns

    const
    The Axis Aligned BoundingBox of this part instance.

    See

    AABB

    Returns AABB

  • Gets the part instance ids from the root to this part instance /root/.../grandparent/parent/instance.

    DO NOT modify in place this array, this results in undefined behavior.

    Returns

    const
    The array of part instance ids from the root to this part instance.

    Returns number[]

  • Gets the part instance class ids from the root to this part instance /root/.../grandparent/parent/instance.

    DO NOT modify in place this array, this results in undefined behavior.

    Returns

    const
    The array of part instance class ids from the root to this part instance.

    Returns number[]

  • Gets the status flags from the root to this part instance : /root/.../grandparent/parent/instance.

    The status flags are the OR of PartInstanceInfoStatusFlag.

    DO NOT modify in place this array, this results in undefined behavior.

    Returns

    const
    The array of status flags from the root to this part instance.

    See

    PartInstanceInfoStatusFlag

    Returns number[]

  • Gets the list of the annotation views properties from the root to this part instance : /root/.../grandparent/parent/instance.

    This gets an array of array of AnnotationViewInfoInterface.

    DO NOT modify in place this array, this results in undefined behavior.

    Returns

    const
    The list of annotation views properties from the root to this part instance.

    See

    AnnotationViewInfoInterface

    Returns AnnotationViewInfoInterface[][]

  • Gets the list of the attached documents from the root to this part instance : /root/.../grandparent/parent/instance.

    This gets an array of array of AttachedDocumentInfoInterface.

    DO NOT modify in place this array, this results in undefined behavior.

    Returns

    const
    The list of attached documents properties from the root to this part instance.

    See

    AttachedDocumentInfoInterface

    Returns AttachedDocumentInfoInterface[][]

  • Gets the id of the part instance that was queried by retrieveIdCard.

    Returns

    The part instance id this object refers to.

    See

    retrieveIdCard

    Returns number

  • Gets the square of the diagonal of the Oriented Bounding Box of this part instance.

    Returns

    The square of the diagonal of the Oriented Bounding Box of this part instance.

    Returns number

  • Gets the maximum part instance id of the leaves that represent the node/leaf part instance for the full hierarchy.

    DO NOT modify in place this array, this results in undefined behavior.

    The given part instance at depth i is therefore represented by the leaves part instances :

    getSubLeafMinimums()[i], getSubLeafMinimums()[i] + 1, getSubLeafMinimums()[i] + 2, ..., getSubLeafMaximums()[i].

    Returns

    const
    The maximum part instance leaf of the full hierarchy.

    Returns number[]

  • Gets the minimum part instance id of the leaves that represent the node/leaf part instance for the full hierarchy.

    DO NOT modify in place this array, this results in undefined behavior.

    The given part instance at depth i is therefore represented by the leaves part instances :

    getSubLeafMinimums()[i], getSubLeafMinimums()[i] + 1, getSubLeafMinimums()[i] + 2, ..., getSubLeafMaximums()[i].

    Returns

    const
    The minimum part instance leaf of the full hierarchy.

    Returns number[]

  • Gets the world transformations from the root to this part instance : /root/.../grandparent/parent/instance.

    The Matrix4 follows the column multiplication convention (see Matrix4).

    DO NOT modify in place this array, this results in undefined behavior.

    Returns

    const
    The list of Matrix4 from the root to this part instance.

    See

    Matrix4

    Returns Matrix4[]

  • Tells if this part instance is a leaf, which means it has no child.

    Returns

    true if the part instance this object refers to is a leaf.

    Returns boolean