Revit 共享坐标到 Forge 查看器
Revit shared coordinates to Forge viewer
在 Forge 坐标和 Revit 的 共享 坐标之间进行转换的正确过程是什么?我知道有 globalOffset,但它参考的是 Revit 项目内部坐标系还是共享坐标?
2021 年 6 月 11 日更新
现在我 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 知道支持的对齐方式
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 );
==================
首先,Forge Viewer支持如下3种Revit link方法,你可以看看第三种(通过共享坐标)。
- Origin to origin: 将第一个模型的
globalOffset
应用到其他模型。检查 MultipleModelUtil/MultipleModelUtil.js 以获得演示
- 中心到中心: 查看器的默认方式。
- 通过shared coordinates:设置applyRefpoint: true 并使
globalOffset
变为refPoint
。 这个方法就是您要找的方法。
refPoint
是Revit内部坐标系中的Revit测量点位置。可以通过 AecModelData. Meanwhile, you can take advantage of the AggregatedView 来使用这个对齐选项。下面是一个告诉如何使用 AggregatedView 的例子:
https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e
如果您想直接将此逻辑与查看器 class 一起使用,这里有一个代码片段供您使用:
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 });
bubbleNode
可以是以下任意一种:
bubbleNode = doc.getRoot().getDefaultGeometry()
//Or
const viewables = viewerDocument.getRoot().search({'type':'geometry'});
bubbleNode = viewables[0];
要获得AecModelData
,请参考我的要点:https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e#file-index-html-L67
// Call this line before using AecModelData
await doc.downloadAecModelData();
// doc.downloadAecModelData(() => resolve(doc));
有关 AecModelData 的详细信息,请参见此处:https://forge.autodesk.com/blog/consume-aec-data-which-are-model-derivative-api
在 Forge 坐标和 Revit 的 共享 坐标之间进行转换的正确过程是什么?我知道有 globalOffset,但它参考的是 Revit 项目内部坐标系还是共享坐标?
2021 年 6 月 11 日更新
现在我 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 知道支持的对齐方式
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 );
==================
首先,Forge Viewer支持如下3种Revit link方法,你可以看看第三种(通过共享坐标)。
- Origin to origin: 将第一个模型的
globalOffset
应用到其他模型。检查 MultipleModelUtil/MultipleModelUtil.js 以获得演示 - 中心到中心: 查看器的默认方式。
- 通过shared coordinates:设置applyRefpoint: true 并使
globalOffset
变为refPoint
。 这个方法就是您要找的方法。
refPoint
是Revit内部坐标系中的Revit测量点位置。可以通过 AecModelData. Meanwhile, you can take advantage of the AggregatedView 来使用这个对齐选项。下面是一个告诉如何使用 AggregatedView 的例子:
https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e
如果您想直接将此逻辑与查看器 class 一起使用,这里有一个代码片段供您使用:
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 });
bubbleNode
可以是以下任意一种:
bubbleNode = doc.getRoot().getDefaultGeometry()
//Or
const viewables = viewerDocument.getRoot().search({'type':'geometry'});
bubbleNode = viewables[0];
要获得AecModelData
,请参考我的要点:https://gist.github.com/yiskang/c404af571ba4d631b5929c777503891e#file-index-html-L67
// Call this line before using AecModelData
await doc.downloadAecModelData();
// doc.downloadAecModelData(() => resolve(doc));
有关 AecModelData 的详细信息,请参见此处:https://forge.autodesk.com/blog/consume-aec-data-which-are-model-derivative-api