是否可以在 Forge 中获取 nwd 模型的保存视图的名称?

Is it possible to get the name of saved views of nwd models in Forge?

我知道可以从 Navisworks 模型中保存的视图中获取相机,但最好也获取名称。将 nwd 文件上传到 BIM 360 Document Management 项目时,会显示这些保存的视图。是否也可以使用 Froge 查看器执行此操作?或者这只是文档管理器的功能吗? 问候弗罗德

Navisworks 文件中保存的视图可以通过 GET:urn/manifest 的响应中的视点名称获取。这是 Revit 房屋示例模型的示例,rac_basic_sample_project.rvt 导出为 rac_basic_sample_project.nwc,请参阅文件夹类型 folder JSON 对象:

{
    "guid": "dc74c06c-0818-46c3-b9cd-6f9666468d12",
    "type": "view",
    "role": "3d",
    "name": "Default",
    "status": "success",
    "camera": [
        -37.01164245605469,
        -573.8855590820312,
        10.432775497436523,
        -37.01164245605469,
        -101.42298889160156,
        10.432775497436523,
        0,
        -2.220446049250313e-16,
        1,
        1,
        0.785398006439209,
        1,
        0
    ],
    "useAsDefault": true,
    "hasThumbnail": "true",
    "children": [
        {
            "guid": "59d18972-95cb-4845-a116-55a92e3c7ac3",
            "type": "resource",
            "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bGt3ZWo3eHBiZ3A2M3g0aGwzMzV5Nm0yNm9ha2dnb2YyMDE3MDUyOHQwMjQ3MzIzODZ6L3JhY19iYXNpY19zYW1wbGVfcHJvamVjdC5ud2M/output/0/0_100.png",
            "role": "thumbnail",
            "mime": "image/png",
            "resolution": [
                100,
                100
            ]
        },
        {
            "guid": "14607723-303c-476a-ac39-8f66cac8f4bf",
            "type": "resource",
            "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bGt3ZWo3eHBiZ3A2M3g0aGwzMzV5Nm0yNm9ha2dnb2YyMDE3MDUyOHQwMjQ3MzIzODZ6L3JhY19iYXNpY19zYW1wbGVfcHJvamVjdC5ud2M/output/0/0_200.png",
            "role": "thumbnail",
            "mime": "image/png",
            "resolution": [
                200,
                200
            ]
        },
        {
            "guid": "d7fd06cb-4ef5-48df-9e27-297343bf107a",
            "type": "resource",
            "urn": "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bGt3ZWo3eHBiZ3A2M3g0aGwzMzV5Nm0yNm9ha2dnb2YyMDE3MDUyOHQwMjQ3MzIzODZ6L3JhY19iYXNpY19zYW1wbGVfcHJvamVjdC5ud2M/output/0/0_400.png",
            "role": "thumbnail",
            "mime": "image/png",
            "resolution": [
                400,
                400
            ]
        }
    ]
},
{
    "guid": "cccca659-8638-4e8d-9554-223f7cc4a23b",
    "type": "folder",
    "name": "3D View",
    "role": "viewable",
    "hasThumbnail": "false",
    "status": "success",
    "progress": "0% complete",
    "children": [
        {
            "guid": "3dc842c3-acf9-4921-8d54-ffebf86500d1",
            "type": "view",
            "role": "3d",
            "name": "Kitchen",
            "camera": [
                -71.70982360839844,
                -77.9845199584961,
                4.921259880065918,
                10.964564323425293,
                -15.158869743347168,
                4.921259880065918,
                4.996003610813204e-16,
                -4.440892098500626e-16,
                1,
                1,
                0.9272952079772949,
                1,
                0
            ],
            "status": "success"
        },
        {
            "guid": "716c2341-af18-4866-9fb7-57a27ff811d3",
            "type": "view",
            "role": "3d",
            "name": "From Yard",
            "camera": [
                -98.73897552490234,
                -169.06787109375,
                0,
                -42.515201568603516,
                -44.77614212036133,
                -1.609189127435573e-14,
                0,
                1.1102230246251565e-16,
                1,
                1,
                0.9272952079772949,
                1,
                0
            ],
            "status": "success"
        },
        {
            "guid": "1466f07a-5536-4acd-bb51-ee228fb6a41e",
            "type": "view",
            "role": "3d",
            "name": "Living Room",
            "camera": [
                -31.575815200805664,
                -51.19736862182617,
                0.9842519760131836,
                38.432044982910156,
                -143.84164428710938,
                0.9842519760131836,
                -5.0237591864288333e-14,
                -3.735900477863652e-14,
                1,
                1,
                0.9272952079772949,
                1,
                0
            ],
            "status": "success"
        },
        {
            "guid": "68ffe8dc-9a9c-45a5-aaf5-29221dd38771",
            "type": "view",
            "role": "3d",
            "name": "Approach",
            "camera": [
                -41.0597038269043,
                38.65303039550781,
                32.80839920043945,
                -49.91415786743164,
                -107.17664337158203,
                9.272088050842285,
                -0.009639321826398373,
                -0.15875616669654846,
                0.9872707724571228,
                1,
                0.9272952079772949,
                1,
                0
            ],
            "status": "success"
        },
        {
            "guid": "4c8b4f68-7010-47eb-a3e3-3aa699e82674",
            "type": "view",
            "role": "3d",
            "name": "Section Perspective",
            "camera": [
                8.170970916748047,
                29.014333724975586,
                5.741469860076904,
                -82.0259780883789,
                -107.69042205810547,
                5.741469860076904,
                7.771561172376096e-16,
                2.914335439641036e-16,
                1,
                1,
                0.9272952079772949,
                1,
                0
            ],
            "status": "success"
        },
        {
            "guid": "33f941f3-81d1-41c5-82e5-346731d79f34",
            "type": "view",
            "role": "3d",
            "name": "Solar Analysis",
            "camera": [
                62.19073486328125,
                -142.4400634765625,
                161.65139770507812,
                -32.913902282714844,
                -97.60645294189453,
                8.838506698608398,
                -0.7451809644699097,
                0.3512883186340332,
                0.5668349266052246,
                1,
                45,
                273.4084777832031,
                1
            ],
            "status": "success"
        },
        {
            "guid": "41b33c50-bcdf-4f57-8101-5f8af6ece8eb",
            "type": "view",
            "role": "3d",
            "name": "{3D}",
            "camera": [
                -104.73332977294922,
                -202.08343505859375,
                67.68977355957031,
                -103.85852813720703,
                -103.78852081298828,
                5.5336480140686035,
                0.004756217356771231,
                0.5344184637069702,
                0.8452067375183105,
                1,
                45,
                424.3688049316406,
                1
            ],
            "status": "success"
        }
    ]
} 

