1

I would like to create a heatmap in Autodesk Platform Services (formerly forge) based on the following demo. https://github.com/autodesk-platform-services/aps-iot-extensions-demo

However, the heatmap is not showing up. enter image description here

The changes I made in the sample code are as follows,

1.Change the following parameters in /public/config.js

/public/config.js

    APS_MODEL_URN = 'URN' 
    APS_MODEL_VIEW = ''

URN obtained from "Translate a Revit File, Generating Room and Space Information (Reference:https://github.com/autodesk-platform-services/ aps-tutorial-postman/tree/master/ModelDerivative_07)"

2.Since there was no room information, define the following in /public/extensions/SensorHeatmapsExtension.js

3.Modified the location information of the four sensors in /services/iot.mocked.js so that they are placed inside the cube of the room.

/services/iot.mocked.js

const SENSORS = {
    'sensor-1': {
        name: 'sensor_1-1',// An ID to identify this device
        description: 'rack_1-1_Basic_sensor.',
        groupName: 'Level 2',
        location: {// World coordinates of this device
            x: 70,
            y: 0,
            z: -5
        },
        objectId: 1
    },
    'sensor-2': {
        name: 'sensor_1-2',
        description: 'rack_1-2_Basic_sensor.',
        groupName: 'Level 2',
        location: {
            x: 70,
            y: -30,
            z: -5
        },
        objectId: 2
    },
    'sensor-3': {
        name: 'sensor_1-3',
        description: 'rack_1-3_Basic_sensor.',
        groupName: 'Level 2',
        location: {
            x: 75,
            y: 0,
            z: -5
        },
        objectId: 3
    },
    'sensor-4': {
        name: 'sensor_1-4',
        description: 'rack_1-4_Basic_sensor.',
        groupName: 'Level 2',
        location: {
            x: 75,
            y: -30,
            z: -5
        },
        objectId: 4
    }
};

4.Fixed _setupSurfaceShadingw in /public/extensions/SensorHeatmapsExtension.js as follows

/public/extensions/SensorHeatmapsExtension.js

async _setupSurfaceShading(model) {
        if (!this.dataView) {
            return; }
        }
        
        const DataVizCore = Autodesk.DataVisualization.Core;
        const structureInfo = new DataVizCore.ModelStructureInfo(model);
        let levelRoomsMap = await structureInfo.getLevelRoomsMap();

        ///////////////2.room define///////////////
        let room_2 = new DataVizCore.Room(
            2222, //id Room's DbId
            "2F_Room",//name
            Box3(new THREE.Vector3(60, -40. -20), new THREE.Vector3(100, 10, 10))//bounds
        );

        for (const [sensorId, sensor] of this.dataView.getSensors().entries()) {
            if(sensor.objectId >= 1 && sensor.objectId <= 4){
                room_2.addDevice(sensor);
            }
        }        

        levelRoomsMap.addRoomToLevel("Level 2", room_2);

        /////////////// 4.SurfaceShading ///////////////
        const shadingGroup = new DataVizCore.SurfaceShadingGroup('iot-heatmap');
        const rooms = new Map();

        for (const [sensorId, sensor] of this.dataView.getSensors().entries()) {
            if (!sensor.objectId) {
                continue;
            }
            if (!rooms.has(room_2.id)) {        
                const room = new Autodesk.DataVisualization.Core.SurfaceShadingNode(room_2.name, room_2.id);
                shadingGroup.addChild(room);
                rooms.set(room_2.id, room);
            }
            const room = rooms.get(room_2.id);
            const types = Array.from(this.dataView.getChannels().keys());
            room.addPoint(new Autodesk.DataVisualization.Core.SurfaceShadingPoint(sensorId, sensor.location, types));
        }
        this._surfaceShadingData = new DataVizCore.SurfaceShadingData();
        this._surfaceShadingData.addChild(shadingGroup);
        this._surfaceShadingData.initialize(model);        
        await this._dataVizExt.setupSurfaceShading(model, this._surfaceShadingData);
        //this._dataVizExt.registerSurfaceShadingColors('temp', [0x00ff00, 0xffff00, 0xff0000]);
    }
y.hosokawa
  • 23
  • 5
  • did you confirm rooms generated by running this code in console? NOP_VIEWER.search('Revit Rooms', ids => { console.log('Room volume object IDs', ids); }, err => { console.error(err); }, ['Category'], { searchHidden: true }); – varunpatil Apr 13 '23 at 05:01
  • No, I could not confirm it like the sample rvt file posted on github. We were able to define the room in revit and reflect the heatmap. It is unfortunate that we could not define the room information only with aps-iot-extensions-demo. – y.hosokawa Apr 24 '23 at 05:11
  • it requires some extra work, use tools like postman and oss-manager.autodesk.io – varunpatil Apr 24 '23 at 14:45

0 Answers0