| Calculator API URL | https://calculator.measuresquare.com/public/calculator |
| Name | Type | Description |
|---|---|---|
| apiKey | string | Please contact Allen Wang, api@measuresquare.com to get your Publishable API key for your application integration authorization. |
| Name | Type | Description |
|---|---|---|
| measureSystem | string | The measure system of calculator, value: Imperial | Metric |
| imageWidth | int | The pixel of generated image width, value: 512 ~ 2048, default: 1024 |
| modelScript | string | The xml formate of estimate models, include floorproduct&rooms informations |
<M2Script Direction="Vertical" CutMargin="0'3"" MaxTSeamCount="2" GroutWidth="0.25"">
<FloorProduct Type="Carpet" ID="carpet" Width="12'0"" Length="150'0"" HoriRepeat="0'0"" VertRepeat="0'0"" HoriDrop="0'0"" VertDrop="0'0""/>
<RectRoom RoomName="room 1" LayoutDirection="0" Width="13'0"" Length="15'0"" />
<RectRoom RoomName="room 2" Width="13'0"" Length="15'0"" />
<Stairway CoveringStyle="Waterfall" StairName="stair 1" >
<StairUnit UnitStyle="Regular" StepCount="8" StairWidth="3'0"" TreadWidth="0'11"" RiseHeight="0'7"" />
<StairUnit UnitStyle="RightAngleTurnArc"/>
<StairUnit UnitStyle="Regular" StepCount="8" StairWidth="3'0"" TreadWidth="0'11"" RiseHeight="0'7"" />
</Stairway>
<FloorProduct Type="Tile" ID="tile" Width="2'0"" Length="2'0"" TileCalcMethod="WasteAddon" WasteAddon="0%" />
<RectRoom RoomName="room 3" Width="15'0"" Length="18'0"" />
<PolygonRoom Roomname="room 4" Points="0,2438.40|2438.40,2438.40|2438.40,6096.00|6096.00,6096.00|6096.00,8534.40|0,8534.40" />
</M2Script>
| Note | Description |
|---|---|
|
Atrribute in red
|
Atrribute in red color is a enumerator M2Script -> Direction: Auto | Horizontal | Vertical
FloorProduct -> Type: Carpet | Tile | Hardwood | Laminate | Vinyl | CarpetTile | VinylTile
Stairway -> CoveringStyle: Waterfall | TreadAndRise | TreadOnly | RiseOnly | Fullwrap
StairUnit -> UnitStyle: Regular | RightAngleLanding | StraightLanding | RightAngleTurn |
RightAngleLandingArc | StraightLandingArc | RightAngleTurnArc
|
| Atrribute in blue |
Atrribute in blue color is optional M2Script Node:GroutWidth default is 0.25" CutMargin default is 3" MaxTSeamCount default is 2 RectRoom | PolygonRoom Node: LayoutDirection The rotation angle of the layout, measured in degrees. Valid range: 0 to 360. When set, this value overrides the direction specified by the M2Script node. 0 or 180: Horizontal 90 or 180: Vertical FloorProduct Node: Tile | VinylTile | CarpetTile: TileCalcMethod WasteAddon | HalfReuse | CutAndFit, default is WasteAddon StartPoint Center | Top-Left | Top-Right | Bottom-Left | Bottom-Right, default is Center Carpet | Vinyl : HoriRepeat/VertRepeat/HoriDrop/VertDrop default is 0'0" Tile | VinylTile | CarpetTile | Hardwood | Laminate: WasteAddon default is 0% |
| If Multiple Floor Product | Room/shape will use the recent floor product in front. |
| PolygonRoom -> Points |
Points= "0,2438.40|2438.40,2438.40|2438.40,6096.00|6096.00,6096.00|6096.00,8534.40|0,8534.40"
Anticlockwise, each point split by |, can display room in any shape(include L-shape)
1(ft) = 304.8, 1(in) = 25.4
2438.40 = 8(ft), 6096.00 = 20(ft), 8534.40 = 28(ft)
|
{
"ImageBase64String":"{base64ImageString}",
"ProductEstimates": [
{
"ID": "carpet",
"ShapeQty": "53.48",
"Usage": "59.75",
"TileCount": null,
"BoxCount": 0,
"BoxedUsage": "59.75"
},
{
"ID": "Grout 3\"",
"ShapeQty": "25.807",
"Usage": "25.807",
"TileCount": null,
"BoxCount": 0,
"BoxedUsage": "25.807"
},
{
"ID": "tile",
"ShapeQty": "415.60",
"Usage": "415.60",
"TileCount": 104,
"BoxCount": 0,
"BoxedUsage": "415.60"
}]
}
string url = "https://calculator.measuresquare.com/public/calculator";
XElement rootElement = new XElement("M2Script", new XAttribute("Direction", "Auto"), new XAttribute("GroutWidth", "0.25\""));
rootElement.Add(new XElement("FloorProduct", new XAttribute("Type", "Carpet"), new XAttribute("ID", "carpet"),
new XAttribute("Width", "12'0\""), new XAttribute("Length", "150'0\"")));
rootElement.Add(new XElement("RectRoom", new XAttribute("RoomName", "room 1"), new XAttribute("LayoutDirection", "0")
new XAttribute("Width", "13'0\""), new XAttribute("Length", "15'0\"")));
rootElement.Add(new XElement("RectRoom", new XAttribute("RoomName", "room 2"),
new XAttribute("Width", "13'0\""), new XAttribute("Length", "15'0\"")));
rootElement.Add(new XElement("Stairway", new XAttribute("CoveringStyle", "Waterfall"), new XAttribute("StairName", "stair 1"),
new XElement("StairUnit", new XAttribute("UnitStyle", "Regular"), new XAttribute("StepCount", "8"),
new XAttribute("StairWidth", "3'0\""), new XAttribute("TreadWidth", "0'11\""),
new XAttribute("RiseHeight", "0'7\"")),
new XElement("StairUnit", new XAttribute("UnitStyle", "RightAngleTurnArc")),
new XElement("StairUnit", new XAttribute("UnitStyle", "Regular"), new XAttribute("StepCount", "8"),
new XAttribute("StairWidth", "3'0\""), new XAttribute("TreadWidth", "0'11\""),
new XAttribute("RiseHeight", "0'7\""))));
rootElement.Add(new XElement("FloorProduct", new XAttribute("Type", "Tile"), new XAttribute("ID", "tile"),
new XAttribute("Width", "2'0\""), new XAttribute("Length", "2'0\"")));
rootElement.Add(new XElement("RectRoom", new XAttribute("RoomName", "room 3"),
new XAttribute("Width", "15'0\""), new XAttribute("Length", "18'0\"")));
rootElement.Add(new XElement("PolygonRoom", new XAttribute("RoomName", "room 4"),
new XAttribute("Points", "0,2438.40|2438.40,2438.40|2438.40,6096.00|6096.00,6096.00|6096.00,8534.40|0,8534.40")));
Dictionary<string, object> postObj = new Dictionary<string, object>();
postObj.Add("measureSystem", "Imperial");
postObj.Add("imageWidth", 1024);
postObj.Add("modelScript", rootElement.ToString());
using (HttpClient client = new HttpClient()){
client.DefaultRequestHeaders.Add("apiKey", "Your Publishable API Key");
using (HttpResponseMessage response = await client.PostAsJsonAsync(url, postObj))
{
if (response.StatusCode == HttpStatusCode.OK)
{
//response.Content see Response section
}
}
}