Forge is normalising obj file's coordinates - autodesk-forge

I am using forge to view obj file, but it is normalising the obj file's coordinates w.r.t centre of the screen. Due to which at a later point in time when I am rendering the custom THREE.js objects at original coordinate they are very very far apart from the model.
I am seeking one of the two solutions
Either I get a forge api to transform the custom object's coordinates the same way forge did for initial model, or
Forge displays the model in the correct position without normalising the coordinates but focuses camera to the model on initial load of the screen.

Forge typically moves 3D designs to the origin (to avoid floating point precision issues) but it stores the original offset in the globalOffset property in the model metadata. You could either:
Take the globalOffset value into account when inserting the custom three.js objects, or
Load the model with globalOffset set to an empty vector (new THREE.Vector3(0.0, 0.0, 0.0)), as explained in https://forge.autodesk.com/blog/multi-model-refresher.

Related

different geometry in SVF and SVF2

We have an IFC file that is converted in SVF and SVF2.
We noticed that the same beam has different geometry in both formats (see picture
The SVF2 geometry is wrong (the beam is rotated or mirrored).
I will send the IFC to forge (dot) help (at) autodesk (dot) com
SVF2 barely reduces the number of geometry instances for this model:
SVF: 18015 geometries
SVF2: 17037 geometries
Since SVF2 loads every geometry individually via a websocket, it takes much longer if the number of instances isn't much smaller compared to SVF.
Add an extra querying string disableWebSocket=true to your website URL e.g. http://localhost:8000?disableWebSocket=true

How import model from forge scene to map(Google, arcGis etc)?

I use forge API in my application. I added an arcGis map to display the model using the methods from the post https://forge.autodesk.com/blog/dump-geometries-2d-curve in GEOMETRY_LOADED_EVENT.
When I work with small models, the data is displayed on the ArcGis map well, but info about layers are lost.
When the models are large, I get a very large data object(100mb + ) and my program does not work. Is it possible to save the model in threejs-friendly formats or to get a more compact object with model and layers data? Or are there still ways to display the model on the map? I would be very grateful for the advice.
I tried methods from the post https://forge.autodesk.com/blog/dump-geometries-2d-curve in GEOMETRY_LOADED_EVENT.
Not sure if this fits your use case, but I've been working on a tool for converting Forge models into glTF format (which is pretty three.js-friendly I'd say): https://github.com/petrbroz/forge-extract.

Is it possible to load only one specific object from the model(document) when initializing the document in the Forge viewer?

We would like to know if it possible to initialize the viewer to only render an specific object id.
There is a tutorial to extract geometry from a model, but it involves using the derivative to convert geometry to OBJ.
https://forge.autodesk.com/en/docs/model-derivative/v2/tutorials/extract-geometry-from-source-file/
The idea is to create a catalog of objects based on the elements in a model (document). We usually work with Revit files.
Viewer works with dbIds (or nodeIds which are equivalent to objectIds) and may load bubbles (geometry constructs) selectively based on - see live sample here
viewer.loadModel(svfUrl,{ids:[dbIds...]})

Not able to completely hide model in forge viewer

I am trying to hide the complete model in forge-viewer, for that I am calling forge visibility API as follows:
viewer.impl.visibilityManager.setNodeOff(viewer.model.getModelId(),true)
where viewer is a object of GUIViewer3D.
But this is not hidding the complete model, some components in the model are still visible.
I think it is a bug in forge-viewer because if I pass a root node of model to setNodeOff() API it has to hide whole model. I am sure that there is only one model loaded in my viewer session.
Refer this image for the elements which are still visible after calling viewer.impl.visibilityManager.setNodeOff(viewer.model.getModelId(),true)
getModelId() returns model IDs, and the visibility APIs expect node IDs. In order to hide the entire model, consider the following:
viewer.hide(model.getRootId());
Could you try something for me...
Could you try adding the header 'x-ads-force':'true' to the POST job request when you are converting the .RVT file?
Here is the documentation on the API request...
https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/job-POST/#headers
Then, retrieve the URN and feed it to the Forge Viewer, as before, like this example:
https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-manifest-GET/#example
.
So... What's going on?
When you convert a RVT to a SVF (for the the Forge Viewer), it produces a random set of DBIds.
When you call the GetProperties API, it uses that cached SVF to pull the DBIds and provide you with a result.
Back in August, the GetProperty API engine, was updated. It produces a different order of DBIds compared to the old converted SVF.
Since the old SVF is cached, even if you submit a new job, it will use the old SVF.
To avoid the old SVF, we need to 'force convert' the RVT to SVF conversion, to flush that cache, so that the new SVF is visible and the Forge Viewer can retrieve it.
Once the Forge Viewer can see the new SVF, it should match the DBIds of the GetProperties API.
Complicated huh?
Let me know if that fixes the problem.
As my goal is to completely hide model from viewer, I achieved this by following:
viewer.clearSelection();
viewer.model.setAllVisibility(0);
viewer.impl.toggleGhosting(false);
viewer.impl.toggleGroundShadow(false);
This gives me the required behavior. The elements which I was not able to hide are now hidden through this approach.
to completely hide the model you can isolate an empty list, which will show the whole model ghosted, then you can turn off ghosting globally
viewer.isolate([]);
viewer.setGhosting(false);

Values for volume, area and length in Autodesk Forge Model Derivative API

I'm using Forge to extract data from Revit models (transformed to .nwc). I call
GET /modelderivative/v2/designdata/{urn}/metadata/{guid}/properties
to get all properties of my model. The problem is that for some reason values for volume, area and length for all Revit objects are now in the format "0.009 ft^3", while before they all were just numbers. What can be the reason for this? Is this an API change or the model is saved with some special parameters, etc.?
Yes, this is a change because previously you could not tell the unit of any of the values. Now it's showing the values as you find them in the Viewer as well.