The AnnotationGroupInfoInterface interface is used to store the annotations properties linked to a part instance.
Please see Annotations for more explanations about annotations.
The AnnotationGroupInfoInterface is retrieved when using a InstanceMetadataInterface.getAnnotationGroups i.e. when the metadata
attached to a part instance are retrieved from an id card request.
The actual data will be retrieved by using an AnnotationGetterInterface since the AnnotationGroupInfoInterface only stores
general properties of an annotation view, but not the annotation views internal data.
/** * Sample to illustrate the use of an AnnotationGetterInterface to retrieve multiple annotation views. */ import { DataSessionInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal, AnnotationGetterInterfaceSignal, InfiniteEvent, PartInstanceInfoInterface, AnnotationGroupInfoInterface, AnnotationGetterInterface, AnnotationResultInterface, AncestryInstanceMetadataInterface, WorkingSetInterface, } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession : DataSessionInterface; // created previously letlIdCardGetterInterface : IdCardGetterInterface; // created previously, the working set to use for the id card query letlWorkingSet : WorkingSetInterface; // the part instance id to fetch letlPartInstanceId : number;
// to retrieve the annotations constlAnnotationViewGetter : AnnotationGetterInterface = lDataSession.createAnnotationGetter();
// what to do when we have retrieved id card information ? letonIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) =>void;
// what to do when annotation data has been downloaded ? letonAnnotationViewDownloaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) =>void;
// what to do when id card is ready ? lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady); // what to do when the download of the annotation view is ready ? lAnnotationViewGetter.addEventListener(AnnotationGetterInterfaceSignal.AnnotationFetchReady, onAnnotationViewDownloaded);
// onIdCardReady will be called when id-card data is available onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void=> { if (lIdCardGetterInterface.getLastError() !== undefined) { // do nothing in case of error // perhaps some GUI code ? } constlPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos(); if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1) { // no data (isCancelled ?) return; } // get the first the instantiation chain constlCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0]; // the annotation views that will be fetched constlAnnotationsToFetch : Array<AnnotationGroupInfoInterface> = []; // iterate over the metadata infos to retrieve all views at once constlAllInstanceMetadata : Array<AncestryInstanceMetadataInterface> = lCurrentChain.getAncestorInstanceInfos(); // loops leti : number; letj : number; // number of annotation views for this instance letlNbAnnotationViews : number; // number of ancestors constlNbAncestors : number = lAllInstanceMetadata.length; letlAnnotationViewsOfPartInstance :Array<AnnotationGroupInfoInterface>; letlCurAnnotationView : AnnotationGroupInfoInterface; for (i = 0; i < lNbAncestors; i += 1) { lAnnotationViewsOfPartInstance = lAllInstanceMetadata[i].getAnnotationGroups(); lNbAnnotationViews = lAnnotationViewsOfPartInstance.length; for (j = 0; j < lNbAnnotationViews; j += 1) { lCurAnnotationView = lAnnotationViewsOfPartInstance[j]; // some fancy log console.log('Will fetch annotation view ' + lCurAnnotationView.getGroupName() + ' of type ' + lCurAnnotationView.getGroupTypeName() + ' with ' + lCurAnnotationView.getAnnotationsCount() + ' annotations'); // add the annotation view to be fetched lAnnotationsToFetch.push(lCurAnnotationView); } } // and download lAnnotationViewGetter.fetchAnnotationGroups(lAnnotationsToFetch); };
// what to do when annotation data has been downloaded ? onAnnotationViewDownloaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void=> { // annotation are ready constlAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationGroupsResult(); if ((!lAnnotationViewsContent) || (lAnnotationViewsContent.length === 0)) { console.log('error while fetching annotation content'); return; } // now annotation content is there, just need to display them // use only the first view constlCurAnnotationViewResult : AnnotationResultInterface = lAnnotationViewsContent[0]; console.log('display annotation view ' + lCurAnnotationViewResult.getGroupName() + ' (of type ' + lCurAnnotationViewResult.getGroupTypeName() + ')'); };
/** * Sample to illustrate the asynchronous use of an AnnotationGetterInterface to retrieve multiple annotation views. */ import { DataSessionInterface, IdCardGetterInterface, AsyncResultReason, AsyncPartInstanceInfoResult, PartInstanceInfoInterface, AnnotationGroupInfoInterface, AnnotationGetterInterface, AnnotationResultInterface, AsyncAnnotationResult, AncestryInstanceMetadataInterface, WorkingSetInterface } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession : DataSessionInterface; // created previously letlIdCardGetterInterface : IdCardGetterInterface; // created previously, the working set to use for the id card query letlWorkingSet : WorkingSetInterface; // the part instance id to fetch letlPartInstanceId : number;
// to retrieve the annotations constlAnnotationViewGetter : AnnotationGetterInterface = lDataSession.createAnnotationGetter();
// get the first the instantiation chain constlCurrentChain : PartInstanceInfoInterface = lIdCardRes.value[0]; // the annotation views that will be fetched constlAnnotationsToFetch : Array<AnnotationGroupInfoInterface> = []; // iterate over the metadata infos to retrieve all views at once constlAllInstanceMetadata : Array<AncestryInstanceMetadataInterface> = lCurrentChain.getAncestorInstanceInfos(); // loops leti : number; letj : number; // number of annotation views for this instance letlNbAnnotationViews : number; // number of ancestors constlNbAncestors : number = lAllInstanceMetadata.length; letlAnnotationViewsOfPartInstance :Array<AnnotationGroupInfoInterface>; letlCurAnnotationView : AnnotationGroupInfoInterface; for (i = 0; i < lNbAncestors; i += 1) { lAnnotationViewsOfPartInstance = lAllInstanceMetadata[i].getAnnotationGroups(); lNbAnnotationViews = lAnnotationViewsOfPartInstance.length; for (j = 0; j < lNbAnnotationViews; j += 1) { lCurAnnotationView = lAnnotationViewsOfPartInstance[j]; // some fancy log console.log('Will fetch annotation view ' + lCurAnnotationView.getGroupName() + ' of type ' + lCurAnnotationView.getGroupTypeName() + ' with ' + lCurAnnotationView.getAnnotationsCount() + ' annotations'); // add the annotation view to be fetched lAnnotationsToFetch.push(lCurAnnotationView); } } // and download constlAnnotationContentResult : AsyncAnnotationResult = awaitlAnnotationViewGetter.asyncFetchAnnotationGroups(lAnnotationsToFetch); // annotation are ready // const lAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationGroupsResult(); if ((!lAnnotationContentResult.value) || (lAnnotationContentResult.value.length === 0)) { console.log('error while fetching annotation content'); return; } // now annotation content is there, just need to display them // use only the first view constlCurAnnotationViewResult : AnnotationResultInterface = lAnnotationContentResult.value[0]; console.log('display annotation view ' + lCurAnnotationViewResult.getGroupName() + ' (of type ' + lCurAnnotationViewResult.getGroupTypeName() + ')'); };
fetchAnnotation();
Please make sure the destination browser supports promises before using async calls.
The AnnotationGroupInfoInterface interface is used to store the annotations properties linked to a
part instance.Please see Annotations for more explanations about annotations.
The AnnotationGroupInfoInterface is retrieved when using a InstanceMetadataInterface.getAnnotationGroups i.e. when the metadata attached to a
part instanceare retrieved from an id card request.The actual data will be retrieved by using an AnnotationGetterInterface since the AnnotationGroupInfoInterface only stores general properties of an annotation view, but not the annotation views internal data.
or with async calls :
Please make sure the destination browser supports promises before using async calls.
See