Revit 共享坐标到 Forge 查看器 [英] Revit shared coordinates to Forge viewer

查看:33
本文介绍了Revit 共享坐标到 Forge 查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Forge 坐标和 Revit 的共享坐标之间进行转换的正确过程是什么?我知道有 globalOffset,但它是参考 Revit 项目内部坐标系还是共享坐标?

解决方案

2021 年 6 月 11 日更新

现在我的 MultipleModelUtil.js 支持我在下面分享的对齐方式.此外,我们可以很容易地告诉 Forge Viewer 使用 共享坐标以聚合模型.这是代码片段,您可以查看此处以了解支持的对齐方式>

const util = new MultipleModelUtil(viewer);util.options = {对齐方式:MultipleModelAlignmentType.ShareCoordinates};常量模型 = [{ name: '1.rvt', urn: 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLlNpaHgxOTVuUVJDMHIyWXZUSVRuZFE_dmVyc2lvbj0x' },{ name: '2.rvt', urn: 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLldVRHJ4ajZ6UTBPLTRrbWZrZ3ZoLUE_dmVyc2lvbj0x' },{ name: '3.rvt', urn: 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjRyZW5HRTNUU25xNHhYaW5xdWtyaWc_dmVyc2lvbj0x' }];util.processModels(模型);

==================

首先,Forge Viewer 支持如下三种 Revit 链接方式,您可以查看第 3 种(共享坐标).

  1. Origin to origin:将第一个模型的 globalOffset 应用于其他模型.检查 MultipleModelUtil/MultipleModelUtil.js 以获取演示
  2. 中心到中心:查看器的默认方式.
  3. 共享坐标:设置 applyRefpoint: true 并将 globalOffset 设置为refPoint.这种方法正是您要找的方法.

refPoint 是 Revit 内部坐标系内的 Revit 测量点位置.它可以通过 AecModelData 访问.同时,您可以利用 AggregatedView 使用此对齐选项.这是一个说明如何使用 AggregatedView 的示例:https://gist.github.com/yiskang/c404af571ba4d631b5929c89775

如果你想直接在 Viewer 类中使用这个逻辑,这里有一个代码片段:

let globalOffset = null;const aecModelData = bubbleNode.getAecModelData();const tf = aecModelData &&aecModelData.refPointTransformation;//Matrix4x3 作为数组[12]const refPoint = tf ?{ x: tf[9], y: tf[10], z: 0.0 } : { x: 0, y: 0, z: 0 };//检查当前的 globalOffset 是否足够接近 refPoint 以避免不准确.const MaxDistSqr = 4.0e6;const distSqr = globalOffset &&三.Vector3.prototype.distanceToSquared.call(refPoint, globalOffset);if (!globalOffset || distSqr > MaxDistSqr) {globalOffset = new THREE.Vector3().copy(refPoint);}viewer.loadDocumentNode(doc, bubbleNode, { applyRefpoint: true, globalOffset: globalOffset, keepCurrentModels: true });

bubbleNode 可以是以下之一:

bubbleNode = doc.getRoot().getDefaultGeometry()//或者const viewables = viewerDocument.getRoot().search({'type':'geometry'});气泡节点 = 可视[0];

要获取AecModelData,请参考我的gist:https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e#file-index-html-L67

//在使用 AecModelData 之前调用这一行等待 doc.downloadAecModelData();//doc.downloadAecModelData(() => resolve(doc));

有关 AecModelData 的详细信息,请参阅此处:https://forge.autodesk.com/blog/consume-aec-data-which-are-model-derivative-api

What is the correct process for getting a transform between Forge coordinates and Revit's shared coordinates? I know there is globalOffset, but does it reference the Revit project internal coordinate system or shared coordinates?

解决方案

Update Jun 11th, 2021

Now my MultipleModelUtil.js supports the alignments I shared below. Also, we can easily tell Forge Viewer to use By shared coordinates to aggregate models. Here is the code snippet, and you can check out here to know supported alignments

const util = new MultipleModelUtil( viewer );

util.options = {
  alignment: MultipleModelAlignmentType.ShareCoordinates
};

const models = [
  { name: '1.rvt', urn: 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLlNpaHgxOTVuUVJDMHIyWXZUSVRuZFE_dmVyc2lvbj0x' },
  { name: '2.rvt', urn: 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLldVRHJ4ajZ6UTBPLTRrbWZrZ3ZoLUE_dmVyc2lvbj0x' },
  { name: '3.rvt', urn: 'urn:dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLjRyZW5HRTNUU25xNHhYaW5xdWtyaWc_dmVyc2lvbj0x' }
];

util.processModels( models );

==================

First, Forge Viewer supports 3 kinds of Revit link methods as the below, and you can take a look at the 3rd one (By shared coordinates).

  1. Origin to origin: Apply the globalOffset of the 1st model to others. Check MultipleModelUtil/MultipleModelUtil.js for the demo
  2. Center to center: the default way of the viewer.
  3. By shared coordinates: set up applyRefpoint: true and make the globalOffset to the refPoint. This method is the one you are looking for.

The refPoint is the Revit survey point location inside Revit internal coordinate system. It's accessible with the AecModelData. Meanwhile, you can take advantage of the AggregatedView to use this aligning option. Here is an example of telling how to use AggregatedView: https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e

If you want to use this logic with the Viewer class directly, here is a code snippet for you:

let globalOffset = null;

const aecModelData = bubbleNode.getAecModelData();
const tf = aecModelData && aecModelData.refPointTransformation; // Matrix4x3 as array[12]
const refPoint = tf ? { x: tf[9], y: tf[10], z: 0.0 } : { x: 0, y: 0, z: 0 };

// Check if the current globalOffset is sufficiently close to the refPoint to avoid inaccuracies.
const MaxDistSqr = 4.0e6;
const distSqr    = globalOffset && THREE.Vector3.prototype.distanceToSquared.call(refPoint, globalOffset);
if (!globalOffset || distSqr > MaxDistSqr) {
    globalOffset = new THREE.Vector3().copy(refPoint);
}

viewer.loadDocumentNode(doc, bubbleNode, { applyRefpoint: true, globalOffset: globalOffset, keepCurrentModels: true });

The bubbleNode can be either of the following:

bubbleNode = doc.getRoot().getDefaultGeometry()

//Or

const viewables = viewerDocument.getRoot().search({'type':'geometry'});
bubbleNode = viewables[0];

To get AecModelData, please refer to my gist: https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e#file-index-html-L67

// Call this line before using AecModelData
await doc.downloadAecModelData();

// doc.downloadAecModelData(() => resolve(doc));

See here for details of the AecModelData: https://forge.autodesk.com/blog/consume-aec-data-which-are-model-derivative-api

这篇关于Revit 共享坐标到 Forge 查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