Interface Export3DOutputFormatInterface

The Export3DOutputFormatInterface interface defines the output format of a 3D export procedure called by DataSessionInterface.export3D.

  • filename may be used to trigger a download from the browser and set the destination filename, without any extension.
  • dataFormat specifies the format of the tessellated data.
  • If productStructureFormat is specified, then the export procedure will output the product structure in the given format, and the leaves (that contain tessellated data) will still be outputted in dataFormat format. If productStructureFormat is not specified then the export 3D procedure will consist in a single file that contain the product structure and the 3d data in dataFormat format.
  • If bomFormat is specified, then the metadata of the exported nodes will also be outputted in the given format.
  • If metadataFields and bomFormat are specified, only metadata fields of the specified name will be exported (no nested values separated by ., only top metadata fields can be specified).
  • If removeDeadBranches is specified and true, then branches that have no geometries will be stripped from the exported data.
  • If simplification is specified, the tessellated data will also be compressed : If simplification is in the ]0, 1[ range, then the given simplification ratio will be set. If simplification is strictly superior to 1, then simplification represents a number of triangles.

You may then customize the name of the 3d nodes / bom id with the following algorithms:

  • If nodeNaming is not specified, then the naming is inferred from the document names attached to an instance.
  • If nodeNaming is specified and mode is metadatafields, then the list of provided field names is matched in order against each metadata field attached to an instance. If a field with the given name is found, then the node is named with the found value.
  • If nodeNaming is specified and mode is uniqueinstanceids, then a unique id is generated for each node.
/** 
* Sample to illustrate the use of a 3d export procedure.
*/
import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, ExportJobInterfaceSignal, InfiniteError, InfiniteEvent, Export3DOutputFormat } from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession: DataSessionInterface;
// the working set to export as 3d data
let lWorkingSetToExport : WorkingSetInterface;
// the export job to monitor
let lExportJob : ExportJobInterface | undefined = undefined;
// the file to download
// In this test, we will only download one file
let lFileOffset : number = -1;

// triggers a save file from the browser
const onDownloadReady = (pUrl : string) : void => {
const downloadLink = document.createElement('a');
downloadLink.target = '_blank';
// set object URL as the anchors href
downloadLink.href = pUrl;
// append the anchor to document body
document.body.appendChild(downloadLink);
// fire a click event on the anchor
downloadLink.click();
// cleanup: remove element and revoke object URL
downloadLink.remove();
};

const startExportProcedure = () : boolean =>
{
// will will try to export as fbx
lExportJob = lDataSession.export3D(
[{ workingSet: lWorkingSetToExport }],
{
type: 'export3DOutputFormat',
dataFormat: Export3DOutputFormat.EOF_FBX,
// filename without extension
filename: 'test'
}
);
// sanity check
if(lExportJob === undefined)
{
return false;
}
lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobFinished, (pEvent : InfiniteEvent) : void =>
{
// only get the URL if no error
const lError : InfiniteError | undefined = lExportJob.getLastError();
if(lError === undefined && (lFileOffset === -1))
{
lFileOffset = pEvent.attachments;
if(lExportJob.isExportSuccess(lFileOffset))
{
// trigger the URL computing
if(!lExportJob.computeDownloadURL(lFileOffset))
{
console.log('Export job failed');
}
}
}
});
// URL will be ready
lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobURLReady, () : void =>
{
const lUrl : string | undefined = lExportJob.getDownloadURL(lFileOffset);
// sanity check
if(lUrl === undefined)
{
console.log('Export job failed');
return;
}
// trigger the download from the browser
onDownloadReady(lUrl);
});
return true;
};

startExportProcedure();

or asynchronously :
/** 
* Sample to illustrate the asynchronous use of a 3d export procedure.
*/
import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, AsyncResultReason, Export3DOutputFormat } from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession: DataSessionInterface;
// the working set to export as 3d data
let lWorkingSetToExport : WorkingSetInterface;
// the export job to monitor
let lExportJob : ExportJobInterface | undefined = undefined;

