Loading DWGs into AggregatedView

huangapple go评论58阅读模式
英文:

Loading DWGs into AggregatedView

问题

I'm having issues getting several models aligned in an AggregatedView using APS (Forge).
我在使用APS(Forge)时遇到了几个模型无法对齐的问题。

I have several Revit-files loaded, they share coordinates and are loaded into the view correctly aligned to each other. But after user input I am loading several more models (this time DWGs) into the same instance. These DWGs I of course want to be aligned to the Revit files, but however I try it I just can't seem to align them.
我已加载了几个Revit文件,它们共享坐标并已正确对齐加载到视图中。但在用户输入后,我加载了更多模型(这次是DWG文件)到同一个实例。当然,我希望这些DWG文件与Revit文件对齐,但无论我如何尝试,似乎无法对齐它们。

The Revit files have a Project Base Point of 142000,6584000,0, (which gives the correct Shared Coordinates to the DWGs) but when I load the Revit files into the viewer the get a globalOffset of: x: 473184.78.., y: 21616569.45.., z: -52.18... Which doesn't seem right to me. And when I look at the unitScale of the model they have a unit scale of 0.3048 even though they have "Length" and "Distance" in meter.
Revit文件具有项目基准点坐标为142000,6584000,0(这为DWG文件提供了正确的共享坐标),但当我将Revit文件加载到查看器中时,它们的globalOffset为:x: 473184.78.., y: 21616569.45.., z: -52.18... 这对我来说似乎不正确。而且当我查看模型的unitScale时,尽管它们的单位为"米",但它们的单位比例为0.3048。

When I then load the DWGs I use:
然后,当我加载DWG文件时,我使用:

To give me the options:
为了给我提供以下选项:

This puts my models "kinda" correctly, which means within a couple of km.. But however else I try the models gets placed insanely far away.
这使我的模型“有点”正确,也就是在几公里内...但无论我如何尝试,模型都被放置在非常远的地方。

Could really use some help, sadly looking at other questions hasn't revealed to me what I'm doing wrong here.
真的需要一些帮助,不幸的是查看其他问题并没有揭示我在这里做错了什么。

Thanks!
谢谢!

I tried loading both the Revit models and DWGs with "applyScaling: 'meter'", but with that option the Revit models no longer load correctly aligned to each other, and looking at the unitScale of the models only the first model gets the applied scaling, the rest keeps 0.3048 (the DWGs already have the correct scaling of 1).
我尝试加载Revit模型和DWG模型时都使用了"applyScaling: 'meter'",但使用该选项后,Revit模型不再正确对齐加载,查看模型的unitScale只有第一个模型应用了缩放,其余保持为0.3048(DWG模型已经具有正确的缩放比例为1)。

When I measure the models I see that the DWGs are about 1/3 as big as they should be in comparison to the Revit files, which would make sense considering the scaling but sadly applying scaling doesn't work for the Revit files.
当我测量模型时,我发现与Revit文件相比,DWG模型约小了1/3,考虑到缩放,这是有道理的,但不幸的是,应用缩放对Revit文件不起作用。

I have tried redoing the variable "coordinates_alter" with other subtractions/additions but I can nog get the models closer to what I have at the moment.
我已经尝试使用其他减法/加法重新设置变量"coordinates_alter",但我无法使模型更接近目前的情况。

I have also tried loading them in "vanilla" or with different globalOffset but neither places them correctly.
我还尝试过在"原始"状态下加载它们,或使用不同的globalOffset,但都不能正确放置它们。

英文:

I'm having issues getting several models aligned in an AggregatedView using APS (Forge).
I have several Revit-files loaded, they share coordinates and are loaded into the view correctly aligned to each other. But after user input I am loading several more models (this time DWGs) into the same instance. These DWGs I of course want to be aligned to the Revit files, but however I try it I just can't seem to align them.
The Revit files have a Project Base Point of 142000,6584000,0, (which gives the correct Shared Coordinates to the DWGs) but when I load the Revit files into the viewer the get a globalOffset of: x: 473184.78.., y: 21616569.45.., z: -52.18... Which doesn't seem right to me. And when I look at the unitScale of the model they have a unit scale of 0.3048 even though they have "Length" and "Distance" in meter.
When I then load the DWGs I use:

// revitModel is the first Revit model loaded into the view
const revitTransform = revitModel.getData().refPointTransform.elements;
const revitOffset = revitModel.getData().globalOffset;
var coordinates_alter = new THREE.Vector3(revitTransform[12]-142000, revitTransform[13]-6584000, revitTransform[14]);
var transform = new THREE.Matrix4().makeTranslation(coordinates_alter.x,coordinates_alter.y,coordinates_alter.z);

To give me the options:

        const options = {
            placementTransform: transform,
            globalOffset: revitOffset,
            applyRefPoint: true,
        };

This puts my models "kinda" correctly, which means within a couple of km.. But however else I try the models gets placed insanely far away.
Could really use some help, sadly looking at other questions hasn't revealed to me what I'm doing wrong here.

Thanks!

I tried loading both the Revit models and DWGs with "applyScaling: 'meter'", but with that option the Revit models no longer load correctly aligned to each other, and looking at the unitScale of the models only the first model gets the applied scaling, the rest keeps 0.3048 (the DWGs already have the correct scaling of 1).
When I measure the models I see that the DWGs are about 1/3 as big as they should be in comparison to the Revit files, which would make sense considering the scaling but sadly applying scaling doesn't work for the Revit files.

I have tried redoing the variable "coordinates_alter" with other subtractions/additions but I can nog get the models closer to what I have at the moment.

I have also tried loading them in "vanilla" or with different globalOffset but neither places them correctly.

答案1

得分: 2

获取模型偏移值是一件麻烦的事情。以下是对我有效的方法:

applyRefPoint: false,
applyScaling: "m"

然后,大部分情况下,忽略所有模型特定的 globalOffsetrefPointTransformplacementTransform,而只考虑 AggregatedView.globalOffset。当从汇总查看器加载或卸载模型时,此矢量将会动态变化。

如果您确实需要对模型应用变换(例如,在Revit中与其他模型一起加载时,模型的位置、旋转或缩放不正确),我认为您应该只使用 placementTransform,而不添加其他偏移。这是一个 Matrix4,您可以使用它来任意平移、旋转或缩放您的模型。使用额外的偏移值只会令人困惑。

英文:

Getting model offsets right is a pain. This is what worked for me:

applyRefPoint: false,
applyScaling: "m"

Then mostly ignoring all model specific globalOffset, refPointTransform and placementTransform, instead only considering AggregatedView.globalOffset. This vector will dynamically change when loading or unloading models from the aggregated viewer.

If you actually need to apply a transform to a model (it has an incorrect position, rotation or scaling if loaded in combination with other models in eg. Revit) I think you should only use placementTransform, no additional offsets. This is a Matrix4 which you can use to arbitrarily translate, rotate or scale your model. Using additional offsets is only going to be confusing.

huangapple
  • 本文由 发表于 2023年2月27日 18:05:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75579065.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定