变换Edit2D区域

发布于 2025-02-04 02:31:22 字数 822 浏览 3 评论 0 原文

我正在使用由2D DWG文件创建的SVF上的Edit2D扩展名,并对转换有疑问。 autodesk.edit2d.polygon 创建的具有 getArea()方法,很棒。但是,它不是正确的单位刻度。我测试了一个大约230SF的东西,大约为2.8。

我注意到该方法采用类型 autodesk.edit2d.measuretransform 的参数,我敢肯定是我所需要的,但是我不知道如何进行转换。我看到我可以获得 viever.model.getdata()。viewports [1] .transform 。但是,这只是16个数字的数组,而不是一个变换对象,因此当我尝试传递它时会产生错误。

我无法在此上找到任何文档。有人可以告诉我这将重新出现和/或如何转换为与基础DWG文件相同的单元吗?

相关的问题,我该如何说明基础DWG所在的单位?

编辑

为了添加此内容,我试图在图纸中获取具有区域属性的所有构粒。在这种情况下,我能够弄清楚基础DWG中的多线线以平方英寸的价格报告其面积(不确定是否总是这种情况)。我基于各个聚集线生成了Edit2D多边形,因此它基本上只是在它们上面吸引了它们。

然后,我比较了从多线的区域属性与多边形上 getArea()的结果,以找到比率。在这种情况下,它总是比其来自多线的平方英尺值大约要大约83或84倍(在我的跟踪系统中存在一定程度的错误,所以我不希望此时确切的误差)。但是,这不符合我所知道的任何单位价值。因此剩下的问题:

  1. 这是什么单位?
  2. 这是一致的还是我需要在其他地方寻找这个量表?

I am using the Edit2D extension on an svf created from a 2D dwg file and have a question about transforms. The Autodesk.Edit2D.Polygon's that are created have a getArea() method which is great. However it's not in the correct unit scale. I tested one and something that should be roughly 230sf in size is coming back as about 2.8.

I notice that the method takes an argument of type Autodesk.Edit2D.MeasureTransform which I'm sure is what I need, however I don't know how to get that transform. I see that I can get viewer.model.getData().viewports[1].transform. However, that is just an array of 16 numbers and not a transform object so it creates an error when I try to pass it in.

I have not been able to find any documentation on this. Can someone tell me what units this is coming back in and/or how to convert to the same units as the underlying dwg file?

Related question, how do I tell what units the underlying DWG is in?

EDIT

