将 navisworks 剖面转换为锻造
Posted
技术标签:
【中文标题】将 navisworks 剖面转换为锻造【英文标题】:Converting navisworks section planes to forge 【发布时间】:2019-08-30 01:05:36 【问题描述】:我正在为 Navisworks 进行 Forge 集成,但我一直在纠结如何将 Navisworks 中的剖切面引入 Forge。我按照this blog post 中的说明设置切割平面,但我没有看到它们出现在查看器中。为了设置平面,我从 Navisworks ActiveView 中提取 SectionData 并从返回的 json 对象中提取法线向量和距离,然后通过 url 参数将数据传递给我的 forge 查看器。代码如下:
//set cut planes
if (planes.length > 0)
var three_planes = [];
var i;
for (i = 0; i < planes.length; i += 4)
var a = String(planes[i]);
var b = String(planes[i+1]);
var c = String(planes[i+2]);
var distance = String(planes[i+3]);
if (a.includes("E") || a.includes("e"))
a = "0.00";
if (b.includes("E") || b.includes("e"))
b = "0.00";
if (c.includes("E") || c.includes("e"))
c = "0.00";
if (distance.includes("E") || distance.includes("e"))
distance = "0.00";
var afloat = parseFloat(a);
var bfloat = parseFloat(b);
var cfloat = parseFloat(c);
var distancefloat = parseFloat(distance);
// create a THREE.Vector4
var vector4 = new THREE.Vector4(
afloat, bfloat,
cfloat, distancefloat);
three_planes.push(vector4);
viewer.setCutPlanes(three_planes);
查看器状态显示飞机在那里但看不到它们。是否需要任何特殊的坐标变换才能完成这项工作?
编辑:我尝试了下面给出的解决方案,但我仍然没有在 Forge 中看到切割面。我已经确认来自 Navis 的剖切面变量(afloat、bfloat、cfloat、distancefloat)正确输入。我修改后的代码如下。知道我可能做错了什么吗?
//set cut planes
if (planes.length > 0)
var three_planes = [];
var i;
for (i = 0; i < planes.length; i += 4)
var a = String(planes[i]);
var b = String(planes[i+1]);
var c = String(planes[i+2]);
var distance = String(planes[i+3]);
if (a.includes("E") || a.includes("e"))
a = "0.00";
if (b.includes("E") || b.includes("e"))
b = "0.00";
if (c.includes("E") || c.includes("e"))
c = "0.00";
if (distance.includes("E") || distance.includes("e"))
distance = "0.00";
var afloat = parseFloat(a);
var bfloat = parseFloat(b);
var cfloat = parseFloat(c);
var distancefloat = parseFloat(distance);
var forge_model_offset = NOP_VIEWER.model.getData().globalOffset;
//calculate exact distance in Forge Viewer
var dis_in_forge = (forge_model_offset.x * afloat + forge_model_offset.y * bfloat + forge_model_offset.z * cfloat) -
distancefloat;
//build the plane for Forge Viewer sectioning.
var vector4 = new THREE.Vector4(-afloat, -bfloat, -cfloat, -dis_in_forge);
three_planes.push(vector4);
NOP_VIEWER.setCutPlanes(three_planes);
编辑 2:让它工作。在这里发帖以防有人遇到这个问题。 setCutPlanes 必须在加载过程的后期调用。我的代码最初是从 onModelLoadSuccess 调用它,但它不起作用。但是当我将它移到 TEXTURES_LOADED 事件时它工作正常。
【问题讨论】:
我怀疑这可能是特定型号的问题。你能分享一个演示 Navisworks 模型吗?如果其中包含机密信息,请将其发送至 forge.help@autodesk.com(文件大小限制为 1 M,因此请放入云驱动程序并通过下载链接与我们分享)。此外,Navisworks 的快照对您想要查看的切片(和视点)会有所帮助。 我发送了一封电子邮件。如果我能看到任何可见的剖面,那就太好了。我正在直接穿过建筑物进行测试。谢谢。 【参考方案1】:我进行了一些调查,发现在 Navisworks 和 Forge Viewer 之间映射剖切面时发现了一些技巧。这是有关该主题的博客: https://forge.autodesk.com/blog/map-sectioning-plane-navisworks-forge-viewer-2
核心代码是
//get offset of the model
let forge_model_offset = NOP_VIEWER.model.getData().globalOffset
// assume the param of Navisworks clip plane is available
//I copied from the XML file
let navis_clip_plane =
x:0.1368226246,y:0.4334009763,z:0.8907542664,d:886.2418151801
//calculate exact distance in Forge Viewer
dis_in_forge =( forge_model_offset.x * navis_clip_plane.x +
forge_model_offset.y * navis_clip_plane.y +
forge_model_offset.z * navis_clip_plane.z) -
navis_clip_plane.d
//build the plane for Forge Viewer sectioning.
cutplanes = [
new THREE.Vector4( -navis_clip_plane.x,
-navis_clip_plane.y,
- navis_clip_plane.z, -dis_in_forge)
];
//apply the plane to sectioning
NOP_VIEWER.setCutPlanes(cutplanes)
【讨论】:
以上是关于将 navisworks 剖面转换为锻造的主要内容,如果未能解决你的问题,请参考以下文章
Revit:在哪里可以找到 Navisworks 导出加载项