Is there a way to match coordinates from 2D sheets to 3D view for an item? - autodesk-forge

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,

Related

How do I convert between 2D paper space coordinates world 3D coordinates for AEC models in a forge viewer?

I'm following a blog post by Petr Broz with my published views from a Revit project in BIM 360, but I was wondering how I would convert between 2D coordinates and 3D world coordinates if my published 2D view is actually just a stand-alone floor plan view without being placed on any sheet.
I was trying to get the viewport but I realized the published view doesn't have any viewport in the model. So I cannot actually use those functions in the extension for viewports. Any advise would be greatly appreciated.
Unfortunately, it doesn't support floor plan view without placing the sheet, since there is some required information missing at this moment. We are still discussing this with our engineering team.
The current working path is creating a Revit Sheet view and placing the floor plan inside, see https://www.youtube.com/watch?v=smMap86YZUY
My mistake was manually trying to convert x,y,z coordinates by dividing them with the viewport scale, thus they couldn't align with 3D world coordinates.
By providing the correct model unitscale, I could get the transform with get3DTo2DMatrix().
viewport = viewportExt.getViewports(viewer.model)[0];
viewportXform viewport.get3DTo2DMatrix(viewer.model.getUnitScale());
// From foot to millimeters
x = x* 0.00328084;
y = y* 0.00328084;
z = z* 0.00328084;
var worldPt = new THREE.Vector3(x,y,z);
worldPt.applyMatrix4(viewportXform);

How to find out the location of x,y,z from every corner of the building?

Is there a method from Autodesk Forge to find out the location of each point from the corner of the building like the picture I attached?
In the context of Forge Model Derivative & Viewer, the geometries have been translated to mesh (triangles). It does not contain the information of face/edge, which means it does not tell which is corner of the shape. you may have to calculate which is the furthest vertex. This is a blog about how to get vertex
https://forge.autodesk.com/blog/show-mesh-triangles-data-hittest

Forge Viewer: How to Link Spaces to 2D Sheets

I have a Revit file with spaces information in a 2D view. However, when I access that view through Forge, the spaces information is gone. Looking deeper, I find the spaces are in the 3D "New Construction" view (generated by BIM 360). How can I use the spaces information with the 2D view? I would like to be able to select a space and go to its corresponding location on the 2D view.
Switching from 3D to 2D or vice versa is demonstrated in this example:
https://github.com/Autodesk-Forge/forge-extensions/blob/master/public/extensions/NestedViewerExtension/README.md

Is there any way in forge, to drop pins and draw boundaries in the pdf

i need to drop pins to a 2d drawing in the forge viewer and also divide 2d drawing in different zones/area. is it possible to do that with forge viewer?
Adding to Petr's suggestion. Take a look at this blog post, on how to add markup (so you can drop a pin).
https://forge.autodesk.com/blog/viewing-large-ocrterrain-images-forge-viewer
To divide the 2d drawing into different zones, do you mean split screen ? A bit like this split screen ...
https://forge.autodesk.com/blog/compare-two-2d-documents-using-forge-viewer
If so, take a look at split viewer code here: https://github.com/wallabyway/2DCompare/blob/80564eea77dcc404a799d68a446cb918952ed8d4/docs/extensions/PixelCompare/PixelCompare.min.js#L235-L268

Aligning Coordinate Systems in Autodesk Forge Viewer

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