The Autodesk Forge Design Automation/Model Derivative API now includes a feature for caching svf files in the Viewer

I am currently utilizing the Design Automation API to generate a model, and my next step is to load the viewable into the viewer using v6. Initially, this process works perfectly fine. However, I encounter an issue where the viewer continuously loads the same .svf file after the first time. I have attempted deleting the manifest, passing true to the x-ads-force parameter, and including the If-Modified-Since header when initializing the viewer.

I am working with the .NET SDK.

DerivativesAPI.Translate(Job, True)

Forge Javascript....


var viewer;

function showModel(AccessToken, urn) {
var options = {
    env: 'AutodeskProduction',
    accessToken: AccessToken,
    api: 'derivativeV2'    
};
var documentId = 'urn:' + urn;
Autodesk.Viewing.endpoint.HTTP_REQUEST_HEADERS['If-Modified-Since'] = 'Sat, 29 Oct 1994 19:43:31 GMT';
Autodesk.Viewing.Initializer(options, function onInitialized() {
    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
}

function onDocumentLoadSuccess(doc) {

// A document contains references to 3D and 2D geometries.
var geometries = doc.getRoot().search({ 'type': 'geometry' });
if (geometries.length === 0) {
    console.error('Document contains no geometries.');
    return;
 }

// Choose any of the available geometries
var initGeom = geometries[0];

// Create Viewer instance
var viewerDiv = document.getElementById('MyViewerDiv');
var config = {
    extensions: initGeom.extensions() || []
};
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv, config);

// Load the chosen geometry
  var svfUrl = doc.getViewablePath(initGeom);
   var modelOptions = {
    sharedPropertyDbPath: doc.getPropertyDbPath()
   };
   viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);

   }


function onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}

function onLoadModelSuccess(model) {
console.log('onLoadModelSuccess()!');
console.log('Validate model loaded: ' + (viewer.model === model));
console.log(model);
}


function onLoadModelError(viewerErrorCode) {
console.error('onLoadModelError() - errorCode:' + viewerErrorCode);
 }

Answer №1

Kindly modify this line to load a different SVF:

// Select any of the available geometries
var initialGeometry = geometries[0];

To Switch during runtime, you can utilize the Autodesk.DocumentBrowser

var configuration = {
    extensions: ['Autodesk.DocumentBrowser'].concat( initialGeometry.extensions() )
};
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv, configuration);

https://i.sstatic.net/R0h6k.jpg

Lastly, please take into consideration the Publish Settings of the RVT model, Model Derivative API will export view sets chosen in the Publish Settings only. If there are no predefined view sets in the Publish Settings, it will default to using the 3D view for export.

Answer №2

I discovered that running in Release mode instead of Debug mode from Visual Studio resolved the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the endless possibilities of JavaScript?

My main goal is to maximize client-side functionality using JavaScript. Specifically, I want to create an interface that displays information to users and processes their responses using JavaScript. I plan to use a web server only for retrieving a data fil ...

Encountering the "v_isRef": true flag while utilizing Vuex within a composition function

I encountered an unexpected outcome when using the loginString() function in my template. It seems that there is a need to include .value in templates, which I thought wasn't necessary. { "_dirty": true, "__v_isRef": true, "__v_isReadonly": true } ...

Utilize the HTML5 video tag with a width set to 70%

I'm looking to create a video element that is 70% of the screen width, while maintaining a height aspect ratio of 100%. Currently, I have a video background that spans the full width. Using Bootstrap v4. <body> <video poster="assets/img/gp ...

Looking to access a .doc file stored on your SD card within your Android application?

I am in need of a solution to view .doc files within an android app. After researching various related posts, I am still unsure of the best approach. Here are the methods I have attempted: Using the Aspose Word API for Android allowed me to create .do ...

Retrieve the start date and end date of the previous week using Javascript

Similar Question: How to fetch the first and last day of the week in JavaScript Is there a way to retrieve the start date and end date of the previous week by providing today's date as input to a function? ...

