0.0.2 • Published 5 years ago

forge-svf-utils v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

forge-svf-utils

build status npm version node npm downloads platforms license

Utilities for working with SVF, the proprietary file format used in Autodesk Forge.

Usage

In Node.js

Read an SVF from local file system:

const { SvfReader } = require('forge-svf-utils');

async function run (filepath) {
    const reader = await SvfReader.FromFileSystem(filepath);
    const svf = await reader.read();
    console.log(svf);
}

run('path/to/your.svf');

Read an SVF from Model Derivative service:

const { ModelDerivativeClient, ManifestHelper } = require('forge-server-utils');
const { SvfReader } = require('forge-svf-utils');

const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;

async function run(urn) {
    const auth = { client_id: FORGE_CLIENT_ID, client_secret: FORGE_CLIENT_SECRET };
    const modelDerivativeClient = new ModelDerivativeClient(auth);
    const helper = new ManifestHelper(await modelDerivativeClient.getManifest(urn));
    const derivatives = helper.search({ type: 'resource', role: 'graphics' });
    for (const derivative of derivatives.filter(d => d.mime === 'application/autodesk-svf')) {
        const reader = await SvfReader.FromDerivativeService(urn, derivative.guid, auth);
        const svf = await reader.read();
        console.log(svf);
    }
}

run('your model urn');