To add to this, I tried to get all polylines in the drawing which have an area property. In this case I was able to figure out that the polyline in the underlying dwg was reporting its area in square inches (not sure if that's always the case). I generated Edit2D polygons based on the polylines so it basically just drew over them.

I then compared the area property from the polyline to the result of getArea() on the polygon to find the ratio. In this case it was always about 83 or 84 times smaller than the square foot value of the polyline it came from (there is some degree of error in my tracing system so I don't expect they would be exact at this point). However, that doesn't fit any unit value that I know of. So remaining questions:

  1. What unit is this?
  2. Is this consistent or do I need to look somewhere else for this scale?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吾性傲以野 2025-02-11 02:31:22

好的,经过大量的实验和挫败感,我认为我有效。我最终向Dev工具中的 getarea()方法寻找JS方向。在搜索脚本时,我找到了一个名为 defaultMeasureTransform 的类,该类从 subereTransform 继承,并获取一个查看器参数。我能够构造它,然后将其作为参数传递到 getArea()

const transform = new Autodesk.Edit2D.DefaultMeasureTransform(viewer);
const area = polygon.getArea(transform);

现在 afear 变量匹配原始CAD文件中的单元(在可接受的圆形错误中无论如何,就像.05平方英寸左右)。

在坐标系上拥有更好的文档会很好吗,我在某个地方错过了它吗?无论哪种方式,这都是有效的,希望它对其他人有帮助。

Ok after a great deal of experimentation and frustration I think I have it working. I ended up looking direction into the js for the getArea() method in dev tools. Searching through the script, I found a class called DefaultMeasureTransform that inherits from MeasureTransform and takes a viewer argument. I was able to construct that and then pass it in as an argument to getArea():

const transform = new Autodesk.Edit2D.DefaultMeasureTransform(viewer);
const area = polygon.getArea(transform);

Now the area variable matches the units in the original cad file (within acceptable rounding error anyway, it's like .05 square inches off).

Would be nice to have better documentation on the coordinate systems, am I missing it somewhere? Either way this is working so hopefully it helps someone else.

睫毛上残留的泪 2025-02-11 02:31:22

也许您错过了的第3.2个单位 https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/edit2d-use/

如果您使用edit2d而不衡量extextension,它将在模型单元中显示所有坐标。您可以通过修改或替换Defaultunithandler来自定义单元。更多信息可在自定义Edit2D教程中获得。

and

btw,我们可以通过 defaultunithandler by ediff> edist> edist2dext.defext.defaultcontext.unithandler

Maybe you missed the section 3.2 Units for Areas and Lengths of https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/edit2d-use/

If you use Edit2D without the MeasureExtension, it will display all coordinates in model units. You can customize units by modifying or replacing DefaultUnitHandler. More information is available in the Customize Edit2D tutorial.

and https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/edit2d-customize/

BTW, we can get the DefaultUnitHandler by edit2dExt.defaultContext.unitHandler

今天小雨转甜 2025-02-11 02:31:22

我知道这有点晚了,但是我想分享我的后代发现,即使您已经回答了自己的问题。对于相关用例,这将扩展它,尤其是在操纵数字以显示结果的情况下。我正在使用autodesk.edit2d扩展程序,该扩展可以实现此方法,并且我得到了My Shapees数组中形状的总面积。

const edit2d = myViewerVariable.getExtension('Autodesk.Edit2D');
const unitHandler = edit2d.defaultContext.unitHandler;
const transform = unitHandler.measureTransform;
const totalArea = myShapes.reduce(
    (internalAccumulator, internalValue) => {
        {
            return internalAccumulator + internalValue?.getArea(transform);
        }
    },
    0.0
);

此时,我的 totalarea 可以例如, 280480.0264359908 。没有单位测量。 Unithandler变量具有一个配置对象键(unithandler.config),其中包含displayunits(通过查看器中的设置设置)和layerunits(AutoCAD中定义层定义的默认单元),以防您想知道什么在这一点上与之合作。在这一点上,我现在知道上面的数字为英寸。

然后,您可以使用 unithandler 对象将指定的区域转换为用户友好的字符串,该字符串是用所选的displayunits输出的,带有 areatoStoString

unithandler.AreatoString(totalArea)返回 180m²9545cm²如果我的测量单位设置为“电表和厘米”,则在观众设置中。同样,同一功能将返回1947'²112“ 如果在查看器设置中选择“脚和十进制英寸”。

I know this is a little late, but I wanted to share my findings for posterity, even though you have already answered your own question. This expands on it for related use cases, particularly around manipulating the number to display the results. I am using the Autodesk.Edit2D extension which enables this methodology, and I'm getting the total area of shapes in myShapes array.

const edit2d = myViewerVariable.getExtension('Autodesk.Edit2D');
const unitHandler = edit2d.defaultContext.unitHandler;
const transform = unitHandler.measureTransform;
const totalArea = myShapes.reduce(
    (internalAccumulator, internalValue) => {
        {
            return internalAccumulator + internalValue?.getArea(transform);
        }
    },
    0.0
);

At this point, my totalArea could be for example, 280480.0264359908. With no unit of measurement. The unitHandler variable has a config object key (unitHandler.config) that contains both the displayUnits (set via the Settings in Viewer) and the layerUnits (the default units that the layer is defined in the AutoCAD) in case you want to know what you're working with at this point. At this point, I now know that the number above is in inches.

You can then use the unitHandler object to convert the specified area to a user-friendly string, which is output with the selected displayUnits with areaToString.

unitHandler.areaToString(totalArea) returns 180 m² 9545 cm² if my unit of measurement is set to "Meters and centimeters" in the viewer settings. Likewise, the same function will return 1947'² 112"² if "Feet and decimal inches" is selected in the viewer settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文