Zoom on a specific element #106
-
|
Hello, I wonder if is there any way to zoom on a specific element (having maybe the coordinates) once the dxf is loaded. Basically the same behaviour achievable zooming with the mouse wheel, but programmatically. Thanks for such a beautiful library! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
|
Hello, |
Beta Was this translation helpful? Give feedback.
-
That looks strange. I just tried it in the example page: const bounds = this.dxfViewer.GetBounds()
const origin = this.dxfViewer.GetOrigin()
const center = {x: (bounds.maxX + bounds.minX) / 2 - origin.x,
y: (bounds.maxY + bounds.minY) / 2 - origin.y}
this.dxfViewer.SetView(center, 200)
this.dxfViewer.Render()Inserted it after DXF is loaded here, and it works as expected. The view is not distorted by mouse manipulations. So it is probably something specific to your code. |
Beta Was this translation helpful? Give feedback.
-
|
Hello @vagran I've also tested on your example, adding the following code in the finally block. With a slight modification (e.g. adding +1 offset on both x and y) the distortion occurs after zooming or moving. const bounds = this.dxfViewer.GetBounds()
const origin = this.dxfViewer.GetOrigin()
const center = {x: (bounds.maxX + bounds.minX) / 2 - origin.x + 1,
y: (bounds.maxY + bounds.minY) / 2 - origin.y + 1}
this.dxfViewer.SetView(center, 200)
this.dxfViewer.Render()As the offset decreases, the distortion appears less visible. Best regards, |
Beta Was this translation helpful? Give feedback.
-
|
How would I use SetView to focus on DXF coordinates. Is there already an existing helper we can use? For example I have the following metadata: |
Beta Was this translation helpful? Give feedback.


Oh, nice finding! Thanks!
I will fix it in master now. Before the next release, you can use this workaround in your code: