nn15296
nn15296

Reputation: 3

How to convert between coordinates in Revit and those in APS viewer

I'm trying to convert the coordinates that I get for a given location in a Revit file to those in APS viewer for the same file uploaded into an APS bucket, however I am unable to find any methods which match the two.

I've tried using the following methods:

  1. viewer.clientToWorld which will get the local coordinates of the place that you click.
  2. viewer.model.getData().globalOffset to offset the viewer.clientToWorld in line with the following answer: Transforming coordinates from Revit to Viewer.
  3. Using the Geolocation extension functions lmvToLonLat to convert the viewer.clientToWorld coordinates to Longitude and Latitude.

None of these methods match up to the coordinates for the same location in Revit. The three types of coordinates we have are:

  1. N/S and E/W in metres
  2. N/S and E/W in feet
  3. Longitude and Latitude coordinates

Upvotes: 0

Views: 157

Answers (2)

Eason Kang
Eason Kang

Reputation: 7070

If you just want to convert N/S and E/W into Revit internal coordinate space, then here is a way I shared in https://stackoverflow.com/a/75799083/7745569, especially, getProjectLocationToModelTransformation and reportProjectBasePoint:

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 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;
}

However,

If you want to convert the N/S and E/W into real geolocation points (in WGS84 or other GIS coordinate systems), then your RVT model must configured well with geolocation info (e.g. using the Autodesk Shared Reference Point Tool), so that Revit will know the correct transform matrix and put it into refPointTransformation when translating to SVF/SVF2.

Upvotes: 0

Petr Broz
Petr Broz

Reputation: 9942

There's a viewer extension called GeolocationExtension that provides this kind of functionality (mapping between lat/long coordinates and in-viewer coordinates) through methods such as lonLatToLmv or lmvToLonLat.

Upvotes: 0

Related Questions