autodesk-forgeautodesk-viewer

angleToTrueNorth is null for Navisworks translated model


When translating a Navisworks model to SVF, the value for angleToTrueNorth from model.getData().metadata['custom values'].angleToTrueNorth is not available. Where else can I find it?


Solution

  • Unfortunately, the angleToTrueNorth is Revit only, i.e., translating RVT directly with Model Derivative API, as far as I know.

    model.getData().metadata['custom values'].angleToTrueNorth
    

    However, if your NWC/NWD model was exported from RVT using shared coordinates after last April, then we could calculate that from the nwModelToWorldTransform transform in the manifest.

    "derivatives": [
    {
        "name": "racbasicsampleproject.nwc",
        "hasThumbnail": "true",
        "status": "success",
        "progress": "complete",
        "properties": {
            "Document Information": {
                "Navisworks File Creator": "nwexportrevit",
                "nwModelToWorldTransform": [
                    0.7986355100472902,
                    0.6018150231520518,
                    0,
                    -0.6018150231520518,
                    0.7986355100472902,
                    0,
                    0,
                    0,
                    1,
                    -65.03805139774867,
                    -61.70701987942478,
                    0
                ]
            },
    
            ///...
    

    Here is how we can calculate the angle to true north from the transform:

    let model = viewer.getAllModels()[0];
    let doc = model.getDocumentNode().getDocument();
    let docRoot = doc.getRoot();
    let docInfo = docRoot.children[0].data.properties['Document Information'];
    
    let angle = THREE.Math.radToDeg(Math.acos( docInfo.nwModelToWorldTransform[0] )) //!<<< ref: https://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations
    
    let angelToTrueNorth = -1.0 * angle; //!<<< The angelToTrueNorth is clockwise, but the angle in math is counterclockwise
    

    So, using the above nwModelToWorldTransform transform for example, the calculated angelToTrueNorth will be:

    let angle = THREE.Math.radToDeg(Math.acos( 0.7986355100472902 )); //<<< 37°
    
    let angelToTrueNorth = -1.0 * 37; //!<<< -37° = 323°
    

    enter image description here