I am using Forge's viewer.setCutPlanes() function to set the cutplanes along with levels, so it will apply the cutplanes horizontally to cut the model level wise. I have two Vector4, as planes, I pass these two planes to the setCutPlanes() function. Now I want to get all elements those are inside the cutplanes, which means, only those elements which are visible in viewer after applying the cutplanes. How can I achieve that?
You could use the Viewer APIs to iterate through the geometry fragments of all objects in your design, get their bounding boxes, and check whether they're between your clipping planes. The process of obtaining the geometry bounds is explained in this blog post: https://forge.autodesk.com/blog/working-2d-and-3d-scenes-and-geometry-forge-viewer.
You can also re-use the 'window selection' example (https://forge.autodesk.com/blog/custom-window-selection-forge-viewer-part-iii) and switch the 8 frustum points to the section plane points.
Related
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.
I am finding a way to pass my coordinates from 2D to 3D model.
I am stuck with an issue where I have Line/Spine which has Start and End Point.
I would like to know how can I get the Start and End point of that line which is been show in my model.
also is there any way to replace that line with my custom line using geometry (i know how to do this in 3D viewer but not sure about 2d view)
I have tried different approaches but seems like nothing is working for me
here is the reference which I was trying to follow
Link
and below is the Line/Path, what I am looking for is geometry of this line or the path of this line so that I can extract vector3 point from where the line is traveling
If you are interested in parsing the contents of a 2D model in Forge Viewer, that is also possible, using a helper class called Autodesk.Viewing.Private.VertexBufferReader. It can iterate through all the "primitives" in a 2D drawing (lines, circular arcs, elliptical arcs, etc.) and call your custom code for each one of them. Here's a blog post that explains the usage of this class: https://forge.autodesk.com/blog/working-2d-and-3d-scenes-and-geometry-forge-viewer.
I work on forge viewer to display Revit converted files. I try to put points into 2D sheets view that I would then display into 3D view. (e.g. in revit red house sample file, from sheet "A-102 plans" to 3D view {3D} ).
Currently, I see only something like:
From 2D view:
Extract coordinates of point from 2D view relatively to item 2d-bouding-box
Convert these relative coordinates into a x,y,z ratio to the size of the item (plus solve from x,y,z, what are the 2 axes we see in 2D)
Into 3D view:
Get 3D bounding box of the item
Compute point position from previous info
Since coordinates are different between the 2 views (which sounds expected), is there a more straightforward way to do this?
Thank you,
I would like to display some reference lines in the viewer that are not shown by default when a drawing is uploaded to Forge.
I know the exact end points of the lines as they were defined in the model, however, it seems that the model in the viewer is translated so that 0,0 is in the center of the bounds.
Is there a way to get the transformation matrix that was applied to the model, so I can align the coordinates of my reference lines with the coordinates of the model in the viewer?
Use viewer.model.getData().globalOffset
I have to visualize a network and I am using igraph.
Each of my vertices has an attribute that groups vertices into clusters. I would like to layout the graph according to the links, but I would also retain the attribute grouping, so that, for instance, vertices with a label "a" does not get mixed with vertices with label "b".
Is there any option other than tkplot() and manually adjust the result, retrieve the coordinates and plot the final result?
Here you can find two solutions: either to set the between-cluster and within-cluster edge weights, and apply a spring force layout; or iterate over clusters, and apply layout.norm() to set each cluster to a specific area of the plot.