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

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

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

Example of project object-data:

{
    "dimensionSystem": "cm",
    "projectId": 141287,
    "projectName": "House"
    "subProjects": [
        {
            "name": "First floor"
            "wallsHeight": 2.8,
            "products": [
                {
                    "id": "1",
                    "model_id": 2143,
                    "name": "Window",
                    "width": 215,
                    "height": 160,
                    "depth": 11,
                    "geometries": [
                        { "name": "mesh_0", "material_id": 1618, "addMaterial": "" },
                        { "name": "mesh_2", "material_id": "#ebebeb", "addMaterial": 32740 },
                    ]
                },
                {
                    "id": "2",
                    "model_id": 32108,
                    "name": "chair",
                    "width": 51,
                    "height": 82,
                    "depth": 58,
                    "geometries": [
                        { "name": "mesh_1", "material_id": 839, "addMaterial": "" },
                    ]
                },
            ],
            "rooms": [
                { 
                    "name": "Room",
                    "id": 2,
                    "area": 12.782,
                    "wallsArea": 40.152,
                    "perimeter": 14.34,
                    "width": 3.32,
                    "length": 3.85,
                    "materialsWall": [
                        { "material_id": "2013", "addMaterial_id": "", "value": 40.152 }
                    ],
                    "materialsFloor": [
                        { "material_id": "2525", "addMaterial_id": "", "value": 12.782 }
                    ],
                    "materialsCeiling": [
                        { "material_id": "2013", "addMaterial_id": "", "value": 12.782 }
                    ],
                    "bottomPlinths": [
                        {
                            "plinthShape": "32894",
                            "material_id": "#ffffff",
                            "addMaterial_id": "32770",
                            "length": 14.34
                        }
                    ],
                    "topPlinths": [
                        {
                            "plinthShape": "32901",
                            "material_id": "#ffffff",
                            "addMaterial_id": "32770",
                            "length": 14.34
                        }
                    ],                    
                    "wallsIdList": [ 6, 7, 8, 9 ],
                    "points": [
                        { "x": -21, "y": 229.5 },
                        { "x": 311, "y": 229.5 },
                        { "x": 311, "y": -155.5 },
                        { "x": -21, "y": -155.5 }
                    ],
                    "productsIdList": [ "1", "2" ]
                },
                {
                    "name": "Kitchen",
                    "id": 3,
                    ...............
                }
            ],
            "total": {
                "materialsCeiling": [
                    { "material_id": "2013", "addMaterial_id": "", "value": 18.326 }
                ],
                "materialsFloor": [
                    { "material_id": "2525", "addMaterial_id": "", "value": 18.326 }
                ],
                "materialsWall": [
                    { "material_id": "2013", "addMaterial_id": "", "value": 69.776 }
                ],
                "topPlinths": [
                    {
                        "plinthShape": "32901",
                        "material_id": "#ffffff",
                        "addMaterial_id": "32770",
                        "length": 24.920000000000005
                    }
                ],
                "bottomPlinths": [
                    {
                        "plinthShape": "32894",
                        "material_id": "#ffffff",
                        "addMaterial_id": "32770",
                        "length": 24.920000000000005
                    }
                ],
                "wallsList": [
                    {
                        "id": 6,
                        "material_id": "2013",
                        "addMaterial_id": "",
                        "value": 9.296,
                        "bottomPlinth": {
                            "plinthShape": 32894,
                            "material_id": "#ffffff",
                            "addMaterial_id": "32770",
                            "length": 3.32
                        },
                        "topPlinth": {
                            "plinthShape": 32901,
                            "material_id": "#ffffff",
                            "addMaterial_id": "32770",
                            "length": 3.32
                        }
                    },
                    {
                        "id": 7,
                        ...............
                    },
                    ...............
                ]
            },
        },
        {
            "name": "Second floor"
            "wallsHeight": 2.8,
            "products": [
                { ............... },
                { ............... }
            ],
            "rooms": [ ............... ],
            "total": { ............... }
        }
    ],
}

Description of file with project details

  • dimensionSystem - dimension system in the project
  • projectId - id of the project
  • projectName - name of the project
  • subProjects - array of floors
    • name - name of the floor
    • wallsHeight - the height of walls in the project
    • products - array of all products on this floor
      • id - id of the product. It is unique in the project.
      • model_id - id of the model
      • name - name of the model
      • width, height, depth - model dimensions
      • geometries - object that contains information about materials applied to the products
    • rooms - array of rooms on this floor
      • name - name of the room
      • id - id of the room
      • area - area of the room
      • wallsArea - area of walls. The area of windows and doors is subtracted from this value
      • perimeter - perimeter of the room
      • width, length - rectangular sizes of room
      • materialsWall - array of all different materials applied to walls in this room
        • material_id - material id
        • addMaterial_id - additional material id (if color-picker with material was used)
        • value - the total area of ​​the walls in this room that are covered with this material
      • materialsFloor - information about materials applied to the cover. It is similar to materialsWall
      • materialsCeiling - information about materials applied to the ceiling. It is similar to materialsWall
      • bottomPlinths - array that contains information about all different bottom plinths in this room
        • plinthShape - id of the plinth
        • material_id - material id
        • addMaterial_id - additional material id (if color-picker with material was used)
        • length- the total length of ​​the plinths with the same plinthShape and material id in this room
      • topPlinths - array that contains information about all different top plinths (moldings) in this room. It is similar to bottomPlinths
      • wallsIdList - array of ids of the walls forming this room. You can find information about each wall separately by its id in the array total --> wallsList
      • points - array of coordinates of the points forming the walls
      • productsIdList - array of ids of the products, placed in this room. You can find information about each product by its id in the array products
    • total - general information about the floor
      • materialsCeiling - array of all different materials applied to ceilings in this floor
      • materialsFloor - array of all different materials applied to cover in this floor
      • materialsWall - array of all different materials applied to walls in this floor
      • bottomPlinths - array that contains information about all different bottom plinths in this floor
      • topPlinths - array that contains information about all different top plinths in this floor
      • wallsList - array of information about each wall separately