Skip to content

Instantly share code, notes, and snippets.

View leefsmp's full-sized avatar

Philippe Leefsma leefsmp

  • Switzerland
  • 10:12 (UTC +02:00)
View GitHub Profile
@leefsmp
leefsmp / Version payload.js
Created July 25, 2016 15:40
Forge DataManagement API payload
[{
type: "versions",
id: "urn:adsk.wipprod:fs.file:vf.m-lA0fEwQJyLND9lLJSYZQ?version=1",
attributes: {
name: "Amine Absorber.dwfx",
displayName: "Amine Absorber.dwfx",
createTime: "2016-06-14T04:20:20+00:00",
createUserId: "200704122227993",
lastModifiedTime: "2016-06-14T04:20:20+00:00",
lastModifiedUserId: "200704122227993",
@leefsmp
leefsmp / particle test.cpp
Created July 29, 2016 17:37
Particle System Test C++ version
#include <stdio.h>
#include "ParticleSystem.h"
#include "ParticleEmitter.h"
#include "MagneticField.h"
#include "Particle.h"
int main() {
// Create new particle system with 10 particles max
@leefsmp
leefsmp / bindings.js
Created July 29, 2016 23:05
WebIDl bindings definition file for Emscripten SDK
interface Vector {
void Vector(double x, double y, double z);
void set(double x, double y, double z);
double getX();
double getY();
double getZ();
@leefsmp
leefsmp / react-forge-viewer.js
Created October 14, 2016 13:08
Illustrates how to use the Forge in a React web application
//////////////////////////////////////////////////////////////////////////
// Copyright (c) Autodesk, Inc. All rights reserved
// Written by Philippe Leefsma 2016 - ADN/Developer Technical Services
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
@leefsmp
leefsmp / viewer-init.js
Created October 21, 2016 08:21
Illustrates how to load document offline/online with Forge Viewer
async onViewerCreated (data) {
try {
const { viewer, initialize, loadDocument } = data
viewer.addEventListener(
Autodesk.Viewing.FULLSCREEN_MODE_EVENT, (e) => {
this.onFullScreenMode(e)
@leefsmp
leefsmp / basic.js
Last active October 30, 2016 17:54
async function getItem (id) {
var response = await fetch('/api/items/' + id)
var item = await response.json()
return item
}
async function taskOnItems (itemIds) {
@leefsmp
leefsmp / ViewingApplication.js
Last active November 2, 2016 03:24
Forge Viewing Application
var options = {
env: 'AutodeskProduction',
getAccessToken: function (onGetAccessToken) {
// Asynchronous request from your app to request
// access token from your server ...
yourAppGetAccessTokenAsync(function (tokenResponse) {
onGetAccessToken (
tokenResponse.access_token,
@leefsmp
leefsmp / InViewerSearch.js
Created October 31, 2016 11:16
Forge Viewer InViewerSearch Extension
var config3d = {
extensions: ["Autodesk.InViewerSearch"],
inViewerSearchConfig = {
uiEnabled: true,
clientId: "adsk.forge.default",
sessionId: "Session-ID-example-F969EB70-242F-11E6-BDF4-0800200C9A66",
loadedModelTab: {
enabled: true, //if false we hide the tab
displayName: 'This View',
pageSize: 50
ddd
@leefsmp
leefsmp / upload.js
Created November 27, 2016 14:55
Forge DataManagement API: new Item or Version creation
/////////////////////////////////////////////////////////////////
// Upload file to create new item or new version
//
/////////////////////////////////////////////////////////////////
upload (token, projectId, folderId, file) {
return new Promise(async(resolve, reject) => {
try {