// triggers a save file from the browser
const onDownloadReady = (pUrl : string) : void => {
const downloadLink = document.createElement('a');
downloadLink.target = '_blank';
// set object URL as the anchors href
downloadLink.href = pUrl;
// append the anchor to document body
document.body.appendChild(downloadLink);
// fire a click event on the anchor
downloadLink.click();
// cleanup: remove element and revoke object URL
downloadLink.remove();
};

const startExportProcedure = async () : Promise<boolean> =>
{
// will will try to export as fbx
lExportJob = lDataSession.export3D(
[{ workingSet: lWorkingSetToExport }],
{
type: 'export3DOutputFormat',
dataFormat: Export3DOutputFormat.EOF_FBX,
// filename without extension
filename: 'test'
}
);
// sanity check
if(lExportJob === undefined)
{
return false;
}
// wait for file count to be known
const lWaitForFileCount : AsyncResultReason = await lExportJob.asyncWaitForFileCount();
if(lWaitForFileCount !== AsyncResultReason.ARR_Success)
{
return false;
}
const lNbFiles: number = lExportJob.getFileCount();
console.log('The export procedure consists in ' + lNbFiles + ' files');
if(lNbFiles < 1)
{
// not enough files ?
// => should not happen
return false;
}
// wait for everything to be computed
// we could have waited for a specific file with an asyncWaitForFinished(item)
const lExportResult : AsyncResultReason = await lExportJob.asyncWaitForFinished();
if(lExportResult !== AsyncResultReason.ARR_Success)
{
return false;
}
// file is ready
// claim for a download url for file 0
console.log('retrieving file ' + lExportJob.getFilename(0));
await lExportJob.asyncGetDownloadURL(0);
const lUrl : string | undefined = lExportJob.getDownloadURL(0);
if(lUrl === undefined)
{
return false;
}
// trigger a download of the file
onDownloadReady(lUrl);
return true;
};

startExportProcedure();

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

interface Export3DOutputFormatInterface {
    bomFormat?: ExportBOMOutputFormat;
    dataFormat?: Export3DOutputFormat;
    filename: string;
    metadataFields?: string[];
    nodeNaming?: {
        fields: string[];
        mode: "metadatafields";
    } | {
        mode: "uniqueinstanceids";
    };
    productStructureFormat?: ProductStructureOutputFormat;
    removeDeadBranches?: boolean;
    simplification?: number;
    type: "export3DOutputFormat";
}

Properties

If specified, then the metadata of the exported nodes will also be outputted in the given format.

The format of the tessellated data.

filename: string

The destination filename set when the 3D export procedure is done and downloaded from the browser. You should not include any extension in filename.

metadataFields?: string[]

A list of metadata fields to export, if relevant. If this is not specified, exports all the metadata.

nodeNaming?: {
    fields: string[];
    mode: "metadatafields";
} | {
    mode: "uniqueinstanceids";
}

Specifies how nodes in the product structure or the BOM export will be named. The field mode is an enum specifying how nodes will be named:

  • metadatafields: Lets you specify a list of metadata fields. Each node will be named after the value of the first specified field if present in its metadata, otherwise the second and so on. If none of the fields are found, defaults to an id created as if nodeNaming was not set.
  • uniqueinstanceids: Nodes are given a unique name. This is the only suitable option when you wish to re-establish a link between different exports.

Type declaration

  • fields: string[]

    The list of metadata field to query to set the name of the node.

  • mode: "metadatafields"

    The mode for setting node names : names are set depending on the content of its metadata.

Type declaration

  • mode: "uniqueinstanceids"

    The mode for setting node names : 'uniqueinstanceids' means each node will be set with a unique node name.

productStructureFormat?: ProductStructureOutputFormat

The product structure format if specified, and the leaves (that contain tessellated data) will still be outputted in dataFormat format. If not specified, then the export 3D procedure will consist in a single file that contain the product structure and the 3d data in dataFormat format.

removeDeadBranches?: boolean

If enabled, branches of the product structure without geometries will be pruned.

simplification?: number

If specified, the tessellated data will be compressed :

  • If in the ]0, 1[ range, then the given simplification ratio will be set.
  • If strictly superior to 1, then a number of triangles.
type: "export3DOutputFormat"

The type of the export procedure, here 3D.