We want to show a marker on the different origin locations of Revit files. I can show the Revit Iternal Point (viewer.model.getData().refPointTransform) and also the Survey Point (viewer.model.getGlobalOffset()) currently I can not find any reference to the Project Base point
-
as far as I know base point from source Revit model is always (0,0,0), In default, Forge Viewer will load the model by aligning the model boundingbox center to the origin of Forge Viewer coordinate. getGlobalOffset tells the offset. So by reversing calculating, you will get the base point of the source model.Xiaodong Liang– Xiaodong Liang2021-11-19 08:45:42 +00:00Commented Nov 19, 2021 at 8:45
-
Survey point should be refPointTransform.Xiaodong Liang– Xiaodong Liang2021-11-19 08:46:49 +00:00Commented Nov 19, 2021 at 8:46
-
Now I'm totaly lost. I can not get any reference to the different Revit Origins. See image here and the small Revit file here GetGlobalOffset and refPointtransform give me vector(0,0,0) wich in the example Revit file is the Revit internal pointNic Maes– Nic Maes2021-11-19 10:00:02 +00:00Commented Nov 19, 2021 at 10:00
-
I will investigate your model and get back to you as soon as possible. currently, I am busy on an event. Will try best to get back to you in the two days. thank you for patienceXiaodong Liang– Xiaodong Liang2021-11-23 14:01:14 +00:00Commented Nov 23, 2021 at 14:01
-
I investigated your model and checked every possible value. Also checked setting of Revit, but did not seem to find why the values are (0,0,0). Please bear with me checking with engineer team.Xiaodong Liang– Xiaodong Liang2021-11-25 04:44:47 +00:00Commented Nov 25, 2021 at 4:44
|
Show 4 more comments
1 Answer
I'm afraid the global offset is not the position of the project base point since the project base point is movable in Revit by changing its 'E/W', N/S, and Elev parameters.
Now I figured it out. We can get the project base point's position in Revit internal coordinate system by the following:
async getProjectLocationToModelTransformation(model) {
const aecModelData = await Autodesk.Viewing.Document.getAecModelData(model.getDocumentNode());
const refPointTransformation = this.readMatrixFromArray12(aecModelData.refPointTransformation);
const projectLocationToModelTransformation = new SylvesterMatrix(refPointTransformation.elements).inverse().toThreeMatrix4();
return projectLocationToModelTransformation;
}
async getBasePointData(model, category = 'Revit Base Point') {
return new Promise(async (resolve, reject) => {
const found = await this.searchAsync(model, category, ['Category'], { searchHidden: true });
if (!found || found.length <= 0) return reject('Base point not found');
const result = await this.getBulkProperties2Async(found, { propFilter: ['N/S', 'E/W', 'Elev', 'Angle to True North'] }, model);
if (!result) return reject('Base point not found');
const data = result[0];
return resolve(data);
});
}
async reportProjectBasePoint(model, useViewerSpace = false) {
const projectLocationToModelTransformation = await this.getProjectLocationToModelTransformation(model);
const basePointData = await this.getBasePointData(model);
const eastWestProp = basePointData.properties.find(p => p.attributeName == 'E/W');
const northSouthProp = basePointData.properties.find(p => p.attributeName == 'N/S');
const elevProp = basePointData.properties.find(p => p.attributeName == 'Elev');
const angletonProp = basePointData.properties.find(p => p.attributeName == 'Angle to True North');
const eastWestVal = Autodesk.Viewing.Private.convertToDisplayUnits(eastWestProp.displayValue, eastWestProp.type, eastWestProp.units, model.getUnitString());
const northSouthVal = Autodesk.Viewing.Private.convertToDisplayUnits(northSouthProp.displayValue, northSouthProp.type, northSouthProp.units, model.getUnitString());
const elevVal = Autodesk.Viewing.Private.convertToDisplayUnits(elevProp.displayValue, elevProp.type, elevProp.units, model.getUnitString());
const basePoint = new THREE.Vector3(eastWestVal.displayValue, northSouthVal.displayValue, elevVal.displayValue);
const basePointInRvt = basePoint.clone().applyMatrix4(projectLocationToModelTransformation);
if (useViewerSpace)
return basePointInRvt.clone().applyMatrix4(model.getModelToViewerTransform());
return basePointInRvt;
}
await reportProjectBasePoint(viewer.getAllModels()[0]); //!<<< PBP position in Revit space
await reportProjectBasePoint(viewer.getAllModels()[0], true); //!<<< PBP position in viewer space
Please find here for the full code: https://gist.github.com/yiskang/e96f544252a989daef022cd89e799f46
