如何在Froge查看器中复制“截面剪切形式”修订?
我正在研究一个可以从Forge Viewer中从Revit切割的部分框的应用程序。我使用以下代码在Revit API中获得了最大点和最小框的最大点和最小框:
BoundingBoxXYZ currentSectionBox = view3D.GetSectionBox();
double[] minPt = new double[] {
currentSectionBox.Transform.Origin.X + currentSectionBox.Min[0],
currentSectionBox.Transform.Origin.Y + currentSectionBox.Min[1],
currentSectionBox.Transform.Origin.Z + currentSectionBox.Min[2]
};
double[] maxPt = new double[] {
currentSectionBox.Transform.Origin.X + currentSectionBox.Max[0],
currentSectionBox.Transform.Origin.Y + currentSectionBox.Max[1],
currentSectionBox.Transform.Origin.Z + currentSectionBox.Max[2]
};
它可以通过此代码在Revit中复制:
...
// View3D is the current opened 3d view in revit
View3D.SetSectionBox(new BoundingBoxXYZ() {
Max = new XYZ(maxPt[0], maxPt[1], maxPt[2]),
Min = new XYZ(minPt[0], minPt[1], minPt[2])
});
到目前为止,,我使用了相同的最大值和最小值指向Forge Viewer 。我希望看到相同的结果,但事实并非如此。我的代码中有什么问题,还是我只是误解了一些概念?
let offset = this.Viewer3D.model.getData().globalOffset
offset = new THREE.Vector3(offset.x, offset.y, offset.y)
const sectionBoxPosition = new THREE.Box3(minPt.sub(offset), maxPt.sub(offset))
this.Viewer3D.loadExtension('Autodesk.Section').then(function (Section) {
Section.setSectionBox(sectionBoxPosition)
})
I'm working on an app that can reproduce the section box cut from revit in forge viewer. I've got the max point and min point of section box using the code below in revit api:
BoundingBoxXYZ currentSectionBox = view3D.GetSectionBox();
double[] minPt = new double[] {
currentSectionBox.Transform.Origin.X + currentSectionBox.Min[0],
currentSectionBox.Transform.Origin.Y + currentSectionBox.Min[1],
currentSectionBox.Transform.Origin.Z + currentSectionBox.Min[2]
};
double[] maxPt = new double[] {
currentSectionBox.Transform.Origin.X + currentSectionBox.Max[0],
currentSectionBox.Transform.Origin.Y + currentSectionBox.Max[1],
currentSectionBox.Transform.Origin.Z + currentSectionBox.Max[2]
};
And it can be reproduced by this code same in the revit:
...
// View3D is the current opened 3d view in revit
View3D.SetSectionBox(new BoundingBoxXYZ() {
Max = new XYZ(maxPt[0], maxPt[1], maxPt[2]),
Min = new XYZ(minPt[0], minPt[1], minPt[2])
});
So far so good, then I used the same max and min point in forge viewer. I expected to see the same result in revit, but it didn't. Is anything wrong in my code or I just misunderstand some concept about it?
let offset = this.Viewer3D.model.getData().globalOffset
offset = new THREE.Vector3(offset.x, offset.y, offset.y)
const sectionBoxPosition = new THREE.Box3(minPt.sub(offset), maxPt.sub(offset))
this.Viewer3D.loadExtension('Autodesk.Section').then(function (Section) {
Section.setSectionBox(sectionBoxPosition)
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您过去应用全局偏移的方式看起来不正确。
我建议您使用
viewer.model.getModeltoviewertransform()
进行以下计算,以获取正确的模型来转换查看器。有时,除全球偏移量外,模型还有其他转换。注意。
boxtransformfromrvt
来自Revit SectionBox的boundingbox.transform
如下所示。(0,0,0,1)
用于转换矩阵的w元素,因为三js的变换为4x4(xyzw),但是我们从revit中获得的是4x3。这是我的测试的快照:
revit

在Forge查看器中

The way you used to apply the global offset looks incorrect.
I would advise you to do the calculation like the below using
viewer.model.getModelToViewerTransform()
to get the correct model to transform in the viewer. Sometimes, there are other transforms made to the model except for the global offset.Note. The
boxTransformFromRvt
is from Revit SectionBox'sBoundingBox.Transform
like below. The(0,0,0,1)
is for w element of the transform matrix, as threejs' transform is 4x4 (xyzw), but what we get from Revit is 4x3.Here are the snapshots of my tests:
In Revit

In Forge Viewer
