How to change the geometry of the two selected models? - autodesk-forge

I know getSelection() is get the db id of seletion model.
but after this i don't know how to control this viewer.
There are two windows selected by the viewer.
I want to change the geometry of the two windows.
Forge Viewer is open Revit file by my bucket.
viewer.getSelection()
=>(3) [3043, 3055]//how to?

Unfortunately, the viewer isn't designed to support geometry modification. You can modify your design elements in these ways:
changing their position, orientation, or scale (blog)
hiding them, and potentially inserting your own custom three.js geometry instead (tutorial)
changing their materials, incl. using custom shaders (blog)
But if you actually need to tweak the individual vertices of the mesh geometry, that would be very difficult to do.

Related

Forge Edit2D customize toolset

I'm using the Edit2D extension to draw a Polyline over the 2D model then the path of the polyline is sent to the designautomation API to draw the same polyline in the revit file.
The problem I'm having is that the designautomation is drawing the polyline correctly but the scale is incorrect, it doesn't match with what i'm seeing in the browser. The shape is fine, but the scale is not.
I assume that I need to customize the toolset to set the unithandler to use feet instead of inches. The documentation says to register a custom toolset this way:
edit2d.registerTools(MyToolSetName);
But there is no documentation on how to create the MyToolSetName toolset (i saw it's a complex object doing reverse engineering)
Any clue how can I set the unithandler and register it with the registerTools function?
Or any clue on how to make my 2D view in forge match the same coordinates as revit?
Thanks
Update (October 24th)
I built a sample on that, based on sheetviews translated from Revit files.
Please, refer here for more details.
It takes advantage of this blog.
As of now, it only works for sheetviews with viewports containing views that were also translated (present in the bubble generated).
Since we're drawing in 2D view, we only get X and Y from Viewer. Z components of the curves are defined at workitem by the plane used for drawing.
There's also a video on the sample here
Please refer here for details about using Edit2D Toolset (specifically under 3.2 Units for Areas and Lengths) as it says:
Edit 2D uses the same units and length calibration as the MeasureExtension. You can use MeasureExtension’s calibration panel to specify units and calibration for your Edit2D shapes.
We also have a sample that does a similar flow (without Edit2D) here

Trying to render 2d image inside the forge viewer with 3d model

My current use case is to align a 2d image to a 3d model inside the forge viewer allowing zoom as well as panning functionalities. I have tried the following implementations -
Adding the 2d image as an overlay scene on the forge viewer but the problem there is that I can't position the model on the image precisely even though i have tried translating, rotating and scaling the model programatically.
Loading two different viewers on top of each other and then using viewer.getState() and viewer.restoreState() to sync the state between the two viewers on Autodesk.Viewing.CAMERA_CHANGE_EVENT.
Placing the image inside the HTML beneath the forge viewer and then disabling the pointer events on the viewer and using Javascript to zoom both the viewer and the image in sync. But the problem there is that the measure tool doesn't seem to work right.
What am i missing?
I assume that you simply want to insert a 2D raster image into the viewer scene. That can certainly be done using the 1st approach you suggested. Use an overlay scene or the SceneBuilder extension to add a custom three.js mesh into the scene, and then apply your image as a texture to the mesh.
Regarding the placement of the mesh in the viewer scene, that really depends on your use case and the type of models you're working with. For example, if you wanted to place the image under the 3D model (perhaps the picture contains some satellite imagery), you could find the bounding box of the model using the viewer APIs (viewer.model.getBoundingBox()), and place the three.js object with your image at the bottom side of it.

Exporting markup data in RVT/CAD format

I am using Autodesk Markupscore Extension to draw markups on 2D view. I want to create a separate rvt or CAD file for the drawn markup, which can further be used/opened in Revit soft. So the newly created 2D view(rvt/CAD) will contain only that part of 2D view which is inside the drawn markup, How can I achieve this?
I can't comment on the Revit specific piece (for that I would suggest that you check out the Revit discussion forums) but if we're talking about where Forge can help, I see two options:
you could have a Revit plugin running in the Forge Design Automation service, accepting a Revit document and some coordinates of 2D markups on the input, removing design elements that are outside of the 2D markups via Revit APIs, and generating a new Revit document on the output.
you could customize Forge Viewer to hide or occlude the parts of the 2D drawings you don't want to be visible, for example, by "hiding" them (making them semi-transparent), by changing their color, or by overlaying them with another content such as a blank SVG rectangle.

Viewing Multiple .DWG files in viewer using Forge API

I need to see multiple .DWG in the Forge viewer in 3D format. There are some buttons on the viewer screen using which we can toggle between 2D and 3D views. On using those toggle buttons, currently we are able to see only one file at a time in the 3D view. Is there any option to view multiple files in 3D format?
You can use three ways to see multiple views of the same model.
Split the screen into multiple screens (SplitScreenExtension): https://forge.autodesk.com/en/docs/viewer/v7/reference/Extensions/SplitScreenExtension/
Place a view inside a div: https://github.com/Autodesk-Forge/viewer-navigation.sample/blob/master/www/scripts/model.js
Creating a div that renders a view within a DockingPanel.
I may have already answered this in your other Stackoverflow question, but, it is the same answer here. Try loading multiple models into a scene, using this blog post as your guide:
https://forge.autodesk.com/blog/loading-multiple-models-forge-viewer-v7
One neat trick with Forge Viewer, is the ability to load a 2D sheet inside the 3D world. The 2D sheet, if it comes from DWG, it will be vector lines, and if it's an old PDF, it will be image tiles.
Here's a video of combining 2D sheets into a 3D scene, into something more useful to your user...

Using Autodesk Forge, How do I get dimension objects and their properties from a Revit Plan view?

In Revit, I have dimensions on floor plans and elevations. I need to get at those dimensions and their properties to see if the user had overridden the value. Is this possible using Forge? I've only been able to get the objects and properties for items in the 3D view, not any plans, elevations, etc.
It's a known wishlist item (CF-4851) in our internal case system.
Unfortunately, 2D elements such as dimensions, texts, notes, grids, and sections in plan views and elevation views are not supported by Forge MD currently. Consequently, there are no concrete elements, they aren't clickable and no object properties in the Forge Viewer as I know.