How can i create 3d pushpin extension for autodesk forge? - autodesk-forge

I want to create 3d pushpin extension for Autodesk forge v7.*. I tried to use this article`
3D Markup with icons and Info-Card.
But some functions are not working correctly. How can i use it correctly?
I got this errors in console
Now all functions are working correctly, in data i got undefined for parent. Pushpins are not appeared yet.

Apparently there were a few issues with your code:
Since Viewer v7 and onwards overlay scenes are managed so you'd need to add custom geometry with:
this.viewer.overlays.addScene('custom-scene');
this.viewer.overlays.addMesh(this.line3d, 'custom-scene');
Use arrow functions or bind for your callbacks to window and document events such as mousemove or click otherwise they'd lose their contexts and throw errors
Necessary styling was not set for the markups to persist their relative positions ...
See here with corrections to all of the above:

Related

Forge Viewer add markups and choose elements in 2D drawings

We use forge viewer in our app. It's work good but, we want to add more functionality. But for now i can't get the element Id. I tried to use NOP_VIEWER.getSelection() but in our app return empty array. I also tried load our document here https://forge-extensions.autodesk.io/ and tried to do the same. In your example it works. Could you tell me where is the mistake?

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.

Forge Viewer - can we associate objects of model with markups which are drawn in viewer?

I have object tree view on left side of my viewer, now am looking to establish an association with the markups drawn on the viewer, for example if click on wall object, it should focus me that particular wall object along with the markups there and also should hide other markups in that viewer. So it's making easy for user to see all those associated markups in that wall only.
Is this doable?
Thanks in advance
it should focus me that particular wall object along with the markups there and also should hide other markups in that viewer.
Try control the visibility of a markup with:
markupExt.markups[index].shape.style.display='none/block'
And to add markups to the position of a particular node follow here: https://forge.autodesk.com/blog/placing-custom-markup-dbid
This markup extension example should show you how to do, at least, part of what you are looking for:
https://github.com/apprentice3d/ForgeViewerExtensions

Autodesk Forge Viewer - show markups all the time

We are using the Forge viewer to show both 2D and 3D models. For the 2D models, we would like to be able to show markups all the time, like you can with the viewer inside BIM360.
I tried the solution mentioned here: Forge Viewer: Show bottom toolbar and markups at the same time - but I have not been able to get that to work. It seems like when I call:
Autodesk.Viewing.Extensions.Markups.Core.Utils.showLmvToolsAndPanels(viewer)
It hides the markups.
How is this done in BIM360? - are they using a custom viewer, where this has been enabled somehow?
Unfortunately I was able to get it to work with:
Autodesk.Viewing.Extensions.Markups.Core.Utils.showLmvToolsAndPanels(viewer)
See live sample here:

Autodesk Forge Viewer - Inaccurate Pushpin Location

I am following the tutorial available here, in order to add Pushpins to a clicked location on the Forge viewer. My issue is that the pushpin is drawn on a different location to where I clicked on the viewer. I am using the exact same code that as available in the tutorial, although I have implemented it as a separate extension.
Following is a screenshot of where the Pushpin was drawn, and where the mouse pointer was at the time it was clicked.
I have been trying to play around with the code by even manually changing the location to get the correct position, but wasn't really successful. Any help on this regard would be appreciated.
Thanks in Advance!
I have this problem when my app was doing components size changes with css, and I solve this calling the method resize of the viewer, after the visual size changes, and before the pushpin creation, like above:
viewer.resize()
Link: https://forge.autodesk.com/en/docs/viewer/v7/reference/Viewing/Viewer3D/#resize
I hope this can help you!