UNPKG

forge-svf-utils

Version:

Utilities for working with Autodesk Forge SVF file format.

52 lines (38 loc) 1.88 kB
# forge-svf-utils [![build status](https://travis-ci.org/petrbroz/forge-svf-utils.svg?branch=master)](https://travis-ci.org/petrbroz/forge-svf-utils) [![npm version](https://badge.fury.io/js/forge-svf-utils.svg)](https://badge.fury.io/js/forge-svf-utils) ![node](https://img.shields.io/node/v/forge-svf-utils.svg) ![npm downloads](https://img.shields.io/npm/dw/forge-svf-utils.svg) ![platforms](https://img.shields.io/badge/platform-windows%20%7C%20osx%20%7C%20linux-lightgray.svg) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT) Utilities for working with _SVF_, the proprietary file format used in [Autodesk Forge](https://forge.autodesk.com). ## Usage ### In Node.js Read an SVF from local file system: ```js 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: ```js 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'); ```