Enumeration PartInstanceInfoStatusFlag

The PartInstanceInfoStatusFlag enumeration tells some information about the part instances inside the DMU.

The PartInstanceInfoStatusFlag gives added information to a part instance when retrieved by an IdCardGetterInterface or a ChildrenIdCardGetterInterface. It is included in the PartInstanceInfoInterface or ChildrenPartInstanceInfoInterface.

It mainly tells if a part instance contains at least one geometry (PI_Displayable).

The PartInstanceInfoStatusFlag is a flag, which means several information are stored in a number as an OR of the enumeration values.

/** 
* 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

Enumeration Members

PI_Annotated: 256

Tells that this part instance contains at least one annotation.

PI_ConversionGeometryMissing: 2

Tells if at least one geometry was missing when the part instance was built (only for leaves).

PI_ConversionGeometryPartial: 128

Tells that at least one triangle was removed when this part instance was built (only for leaves).

PI_ConversionGeometryPropagated: 4

Tells if at least one leaf of this part instance had the PI_ConversionGeometryMissing flag (only for nodes).

PI_Displayable: 1

Tells if this part instance contains at least one valid geometry and can be displayed in a 3D View.

PI_GeometryInstanceIdAndClassIdMutualizedWithTolerance: 512

Tells that this part instance has a geometry instance id and a class id that was aggregated with another part instance with a tolerance (not a strict xform equality leaves).

Multiple part instances may have the same geometric instance id if they have the same geometric model and at the "same" location.

PI_InstantiationErrorLoopDetectedOrDepthLimitReached: 16

Tells that an instantiation loop (i.e. this part instance is a child, immediate or not of itself) was detected when this part instance was built.

PI_InstantiationErrorPartMissing: 8

Tells that at least one child (immediate or not) part instance (sub-part, leaf or node) was missing when this part instance was built.

PI_InstantiationErrorPropagated: 32

Tells that this part instance contains at least one child (immediate or not) that has the PI_InstantiationErrorPartMissing or PI_InstantiationErrorLoopDetectedOrDepthLimitReached flag.

PI_OutOfLimitAABB: 64

Tells that the given part instance is not totally included in the DMU Axis Aligned Bounding Box (AABB).