现在我们使用 Kitchen 视图来说明工作流程:

{
    "guid": "3dc842c3-acf9-4921-8d54-ffebf86500d1",
    "type": "view",
    "role": "3d",
    "name": "Kitchen",
    "camera": [
        -71.70982360839844,
        -77.9845199584961,
        4.921259880065918,
        10.964564323425293,
        -15.158869743347168,
        4.921259880065918,
        4.996003610813204e-16,
        -4.440892098500626e-16,
        1,
        1,
        0.9272952079772949,
        1,
        0
    ],
    "status": "success"
} 

首先,让我们将其从原始模型 space 转换为查看者的:

const nwVP = JSON.parse( // the above JSON );
const camera = nwVP.camera;
const nwVPName = nwVP.name;

const placementWithOffset = viewer.model.getData().placementWithOffset;

const pos = new THREE.Vector3( camera[0], camera[1], camera[2] );
const target = new THREE.Vector3( camera[3], camera[4], camera[5] );
const up = new THREE.Vector3( camera[6], camera[7], camera[8] );
const aspect = camera[9];
const fov = camera[10] / Math.PI * 180;
const orthoScale = camera[11];
const isPerspective = !camera[12];

const offsetPos = pos.applyMatrix4( placementWithOffset );
const offsetTarget = target.applyMatrix4( placementWithOffset );

const nwSavedViewpoints = [];
nwSavedViewpoints.push(
    {
        aspect: aspect,
        isPerspective: isPerspective,
        fov: fov,
        position: offsetPos,
        target: offsetTarget,
        up: up,
        orthoScale: orthoScale,
        name: nwVPName
    }
);

之后,通过

切换视角
viewer.impl.setViewFromCamera( nwSavedViewpoints[0] );

最后,您可能会注意到上面转换后的相机定义将具有与 viewer.model.getData().cameras[1]

几乎相同的值(浮动精度问题)

希望对您有所帮助!

干杯,

分段映射更新

如果您保存的视点包含剖面,GET:urn/manifest 的响应将如下所示:

{
    "guid": "54794b24-d9ef-4a1a-b5aa-8bbf35de2c55",
    "type": "view",
    "role": "3d",
    "name": "Section Test",
    "camera": [
        -264.2721252441406,
        -79.92520141601562,
        148.0021209716797,
        -42.678688049316406,
        -73.8739013671875,
        0.7752543091773987,
        0.5530436635017395,
        0.01510258112102747,
        0.8330153822898865,
        1.4948216676712036,
        0.785398006439209,
        1,
        0
    ],
    "sectionPlane": [
        -0.803684066258349,
        -0.5950562340169588,
        0,
        -92.04215879314862
    ],
    "status": "success"
} 

sectionPlane属性就是我们要的目标。因此,转换为

const forge_model_offset = viewer.model.getData().globalOffset;

// assume the param of Navisworks clip plane is available
//I copied from the response of the GET:urn/manifest
const navis_clip_plane = { x: -0.803684066258349, y: -0.5950562340169588, z: 0,d:-92.04215879314862 };

//calculate exact distance in Forge Viewer
const dis_in_forge =( forge_model_offset.x * navis_clip_plane.x  +   
                        forge_model_offset.y * navis_clip_plane.y + 
                        forge_model_offset.z * navis_clip_plane.z) + navis_clip_plane.d;

const cutplanes = [
    new THREE.Vector4( navis_clip_plane.x, navis_clip_plane.y, navis_clip_plane.z, dis_in_forge ) 
];

//apply the plane to sectioning
viewer.setCutPlanes( cutplanes )