What is the best way to save the JSON string when encountering a JsonReaderException?

When a JSON string fails to parse in the service layer, a JsonReaderException is thrown to the controller. JObject jData = new JObject(); try { jData = JObject.Parse(response.Content); } catch (JsonReaderException ex) { throw ex; } In the web la ...

What is the reason behind receiving NaN as the outcome of a calculation involving three legitimate numbers?

Why am I getting a NaN error in this code snippet even though all the values are valid numbers? I'm feeling confused and frustrated xD. Can someone help me find my mistake here? private getAllData = (res: any) => { this.setState({ priceBinance ...

Communication breakdown between components in Angular is causing data to not be successfully transmitted

I've been attempting to transfer data between components using the @Input method. Strangely, there are no errors in the console, but the component I'm trying to pass the data from content to header, which is the Header component, isn't displ ...

Building a Many-to-Many Relationship in Node.js Using Sequelize.js

As I utilize the sequelize node.js module to structure schema in Postgres SQL, I have defined two schemas for Project and my users. Project Schema module.exports = function(sequelize, DataTypes) { var project = sequelize.define('project', { ...

Assigning a value to an input field using jQuery

I'm facing an issue while trying to set the value for an input using jQuery. Essentially, when you click on a link, it redirects you to a different page with a form, and I am attempting to set the value of one of the inputs in that form. Unfortunately ...

Retrieving data from a simulated angular service and making calls accordingly

I'm struggling with writing tests for a controller method that relies on an Angular service call and needs to test the code inside the .then() function afterwards. Here's the basic concept: // Controller $scope.myMethod = function() { meth ...

Toggle jQuery slide effect showing all elements and not hiding other list items

I'm utilizing this to display a sub list: function showSublist(element) { $(element).find('ul.joinus_subtext').slideToggle(); } and below is the HTML markup: <ul class="joinus"> <li onclick="showSublis ...

What is the best way to retrieve a selected value from one dropdown list and populate it into another dropdown

Can someone assist me with retrieving the selected answer from one drop-down list and populating it into another drop-down list? Below is my code for programming groups A and B: Example: If a user selects an option from group A and group B, I would li ...

New messages are revealed as the chat box scrolls down

Whenever a user opens the chatbox or types a message, I want the scroll bar to automatically move down to show the most recent messages. I came across a solution that seems like it will do the trick: The issue is that despite implementing the provided cod ...

Ways to send a message from a chrome extension to a webpage and patiently await a reply

Currently, I'm exploring ways to send messages from a Chrome extension to a page view and wait for a response. Here's what I've tried so far: In the extension's content_script.js: window.addEventListener('message', function(e ...

Using PHP to dynamically change the title of a Bootstrap modal

I've been attempting to dynamically update the title of my modal using PHP. The title I wish to display is stored in a variable and is being reassigned based on user input. Below is my PHP code snippet: $studentName = $results['Studentname&apo ...

Issue with setting HTML content using jQuery's .html() method

I have a simple functionality. When a user clicks on the edit link, it transforms the previous element into an input element for editing, and changes the edit link into a cancel link. If the user decides not to edit, they can click on cancel and everything ...

How to change the state using an object as an argument in the useState hook within a function

This code uses a function component: export default function Account() { We define a constant with inputs as objects: const [state, setState] = useState({ profile: true, orders: false, returns: false, coupon: false, referrals: false, rewards: ...

The sluggish loading speed of the page is being caused by both jQuery and an external file containing Amazon

I am facing an issue with my website where it is loading over 1000 images per page from Amazon servers. To enhance the functionality, I have integrated jQuery plugins that are stored locally on the webserver, without using any remote JS or CSS. However, ...

Methods for transforming a TypeScript class instance containing getter/setter properties into a JSON format for storage within a MySQL database

I am currently working on a TypeScript class that includes a getter and setter method: export class KitSection { uid: string; order: number; set layout(layout: KitLayout) { this._layout = new KitLayout(layout); } get layout( ...