Interface ChildrenPartInstanceInfoInterface

The ChildrenPartInstanceInfoInterface interface is used to store properties about the children of a part instance.

The ChildrenPartInstanceInfoInterface is retrieved when using a ChildrenIdCardGetterInterface.retrieveChildrenIdCard.

The interface provides information about

If you query multiple part instances when using ChildrenIdCardGetterInterface.retrieveChildrenIdCard, ChildrenIdCardGetterInterface.getPartInstanceInfos will return an array of ChildrenPartInstanceInfoInterface of the same size.

The following code snippet allows to get the metadata of the children part instances by the ChildrenIdCardGetterInterface. Such a code may be triggered while receiving the IdCardGetterInterfaceSignal.IdCardReady of the ChildrenIdCardGetterInterface.

/** 
* Sample to illustrate the use of an ChildrenIdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
ChildrenIdCardGetterInterface, ChildrenIdCardGetterInterfaceSignal,
InfiniteEvent, ChildrenPartInstanceInfoInterface, DataSessionInterface,
InstanceMetadataInterface, DocumentContentInterface, WorkingSetInterface
} from 'generated_files/documentation/appinfiniteapi';

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

// create an ChildrenIdCardGetter
const lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface = lDataSession.createChildrenIdCardGetter();
// what to do when result is ready ?
lChildrenIdCardGetterInterface.addEventListener(ChildrenIdCardGetterInterfaceSignal.ChildrenIdCardReady, onChildrenIdCardReady);

// onChildrenIdCardReady will be called when data is available
onChildrenIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lChildrenIdCardGetterInterface.getLastError() !== undefined) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<ChildrenPartInstanceInfoInterface> | undefined = lChildrenIdCardGetterInterface.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 lCurrentChildren : ChildrenPartInstanceInfoInterface = lPartInstanceInfos[0];

// iterate over the children metadata infos
const lAllInstanceMetadata : Array<InstanceMetadataInterface> = lCurrentChildren.getChildrenInstanceInfos();

// number of items
const lNbChildren : number = lAllInstanceMetadata.length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
const lLastChildInstanceInfos : InstanceMetadataInterface = lAllInstanceMetadata[lChildInstanceOffset];
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadataDocuments : Array<DocumentContentInterface> = lLastChildInstanceInfos.getPartMetadataDocuments();
if (lPartMetadataDocuments.length === 0)
{
console.log('this part instance has no part metadata documents');
return;
}
// and we only care with the first document, but many documents may be attached
const lPartMetadata : Object = lPartMetadataDocuments[0].getDocumentContent();
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the visibility info in order to get information about the `part instance`
if (lLastChildInstanceInfos.isDisplayable())
{
console.log('the last child of the part instance is displayable');
}
};

// trigger the retrieval
lChildrenIdCardGetterInterface.retrieveChildrenIdCard(lPartInstanceId, lWorkingSet);

or with async calls :
/** 
* Sample to illustrate the asynchronous use of an ChildrenIdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
ChildrenIdCardGetterInterface, AsyncChildrenPartInstanceInfoResult,
ChildrenPartInstanceInfoInterface, AsyncResultReason, DataSessionInterface,
InstanceMetadataInterface, DocumentContentInterface, WorkingSetInterface
} from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lWorkingSet : WorkingSetInterface;
// the `part instance id` to get
let lPartInstanceId : number;

// create an ChildrenIdCardGetter
const lChildrenIdCardGetterInterface : ChildrenIdCardGetterInterface = lDataSession.createChildrenIdCardGetter();

const retrieveIdCard = async () : Promise<void> =>
{
// trigger the retrieval
const lResult : AsyncChildrenPartInstanceInfoResult = await lChildrenIdCardGetterInterface.asyncRetrieveChildrenIdCard(lPartInstanceId, lWorkingSet);

if (lResult.reason !== AsyncResultReason.ARR_Success || lResult.value === undefined)
{
// do nothing in case of error
// perhaps some GUI code ?
return;
}
const lPartInstanceInfos : Array<ChildrenPartInstanceInfoInterface> = lResult.value;
// 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 lCurrentChildren : ChildrenPartInstanceInfoInterface = lPartInstanceInfos[0];

// iterate over the children metadata infos
const lAllInstanceMetadata : Array<InstanceMetadataInterface> = lCurrentChildren.getChildrenInstanceInfos();
// number of items
const lNbChildren : number = lAllInstanceMetadata.length;
if (lNbChildren <= 0)
{
console.log('this part instance is a leaf');
return;
}
// take the last child
const lChildInstanceOffset : number = lNbChildren - 1;
const lLastChildInstanceInfos : InstanceMetadataInterface = lAllInstanceMetadata[lChildInstanceOffset];
// we get the `part` metadata of the last child of the `part instance`
const lPartMetadataDocuments : Array<DocumentContentInterface> = lLastChildInstanceInfos.getPartMetadataDocuments();

if (lPartMetadataDocuments.length === 0)
{
console.log('this part instance has no part metadata documents');
return;
}
// and we only care with the first document, but many documents may be attached
const lPartMetadata : Object = lPartMetadataDocuments[0].getDocumentContent();
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the visibility info in order to get information about the `part instance`
if (lLastChildInstanceInfos.isDisplayable())
{
console.log('the last child of the part instance is displayable');
}
};

retrieveIdCard();

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

interface ChildrenPartInstanceInfoInterface {
    getAABB(): AABB;
    getChildrenInstanceInfos(): InstanceMetadataInterface[];
    getInstanceId(): number;
    getObbDiagonalSquared(): number;
    isDisplayable(): boolean;
    isInstanceLeaf(): boolean;
}

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 AABB

    const
    The Axis Aligned BoundingBox of this part instance.

    See

    AABB

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

    If this part instance is not a leaf, returns -1.

    Returns number

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

  • Tells if this instance is displayable.

    Returns boolean

    true if this instance is displayable, i.e. it is represented by some geometry(ies).

  • Tells if this part instance is a leaf, which means it has no child (in this case, array from getChildrenInstanceInfos is empty).

    Returns boolean

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