gemini-viewer-examples icon indicating copy to clipboard operation
gemini-viewer-examples copied to clipboard

自适应

Open Super-Xiao opened this issue 1 year ago • 5 comments

老哥 怎么默认加载dxf自适应宽高呢

Super-Xiao avatar Apr 01 '24 07:04 Super-Xiao

I don't quite understand your question. After a dxf is loaded, it automatically zoom to the "home" view, which is defined in the dxf itself.

Do you want it to zoom to graphic extent rather than the original "home" view? To do so, you can firstly get the graphic extent, then zoom to it:

const extent = viewer.getActiveLayoutInfo().extent;
viewer.zoomToBBox(extent);

yanzexuan1 avatar Apr 02 '24 00:04 yanzexuan1

image 目前我加载完成dxf是这样的 被放大了很多。

Super-Xiao avatar Apr 02 '24 10:04 Super-Xiao

Oh, please try this:

const bbox = viewer.getBBox();
viewer.zoomToBBox(bbox);

yanzexuan1 avatar Apr 03 '24 01:04 yanzexuan1

使用这段代码后 image

Super-Xiao avatar Apr 03 '24 02:04 Super-Xiao

Can you check carefully, if there is any small entity somewhere in the corner? That often happen. Or, you can create a new dxf, draw some entities and test again.

yanzexuan1 avatar Apr 03 '24 02:04 yanzexuan1