我正在使用由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倍(在我的跟踪系统中存在一定程度的错误,所以我不希望此时确切的误差)。但是,这不符合我所知道的任何单位价值。因此剩下的问题:
- 这是什么单位?
- 这是一致的还是我需要在其他地方寻找这个量表?
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:
- What unit is this?
- Is this consistent or do I need to look somewhere else for this scale?
发布评论
评论(3)
好的,经过大量的实验和挫败感,我认为我有效。我最终向Dev工具中的
getarea()
方法寻找JS方向。在搜索脚本时,我找到了一个名为defaultMeasureTransform
的类,该类从subereTransform
继承,并获取一个查看器参数。我能够构造它,然后将其作为参数传递到getArea()
:现在
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 calledDefaultMeasureTransform
that inherits fromMeasureTransform
and takes a viewer argument. I was able to construct that and then pass it in as an argument togetArea()
: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.
也许您错过了的第3.2个单位 https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/edit2d-use/
and
btw,我们可以通过
defaultunithandler
byediff> 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/and https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/edit2d-customize/
BTW, we can get the
DefaultUnitHandler
byedit2dExt.defaultContext.unitHandler
我知道这有点晚了,但是我想分享我的后代发现,即使您已经回答了自己的问题。对于相关用例,这将扩展它,尤其是在操纵数字以显示结果的情况下。我正在使用autodesk.edit2d扩展程序,该扩展可以实现此方法,并且我得到了My Shapees数组中形状的总面积。
此时,我的
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.
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 withareaToString
.unitHandler.areaToString(totalArea)
returns180 m² 9545 cm²
if my unit of measurement is set to "Meters and centimeters" in the viewer settings. Likewise, the same function will return1947'² 112"²
if "Feet and decimal inches" is selected in the viewer settings.