Generating 2d views from cut planes automatically - autodesk-forge

i'm new to the autodesk viewer and the others api and I could use some help figuring out what tools are the best to do what I want.
I'm using the autodesk viewer to let users generate 2d views of cut planes, in order to do this I simply use the getScreenshot function from the viewer and save it as a Blueprint in my app.
What I would like to do now is that when the user updates his 3d model, to automatically update my 2d views with the new 3d model.
Currently the only solution I came up with is to store the position of the camera when taking the screenshot and then when the 3d model is updated, have another computer in the background go in the viewer and take the screenshots again at the same location.
This does not seems to be a very elegant solution so I would like to know if there's an alternative, like a way to generate 2d views from an api call or maybe use the Design Automation API with the viewer to take the screenshots ?
Another thing i'm struggling with is getting precise measure of the 2ds views i'm generating, my current solution is to calculate the distance between the camera and the cut plane and then use the fov to get an approximate measure, the formula looks like this :
Math.tan((viewer.getCamera().fov / 2) * Math.PI / 180) * distanceBetweenCameraAndPlaneCut * 4;
but it is very dependent on the user facing the plane cut at a 90° angle and i'm thinking there should be something better to do with the measure tool.
Thanks a lot for your time!

You should be able to run the Viewer on a server using puppeteer (without client-side components) to generate screenshots: https://forge.autodesk.com/blog/running-forge-viewer-headless-chrome-puppeteer
Note: you could also use Design Automation API in order to do something similar, but then you are limited to the file formats the given product (e.g. AutoCAD) supports as input
You could also simply save the state of the Viewer and reset it next time you load the same model in order to take a screenshot of the exact same area using getState()/restoreState(): https://adndevblog.typepad.com/cloud_and_mobile/2015/02/managing-viewer-states-from-the-api.html
Why are you trying to measure the distance between cut plane and camera position? Is that in order to restore the Viewer state/camera? If so, then the solution mentioned in 2. should help

Related

How to select a complete node in forge viewer?

In 3dsMax I can select a node,The result of selection is in this picture
3ds,But when I convert this model to svf format and select it in the forge viewer, it only selects part of it,like this forge
I don't know why this happens,Can someone tell me why this is? Thanks!
Forge Viewer has a default selection behavior where - when you click on something in the viewport - it will typically try to select the lower most node in the hierarchy. You should still be able to select an arbitrary node in the Model Browser window, or programmatically using viewer.select([nodeId1, nodeId2, ...]).

where is the cut plane for Forge levels extension?

for Forge Autodesk.AEC.LevelsExtension, where is the cut plane? looks like it doesn't follow the view range in Revit?
Appended to what Cyrille mentioned.
Revit's AEC model data will be generated automatically during the Forge translation. The level info is dumping from Revit Level elements, e.g., the name, guid, elevations, extensions of the Revit Level which you can see with Revit API. The Levels extension just uses it to rebuild level ranges.
For example, the cutting range of level 1 will be from level1's elevation to (level2's elevation - a height adjustment) with my research. The height adjustment is to avoid cutting on top of floors to brining a better view. So, it's not following Revit's view range of the floor plan view.
If the levels extension doesn't match your need, you may check out my level section tool. This sample demonstrates the concept of how to create cut planes by levels.
In this extension, floors cut planes are defined based on the bounding box of the floor node in the scene instance tree. Floors are defined in an additional AEC data json file which contains additional information.

Autodesk-Forge configurator live sample with geometry change

I want to build enterprise solution for configurator base on Autodesk Inventor models and drawings. I want to have ability to change dimension of assembly (witdh, depth, length and another). I want to see changes on model in real time (something like here but with changes dimensions in custom values: https://tylko.com/shelf/bookcases/1429438/?cv=0&board=cat_all__type_all__id_4267)
As a result I want to have fully documented model with drawings.
Can Forge do that? Is there any demo?
Yes, here's a sample application that does something similar.
https://forge-rimconfigurator-inventor.herokuapp.com/
You can find the source code of the above application here:
https://github.com/sajith-subramanian/forge-rimconfigurator-inventor
There also is another intricate sample available. You can find it here:
http://inventor-config-demo.autodesk.io/
The source code of the above sample is available here:
https://github.com/Autodesk-Forge/forge-configurator-inventor
Thank you for response. Provided samples are different than:
https://tylko.com/shelf/bookcases/1429438/?cv=0&board=cat_all__type_all__id_4267
My sample is dynamic. Is there a possibility to not wait for change update. Same as you can see change directly in Inventor.

Is it possible to insert multiple blocks into a drawing using the Forge Design Automation API?

As the title says I am looking to use the Design Automation API to upload an archive of blocks, then insert them all into a drawing with a border.
The positioning of the blocks does not matter they just need to be inserted into the drawing ready to be arranged by an engineer.
Any help or advice on end points or limitations would be great thanks.
This is doable. You need to develop a custom activity with 2 inputs and one output. input#1 is the base drawing with boarder and input#2 is a zip file with the blocks. When you submit your workitem you will mark the second input argument as ResourceKind = ResourceKind.ZipPackage this will tell the service that it should unzip the file into the folder designated by LocalFileName. Then your script can enumerate the files in the folder (see vl-directory-files) and issue the INSERT command.

creating and run your own algorithms on localized map

So here is my problem. I plan to implement a localized map for my college presenting all the locations such as main block, Tech park etc. Not only do i plan to develop a GUI but also I also want to run my own algorithms, such as finding the quickest route from one block to another etc (Note: the algorithm is something i will be writing since i don't want to take the shortest route as the quickest but want to add my own parameters as weights). I want to host the map locally (say on a in house system) and should be able to cater real time request (displaying route to the nearest cafeteria) and display current data (such as what event is taking place in what corner of the campus). I know Google Maps API or Openstreetmap/OpenLyers API will enable me to build my own map, but can i run my own algorithms on them? also can I add elements that i have created and replace the traditional building/office components with my own?
You can do the following :
1. Export a part of open street map from their website. (go to the export tab)
2. Use ElementTree in python to parse the exported the xml data.
3. Use networkx to add the parsed data into a graph.
4. Run your algorithms on it.