Get plan estimation

Example how to receive project data from Roomtodo planner:

<iframe
    frameborder="0"
    id="iframe"
    src="https://example.com/planner/matconfig">
</iframe>

<script>

window.addEventListener("message", messageListener);

function messageListener(e) {
    try {
        const dataObj = JSON.parse(e.data);
        if (dataObj.action === "got_estimation") {
            let projectData = dataObj.data;
        }
    } catch (error) {
        console.error("Error parse JSON string!");
    }
}
</script>

This data sends to the client every time when one of the described below values changes, and config param is enabled enable_estimation

1878

*But if you want an additional trigger for this event, use this code:

iframeRoomtodo.contentWindow.postMessage(`{"action": "get_estimation"}`, '*');

Example of project object-data:

{
    "rooms": [
        {
            "area": 41.2323,
            "perimeter": 26.48,
            "name": "Room",
            "wallsArea": 74.144,
            "width": 5.388583393241261,
            "length": 7.651788418402589
        }
    ],
    "wallsHeight": 2.8,
    "walls": {
        "materialsCeiling": [
            {
                "material_id": "0",
                "addMaterial_id": "",
                "value": 41.2323
            }
        ],
        "materialsFloor": [
            {
                "material_id": "0",
                "addMaterial_id": "",
                "value": 41.2323
            }
        ],
        "materialsWall": [
            {
                "material_id": "2013",
                "addMaterial_id": "",
                "value": 37.072
            },
            {
                "material_id": "3269",
                "addMaterial_id": "",
                "value": 23.044
            },
            {
                "material_id": "#24aa3a",
                "addMaterial_id": "32754",
                "value": 14.028
            }
        ],
        "plinths": [
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.3006,
                "type": "bottomPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.1503,
                "type": "topPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#44aa7f",
                "addMaterialID": "32765",
                "area": 0.4938,
                "type": "bottomPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.2469,
                "type": "topPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.3006,
                "type": "bottomPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.1503,
                "type": "topPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.4938,
                "type": "bottomPlinth",
                "shapeNum": 0
            },
            {
                "materialID": "#ffffff",
                "addMaterialID": "",
                "area": 0.2469,
                "type": "topPlinth",
                "shapeNum": 0
            }
        ]
    },
    "products": [
        {
            "model_id": "898",
            "name": "Bed",
            "width": 201,
            "height": 109,
            "depth": 212,
            "geometries": [
                {
                    "name": "mesh_0",
                    "material_id": "#aa1f7f",
                    "addMaterial": "32755"
                },
                {
                    "name": "mesh_1",
                    "material_id": "2014",
                    "addMaterial": ""
                }
            ]
        }
    ]
}

Description of file with project details

  • rooms - list with information about every room in the project
    • name - name of the room
    • area - area of the room
    • perimeter - perimeter of the room
    • wallsArea - area of walls. The area of windows and doors is subtracted from this value
    • width, length - rectangular sizes of room
200
  • walls - information about walls in the project
    • wallsHeigt - the height of walls in the project
    • materialsWall - an object that contains information about materials applied to walls. Such as material ID, additional material ID(if color-picker with material was used) and the area covered by this material.
    • materialsFloor - information about materials applied to the floor. It is similar to materialsWall
    • materialsCeiling - information about materials applied to the ceiling. It is similar to materialsWall
    • plinths - an array that contains information about every plinth and molding.
      • materialID - material ID applied to this plinth/molding.
      • addMaterialID - additional material ID(if color-picker with material was used) applied to this plinth/molding.
      • area - area of this plinth/molding.
      • type - type of this part of the wall (topPlinth: molding, bottomPlinth: plinth)
      • shapeNum - type of this plinth/molding. Example for plinths:
260
  • products - list with information about every product/object/model in the project
    • model_id - ID of the product
    • name - name of the room
    • width - width of the product
    • height - height of the product
    • depth - depth of the product
    • geometries - object that contains information about materials applied to the products. It is similar to materialsWall