Forge Edit2D customize toolset - autodesk-forge

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

Related

How to change the geometry of the two selected models?

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.

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);

Forge Viewer 7.X : Make vertex visible on mobile

I need to show the edges of the geometries on mobile using the Forge Viewer 7.X but since version 6.X edges are hidden to improve mobile performance.
https://forge.autodesk.com/en/docs/viewer/v7/change_history/changelog_v6/
Vertex array objects default to false on mobile devices to save memory
It's there a way to turn them on again?
PS: The same log shows a render setting renderEnvironmentDisplayEdges but I can't find where it should be set.
[Edit] To comply with #Peter O. comment:
It is possible to create an override to a Three.js implementation to show meshes edges after the geometry is already loaded/created?
The solution I found have to be made while loading the geometry but the process is being taken care by the Forge Viewer so I'm not sure if I can apply it.
https://threejs.org/docs/#api/en/geometries/EdgesGeometry
Maybe this would help:
viewer.setDisplayEdges(true);

Trying to set the anti-aliasing property in autodesk forge (for 2D model/floor plan)

Trying to set the anti-aliasing property in autodesk forge (for 2D model/floor plan)
I have adding custom text geometry in my forge viewer but strigling to imrove it's quality.
Tried setQualityLevel (viewer3d.setQualityLevel(true, true)) to set the anti-aliasing on but it didn't improved the qulity/ or anti-aliasing does not seems to be working?
Attaching both images below.
with anti-aliasingoff
and anti-aliasing on
Thanks
I have checked the implementation of Forge viewer and captured some more screenshots to explain the problem again.This time I am capturing geometry created by the autodesk forge measurement tool so that we can target the real problem.
In Autodesk 3d viewer we have this option to enable disable the anti-aliasing
enter image description here
if we set it to on the result is below one. 
enter image description here
We can see edges are still jagged but not as compared to what results if we set it to off.  
Following is the result of anti-aliasing
enter image description here
Observe the red line and difference that anti-aliasing flag makes in the overall quality of the rendered data.
We need to solve the same problem in 2D version of viewer but unfortunately the option to toggle anti-aliasing is not present in 2D forge viewer.I know that the implementation of anti-aliasing present in Autodesk Forge is FXAA and not sure if there are any limitations for 2d in it? if not then can you please let us know if we can expect this future version of Autodesk forge ? Please let us know
Please note that according to the API reference the antialiasing is:
Not applicable to 2D.
That is most likely why the settings have no effect on your 2D drawing.

Forge viewer displays elements blurry in 2D views and the Measure extension does not work on them

For some of our Revit models, in Forge viewer, 2D views are display blurry, no element can be selected and the Measure extension does not work on elements and only works on the dimensions and the titleblock.
Like this example:
here and here
But it should be like this
I have tested it with our viewer, A360 viewer and Autodesk Forge Tools vscode extension.
This is because 2D drawings or PDFs can contain both vector graphics and raster graphics (this article explains the difference between the two). The measure extension needs vector graphics in order to work properly.
Thanks to Petr Broz and his hint, by changing the Model Display Style in Revit side to Hidden Line instead of Shaded the problem was solved.
Like this.
Update:
The Shadows in Graphic Display Options, also should be unchecked.