Plan from Revit becomes a picture in forge viewer - autodesk-forge

So when I export my Revit file to the Forge Viewer the 2D plan I want to look at does not have any selectable elements because it somehow was exported as a picture.
It is only my assumption that it was exported as a picture since it becomes blurry when I zoom in. Is this a known issue or does my plan need a special property to be able to be translated to forge properly?
Using a demo file everything works perfectly but using a file coming from a different source does not seem to work properly

There are a few reasons for a view to becoming a raster:
uses shading, shadows, gradients, or sketchy lines.
is rendered.
contains an image.
uses point clouds.
contains a decal. (Includes Revit Annotation elements, such as section, spot, text, and etc.)

Related

How to show dwg in web page

I have a dwg (I can change the file format to svg or other formats if needed) file that I want to show on my web page. After this file is displayed in the page, I want to be able to zoom in, zoom out, pan and put links that request the api where necessary. In fact, it looks like information and links about the relevant place appear when you hover over the landmarks on Google maps.
How should I go about doing this job?
If you can translate the DWG file to DXF (there are several tools to do this) then you can use MapServer to render it on a web map compatible way. Have a look at MS4W for an easy way to install and configure MapServer on Windows. Since you want pop-ups, I'd recommend using Leaflet as the client side browser tool kit for providing pan, zoom, pop-ups etc to communicate to MapServer. figuring out the coordinate system of the DWG file will likely be the hardest part.
Use this method if integrating your DWG with other mapping data (roads, etc) is important. Otherwise look for something easier to implement.
There are libraries that let you easily zoom and pan an SVG image. For example svg-pan-zoom.
As for the links, you would need to do a bit of extra work. IIRC DXF files don't have the concept of a whole element that you could hover over. All the lines in the file are discrete object. So, if I am remembering that correctly, you may need to load the SVG into an editor and add elements on top of the diagram that correspond to your hover areas. They don't need to be visible. They can be transparent and still hoverable. You just need to then add the interactivity. Ie.
Optionally add hover effects with CSS.
Add a mouseover or click event handling to implement the link handling, or
use standard SVG <a> linking instead.

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.

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...

How do I get a consistent markup font size across models when using the Autodesk Forge Viewer MarkupsCore extension?

I'm using the MarkupsCore extension to make persistent text markups on a bunch of different 2D models. I'm setting the style like this:
markupsExt.setStyle({"font-size" : .12});
Usually this works. But sometimes, depending on the .dwg file that gets uploaded to Forge, the markups are way too small. I have no control over the files that get uploaded and I have no idea how they are configured when they are created in AutoCad.
What's going on here and how can I achieve a consistent font size in my markups no matter what model I'm marking up?