import areaPolygon from "area-polygon"; import { Area, Hole, Panel } from "../../class/export"; import { CommonFunctions, GeometryUtils } from "../../utils/export"; import { extractFeetAndUnitShow } from "../../utils/functions"; import { getDoorDescription, getwindowDescription } from "./view"; export function getPanelSchedule(scene, layerID) { let getPanelGroupInformation = Panel.getPanelGroupInformation(scene, layerID); getPanelGroupInformation = getPanelGroupInformation.filter((p) => !(p.mark.startsWith('W'))) getPanelGroupInformation = _.orderBy(getPanelGroupInformation, ['mark'], ['asc']); let panelGroup = _.groupBy(getPanelGroupInformation, (p) => [ p.desc ]) let newPanelSchedule = []; newPanelSchedule = Object.keys(panelGroup).map((each) => { each = panelGroup[each]; let newData = { panels: each[0].panels.length > 1 ? each[0].panels.length : each.length, mark: each.map((mapItem) => mapItem.mark).join(","), desc: each[0].desc }; return newData; }) return (getPanelGroupInformation) ? newPanelSchedule : []; } export function getTrackSchedule(scene, layerID, type = 'floortrack') { let layer = scene.getIn(['layers', layerID]); let tracks = layer.getIn(['panels']).filter((p) => p.type == type); let roof = layer.getIn(['items']).filter((i) => (['bDeck', 'genericRoofDeck', 'panelizedRoofDeck'].includes(i.type))) if (layer.getIn(['buildingSettings', 'drawing_setting_system']) == 4 && roof.size) { if (type == 'topcap') { tracks = tracks.filter((t) => { let tLine = layer.getIn(['lines', t.line]); if (tLine.type == 'interiorWall' || tLine.properties.getIn(['type']) && tLine.properties.getIn(['type']) == 'up-under') { return true; } else return false; }) } } let floorTrackGroupedArray = _.groupBy(tracks.toArray(), (p) => { let line = layer.getIn(['lines', p.line]); let trackCutType = p.properties.getIn(['type']); let startCut = Panel.trackDetectSide(p, layer, 'L').side; let endCut = Panel.trackDetectSide(p, layer, 'R').side; let trackStart = 'LS'; let trackEnd = 'RS'; if(line){ if (!line.inverted) { [startCut, endCut] = [endCut, startCut]; if (trackCutType == 'L') trackCutType = 'R'; else if (trackCutType == 'R') trackCutType = 'L'; } if (['L', 'B'].includes(trackCutType)) { trackStart = ((!startCut && line.inverted) || (!line.inverted && startCut)) ? 'LD' : 'LU'; } if (['R', 'B'].includes(trackCutType)) { trackEnd = ((!endCut && line.inverted) || (!line.inverted && endCut)) ? 'RD' : 'RU'; } } return [ trackStart, trackEnd, Math.round(p.properties.getIn(['width', 'length'])), ] }) let floorTrackSchedule = [] let mark = 'A'; let trackStartIndex = 0; if (type == 'topcap') { trackStartIndex = 1; } else if (type == 'roofFascia') { trackStartIndex = 4; } Object.keys(floorTrackGroupedArray).forEach((a, index) => { let floorTrack = floorTrackGroupedArray[a][0]; let line = layer.getIn(['lines', floorTrack.line]); let trackCutType = floorTrack.properties.getIn(['type']); let newTrack = {}; let size = extractFeetAndUnitShow(floorTrack.properties.getIn(['width', 'length']), true).label; mark = (index == 0) ? mark : String.fromCharCode(mark.charCodeAt(0) + 1); let trackMark = (trackStartIndex) ? mark + (trackStartIndex) : mark; newTrack.mark = trackMark; newTrack.size = size; newTrack.panels = floorTrackGroupedArray[a].map((p) => p.id); newTrack.desc = a; newTrack.left = a.split(',')[0] newTrack.right = a.split(',')[1]; floorTrackSchedule.push(newTrack); }) return floorTrackSchedule; } export function getWireSchedule(scene, layerID, catalog) { //breakerInfo: {breakerBoxId: "kSQRKwP9-", breakerId: 1} let layer = scene.getIn(['layers', layerID]); let wireSegments = layer.getIn(['items']).filter((p) => p.type == 'wireSegment'); let wireSchedule = []; let wireSegmentsGroup = _.groupBy(wireSegments.toArray(), (p) => [ p.properties.getIn(['breakerInfo']), ]) let wireGroupArray = [] Object.keys(wireSegmentsGroup).forEach((groupKey) => { let firstItem = wireSegmentsGroup[groupKey][0]; let breakerID = firstItem.properties.getIn(['breakerInfo', 'breakerId']); let breakerBoxId = firstItem.properties.getIn(['breakerInfo', 'breakerBoxId']); let breakerBox = layer.getIn(['holes', breakerBoxId]); let mark = breakerID; if (breakerBox.properties.getIn(['breakers']).find((b) => b.get('id') == breakerID).get('breakerPair')) { mark += '/' + breakerBox.properties.getIn(['breakers']).find((b) => b.get('id') == breakerID).get('breakerPair'); } wireGroupArray.push({ qty: wireSegmentsGroup[groupKey].length, mark: mark, items: wireSegmentsGroup[groupKey].map((p) => p.id) }) }) wireSegments.toArray().forEach((w, key) => { let wireData = {}; wireData.id = w.id; let findWireGroup = wireGroupArray.find((x) => x.items.includes(w.id)); let markIndex = 0; wireData.mark = key + 1 if (findWireGroup) { markIndex = findWireGroup.items.findIndex((x) => x.includes(w.id)) + 1; wireData.mark = findWireGroup.mark + '-' + markIndex; } let partNumberArray = catalog.getElement(w.type).getPartNumber(catalog, w, layer, scene); if (partNumberArray.length) { wireData.partNumber = partNumberArray[0].partno; } wireSchedule.push(wireData); }) return wireSchedule; } export function getWallSupportColumnSchedule(scene, layerID, catalog) { let wallSupportData = []; let layer = scene.getIn(['layers', layerID]); let wallSupportColumns = layer.holes.filter(i => (i.type == 'wallsupportcolumn')); if (wallSupportColumns.size) { let wallSupportGroup = _.groupBy(wallSupportColumns.toArray(), (p) => [ Math.round(p.properties.getIn(['height', 'length'])), ]) Object.keys(wallSupportGroup).forEach(function (groupKey) { let firstItem = wallSupportGroup[groupKey][0]; let height = firstItem.properties.getIn(['height', 'length']); let desc = 'Columns @ ' + extractFeetAndUnitShow(height, true).label wallSupportData.push({ qty: wallSupportGroup[groupKey].length, desc: desc, items: wallSupportGroup[groupKey].map((p) => p.id) }) }) } return wallSupportData; } export function getSinglePlywoodScedule(scene, layerID, catalog) { let plywoodData = []; let layer = scene.getIn(['layers', layerID]); let plywoods = layer.items.filter(i => (i.type == 'singlePlywood')); if (plywoods.size) { let plywoodGroup = _.groupBy(plywoods.toArray(), (p) => [ Math.round(p.properties.getIn(['thickness', 'length'])), Math.round(p.properties.getIn(['width', 'length'])), Math.round(p.properties.getIn(['height', 'length'])), ]) Object.keys(plywoodGroup).map(function (groupKey) { let firstPlywood = plywoodGroup[groupKey][0]; let width = firstPlywood.properties.getIn(['width', 'length']); let height = firstPlywood.properties.getIn(['height', 'length']); let thickness = firstPlywood.properties.getIn(['thickness', 'length']); let desc = extractFeetAndUnitShow(thickness, true).label + ' X ' + extractFeetAndUnitShow(width, true).label + ' X ' + extractFeetAndUnitShow(height, true).label plywoodData.push({ qty: plywoodGroup[groupKey].length, desc: desc, items: plywoodGroup[groupKey].map((p) => p.id) }) }) } return plywoodData; } export function getRoofingSchedule(scene, layerID, catalog) { let roofingData = []; let layer = scene.getIn(['layers', layerID]); let includedRoofs = ['genericRoofDeck', 'panelizedRoofDeck', 'bDeck'] let roofings = layer.items.filter(roof => (includedRoofs.includes(roof.type))); let roofingCountArray = []; if (roofings) { let roofdeckDescription = ""; roofings.map(roofing => { roofdeckDescription = roofing.name; let rotation = roofing.properties.get('rotate'); let selectedVertices = null; if (rotation == 'vertical') { selectedVertices = roofing.verticalVertices; } else if (rotation == 'horizontal') { selectedVertices = roofing.horizontalVertices; } selectedVertices.map(vertices => { let distance = GeometryUtils.pointsDistance(vertices.x1, vertices.y1, vertices.x2, vertices.y2); if (!roofingCountArray[distance]) { roofingCountArray[distance] = 0; } roofingCountArray[distance] += 1; }) }) Object.keys(roofingCountArray).map(function (roofKey) { roofingData.push({ qty: roofingCountArray[roofKey], mark: roofingCountArray[roofKey], size: extractFeetAndUnitShow(roofKey, true).label, description: roofdeckDescription }) }) } return roofingData; } export function getCeilingSchedule(scene, layerID, catalog) { let ceilingData = []; let layer = scene.getIn(['layers', layerID]); let ceiling = layer.items.filter(cc => cc.type == 'ceiling').map(ceiling => { if (ceiling) { let index =0; let width = ceiling.properties.get('width').get('length'); let height = ceiling.properties.get('height').get('length'); let rotation = ceiling.properties.get('rotate'); let gridStyle = ceiling.properties.get('gridStyle'); let gridLabel = (gridStyle == '2x2') ? "2' x 2'" : "2' x 4'"; let verticalLineGap = width; let horizontalLineGap = height; let horizontalVertices = ceiling.horizontalVertices; let verticalVertices = ceiling.verticalVertices; /** * ceiling main calculation calculate total length of vertical lines if vertical or if horizontal length * if horizontal is selected. * then divideby 12' since its ceiling main size is 12' * ceilingmainTotal * ceilingCount */ let CrossTQuantity=0; if (rotation == "vertical") { let distance = GeometryUtils.pointsDistance( horizontalVertices[0].x1, horizontalVertices[0].y1, horizontalVertices[0].x2, horizontalVertices[0].y2 ); if( gridStyle == "2x4"){ CrossTQuantity=horizontalVertices.length*(distance/121.92) }else{ CrossTQuantity=horizontalVertices.length*(distance/60.96) } }else{ let distance = GeometryUtils.pointsDistance( verticalVertices[0].x1, verticalVertices[0].y1, verticalVertices[0].x2, verticalVertices[0].y2 ); if( gridStyle == "2x4"){ CrossTQuantity=verticalVertices.length*(distance/121.92) }else{ CrossTQuantity=verticalVertices.length*(distance/60.96) } } let ceilingMainTotal = 0; let ceilingMainCount = 0; if (rotation == 'vertical') { verticalLineGap = width; horizontalLineGap = height; verticalVertices.map(verticalVertex => { let distance = GeometryUtils.pointsDistance(verticalVertex.x1, verticalVertex.y1, verticalVertex.x2, verticalVertex.y2); ceilingMainTotal += distance; }) } else if (rotation == 'horizontal') { verticalLineGap = height; horizontalLineGap = width; verticalVertices.map(horizontalVertex => { let distance = GeometryUtils.pointsDistance(horizontalVertex.x1, horizontalVertex.y1, horizontalVertex.x2, horizontalVertex.y2); ceilingMainTotal += distance; }) } ceilingMainCount = Math.ceil(ceilingMainTotal / 365.76); // let tileCount = 0; // let vertiLength = verticalVertices.length; // let horizonLength = horizontalVertices.length; // let WireClipCpunt = (vertiLength + horizonLength) * 2; // // let WireClipCpunt=0; // // WireClipCpunt += horizonLength * 2; // let crossT = 0; // verticalVertices.map((verticalVertex, VIndex) => { // for (var VIndex = 0; VIndex < vertiLength; VIndex++) { // let verticalVertex = verticalVertices[VIndex]; // // horizontalVertices.map((horizontalVertex, HIndex) => { // for (var HIndex = 0; HIndex < horizonLength; HIndex++) { // let horizontalVertex = horizontalVertices[HIndex]; // let cPoint = { x: verticalVertex.x1, y: horizontalVertex.y1 }; // if ((verticalVertex.y1 > cPoint.y && cPoint.y > verticalVertex.y2) && (horizontalVertex.x1 < cPoint.x && cPoint.x < horizontalVertex.x2)) { // tileCount++; // crossT++; // if (HIndex == horizonLength - 1) { //last horizontalLine // tileCount++; // } // if (VIndex == vertiLength - 1) { // tileCount++; // } // if (VIndex == vertiLength - 1 && HIndex == horizonLength - 1) { // tileCount++; // } // //wireclip calculation // if (VIndex % 2 == 0 && HIndex % 2 != 0) { // WireClipCpunt++; // } // } else { // } // } // } const feet_12 = 365.76; const feet_4 = 121.92; const INCH_6 = 15.24; if (rotation == "horizontal") { let temp = horizontalVertices; horizontalVertices = verticalVertices; verticalVertices = temp; } let tileCount = 0; //(verticalVertices.length + 1) * (horizontalVertices.length + 1); let vertiLength = verticalVertices.length; let horizonLength = horizontalVertices.length; let WireClipCpunt=0 WireClipCpunt += horizonLength * 2; let crossT = 0; verticalVertices.forEach((v, vIndex, vArray) => { let prevClipPoint = { x: v.x1, y: v.y1 }; horizontalVertices.forEach((h, hIndex, hArray) => { let intersection = GeometryUtils.twoLineSegmentsIntersection( { x: v.x1, y: v.y1 }, { x: v.x2, y: v.y2 }, { x: h.x1, y: h.y1 }, { x: h.x2, y: h.y2 } ); if (intersection.type == "intersecting") { let interSectedPoint = intersection.point; if ( Area.detectAreaId( scene, layer.id, interSectedPoint.x, interSectedPoint.y ).includes(ceiling.area) ) { tileCount++; crossT++; ///*****wire clip calculation */ let clipApartDist = GeometryUtils.verticesDistance( prevClipPoint, interSectedPoint ); if (hIndex == 0) { if (clipApartDist > INCH_6) WireClipCpunt++; WireClipCpunt++; prevClipPoint = interSectedPoint; } else { if ( Math.abs(clipApartDist - feet_4) <= 0.1 ) { WireClipCpunt++; prevClipPoint = interSectedPoint; } if (hArray.length - 1 == hIndex) { let lastClipDist = GeometryUtils.pointsDistance( prevClipPoint.x, prevClipPoint.y, v.x2, v.y2 ); if (lastClipDist > INCH_6) WireClipCpunt++; prevClipPoint = { x: v.x2, y: v.y2 }; } } /***************************** */ } } if (vArray.length - 1 == vIndex) tileCount++; if (hArray.length - 1 == hIndex) { tileCount++; if (vArray.length - 1 == vIndex) tileCount++; } }); }); ceilingData.push({ qty: tileCount, mark: 'C1', size: gridLabel, description: "Ceiling Tile" }); ceilingData.push({ qty: ceilingMainCount, mark: 'C2', size: "144\"", description: "Ceiling Main - 12 ft" }); ceilingData.push({ qty: Math.ceil(CrossTQuantity), mark: 'C3', size: "48\"", description: "Ceiling 4 Cross 'T'" }); ceilingData.push({ qty: WireClipCpunt, mark: 'C4', size: "", description: "Ceiling Cilp" }); // Update ceilingData for each element // let finalTileCount =+ tileCount; // console.log("finalTileCount",finalTileCount); // ceilingData[index] = { // qty: finalTileCount, // mark: 'C1', // size: gridLabel, // description: 'Ceiling Tile' // }; // ceilingData[index + 1] = { // qty: ceilingMainCount, // mark: 'C2', // size: '144"', // description: 'Ceiling Main - 12 ft' // }; // ceilingData[index + 2] = { // qty: (Math.ceil(CrossTQuantity)), // mark: 'C3', // size: '48"', // description: "Ceiling 4 Cross 'T'" // }; // ceilingData[index + 3] = { // qty: WireClipCpunt, // mark: 'C4', // size: '', // description: 'Ceiling Cilp' // }; let ceilingAngles = layer.panels.filter(item => item.type == 'ceilingAngle'); let ceilingAngleArray = []; let ceilingAngleArrayLabel = [] ceilingAngles.map(cAngle => { let width = cAngle.properties.get('width').get('length'); let defaultLength = 243.84; width = defaultLength; let widthLabel = extractFeetAndUnitShow(width) widthLabel = ""; if (!ceilingAngleArray[width]) { ceilingAngleArray[width] = []; ceilingAngleArrayLabel[width] = widthLabel.label; } ceilingAngleArray[width].push(cAngle) }) let i = 5; Object.keys(ceilingAngleArray).map(function (ceilingAngleArrayKey) { ceilingData.push({ qty: ceilingAngleArray[ceilingAngleArrayKey].length, mark: 'C' + i, size: ceilingAngleArrayLabel[ceilingAngleArrayKey], description: "Ceiling Angle" }); i++; }) let lightfixtures = layer.items.filter(item => item.type == 'lightfixtures'); let lightFixtureArray = [] let group = lightfixtures.reduce((r, a) => { r[a.properties.get('lighttype')] = [...r[a.properties.get('lighttype')] || [], a]; return r; }, {}); let l = 1; Object.keys(group).map((singleLight) => { let labelData = catalog.elements.lightfixtures.values.lighttype[singleLight].label; let singleDataProps = group[singleLight][0].properties; let sizeString = ''; sizeString += (singleDataProps.get('lightWidth').includes('02')) ? "2'" : "4'"; sizeString += " x "; sizeString += (singleDataProps.get('lightLength').includes('02')) ? "2'" : "4'"; ceilingData.push({ qty: group[singleLight].length, mark: 'L' + l, size: sizeString, description: labelData }); l++; }) let grillefixtures = layer.items.filter(item => item.type == 'ceilingGrille'); let grilleGroup = grillefixtures.reduce((r, a) => { r[a.properties.get('size')] = [...r[a.properties.get('size')] || [], a]; return r; }, {}); Object.keys(grilleGroup).map((singleGrille) => { let labelData = (singleGrille == 'SU') ? 'Supply Grille' : 'Return Grille'; let sizeString = "2' x 2'"; ceilingData.push({ qty: grilleGroup[singleGrille].length, mark: '', size: sizeString, description: labelData }); }) } // console.log("ceilingData",ceilingData); return ceilingData; }); return ceilingData; } export function getWindowSchedule(scene, layerID, catalog) { let getPanelGroupInformation = Panel.getPanelGroupInformation(scene, layerID); getPanelGroupInformation = getPanelGroupInformation.filter((p) => (p.mark.startsWith('W'))) getPanelGroupInformation = _.orderBy(getPanelGroupInformation, ['mark'], ['asc']); let windowGroup = _.groupBy(getPanelGroupInformation, (p) => [ p.mark ]) let newWindowsSchedule = []; newWindowsSchedule = Object.keys(windowGroup).map((each) => { each = windowGroup[each]; let newData = { qty: each.length, mark: each[0].mark, size:each[0].size, description:each[0].desc, }; return newData; }) // let windowsSchedule = []; // let windowTypes = ['window']; // let layer = scene.getIn(['layers', layerID]); // let windows = layer.holes.filter((window) => (windowTypes.includes(window.type))); // let windowMark = 1; // windows.map(window => { // let props = window.properties.toJS(); // let description = getwindowDescription(window); // // let functions = catalog.elements.window.values.function; // // let selectedFunction = ""; // // if (props.function) // // selectedFunction = functions[props.function]['label']; // // else // let data = { // qty: 1, // mark: "W" + windowMark, // size: props.size, // description: description, // }; // windowsSchedule.push(data); // windowMark++; // }) // let windowGroup = _.groupBy(windowsSchedule, (p) => [ // p.description // ]) // let newWindowsSchedule = []; // console.log(getPanelGroupInformation,"getPanelGroupInformation") // newWindowsSchedule = Object.keys(getPanelGroupInformation).map((each) => { // each = getPanelGroupInformation[each]; // let newData = { // qty: 0, // mark: each.map((mapItem) => mapItem.mark).join(","), // size: each[0].size, // // description: each[0].description // }; // each.forEach((x) => { // newData.qty += x.qty; // // newData.qty += x.qty; // }); // return newData; // }) return newWindowsSchedule ; } //schedule view table details shown about the doors export function getDoorSchedule(scene, layerID, catalog) { let doorsSchedule = []; let doorTypes = ['door', 'accordianDoor','rollupDoor'] let layer = scene.getIn(['layers', layerID]); let doors = layer.holes.filter((door) => (doorTypes.includes(door.type))); let doorMark = 10; doors.map(door => { let props = door.properties.toJS(); let description if(props.doorSlide){//only acordian door has doorslide property description = "Accordian Door" }else if(props.chainSide){// only rollup door has chainside property description = "Rollup Door" }else{//all other doors are filtered using doortype description = getDoorDescription(door); } let doorClose = props.doorCloser; //DoorCloser selection corrected if (props.doorCloser == 'Y'){ doorClose="Yes" } if (props.doorCloser == 'N'){ doorClose="None" } let colors = catalog.elements.door.values.doorColor; let selectedColor = props.doorColor; //first 4 conditions is for accordian door color to be shown on schedule view table about doors if(props.doorColor=='TN'&&props.doorSlide){ selectedColor="Solid Lam-Tan" }else if(props.doorColor=='WE'&&props.doorSlide){ selectedColor="Solid Lam-White" }else if(props.doorColor=='BK'&&props.doorSlide){ selectedColor="Solid Lam-Black" }else if(props.doorColor=='GR'&&props.doorSlide){ selectedColor="Solid Lam-Gray" }else if (colors[props.doorColor] && colors[props.doorColor]['label']) { selectedColor = colors[props.doorColor]['label']; } else if (props.doorColor == 'VW') { selectedColor = 'VW-White'; } else if(props.color == 'GR'){ selectedColor = 'Gray' } else if(props.color == 'WH'){ selectedColor = 'White' } //last 2 conditions is for rollup door color to be shown on schedule view table doors let functions = catalog.elements.door.values.function; let selectedFunction = ""; if (props.function) selectedFunction = functions[props.function]['label']; let handing = "" if(props.handling && props.handling != undefined){handing = props.handling + "-Hand"} else if (props.color){ if(props.chainSide == "L"){handing = "L" + "-Hand"} else if(props.chainSide == "R"){handing = "R" + "-Hand"} }else if (props.doorSlide){ if (props.doorSlide == "L"){ handing = "L" + "-Slide"} else if (props.doorSlide == "R"){ handing = "R" + "-Slide"} } let grade = " "; if (props.hardwareType && props.hardwareType!=""){ grade = "-"; }else{ grade = props.hardwareType; } let visionLiteOptions = catalog.elements.door.values.visionLiteActive; let selectedVisionLite = "No Vision Lite"; if (props.visionLiteActive) {selectedVisionLite = visionLiteOptions[props.visionLiteActive]['label'];} else { selectedVisionLite = "None"} let data = { qty: 1, mark: doorMark, size: props.doorSize, description: description, color: selectedColor, handing: handing, grade: grade, function: selectedFunction, visionLite: selectedVisionLite, doorCloser: doorClose, // kickPlate:"yes", // Gasket:"NO", // Sweep:props.doorShoe=="DS"?"yes":"No" }; if(props.color == 'GR' || props.color == 'WH'){ let doorW = props.doorWidth; let doorH = props.doorHeight; if(props.doorWidth < 10){ doorW = "0"+props.doorWidth; } if(props.doorHeight < 10){ doorH = "0"+props.doorHeight; } let sizeR = doorW + doorH; data.size = sizeR; } if (!!props.framedOpeningOnly === true) { data = { qty: 1, mark: doorMark, size: props.doorSize, description: description, color: '-', handing: '-', grade: '-', function: '-', visionLite: '-' }; } doorsSchedule.push(data); doorMark++; }) return (doorsSchedule) ? doorsSchedule : []; } export function getFlooringSchedule(scene, layerID, catalog) { let flooringSchedule = []; let layer = scene.getIn(['layers', layerID]); let floors = layer.getIn(['areas']).filter((a) => Area.findAreaSize(layer, a.id) > 0 && a.properties.getIn(['areaType']) == 'area' && a.properties.getIn(['texture']) != 'NONE') floors.forEach((floor) => { let areaSize = Area.findAreaSize(layer, floor.id); let texture = floor.properties.get('texture') let plankFloors = ['PFT', 'PFCO', 'PFBD']; let tileDesc = "NONE"; if (texture == "CSDG") tileDesc = "Box dark gray carpet"; else if (texture == "CSB") tileDesc = "Box blue carpet"; else if (texture == "CSLG") tileDesc = "Box light gray carpet"; else if (texture == "CSBR") tileDesc = "Box brown carpet"; else if (texture == "PFBD") tileDesc = "Plank bamboo dark carpet"; else if (texture == "PFCO") tileDesc = "Plank canadian oak carpet"; else if (texture == "PFT") tileDesc = "Plank teak carpet"; if (plankFloors.includes(texture)) { let tileQty = areaSize / 24 flooringSchedule.push({ qty: Math.ceil(tileQty), desc: tileDesc }); } else { let tileQty = areaSize / 53; flooringSchedule.push({ qty: Math.ceil(tileQty), desc: tileDesc }); } let doorsInArea = layer.getIn(['holes']).filter((h) => h.type == 'door') .filter((h) => { let hPosition = Hole.getHolePosition(scene, layerID, h.id); if (Area.detectAreaId(scene, layerID, hPosition.x, hPosition.y, true).includes(floor.id)) { return true; } }) if (doorsInArea && doorsInArea.size) flooringSchedule.push({ qty: doorsInArea.size, desc: "TRANSITION STRIPS" }); let covabase = floor.properties.get('covabase'); if (covabase) { let perimeter = 0; let floorVertices = floor.vertices.toArray(); floorVertices.reduce((prev, curr) => { let prevVertex = layer.getIn(['vertices', prev]); let currVertex = layer.getIn(['vertices', curr]); let length = GeometryUtils.verticesDistance(prevVertex, currVertex) perimeter += length; return curr; }, floorVertices[floorVertices.length - 1]) let perimeterInFeet = perimeter / 30.48; flooringSchedule.push({ qty: Math.ceil(perimeterInFeet / 120), desc: "ROLL GRAY COVE" }); flooringSchedule.push({ qty: Math.ceil(perimeterInFeet / 20), desc: "TUBE COVE ADHESIE" }); } }) let floorGroup = _.groupBy(flooringSchedule, (p) => [ p.desc ]) let newFloorSchedule = []; newFloorSchedule = Object.keys(floorGroup).map((each) => { each = floorGroup[each]; let newData = { qty: 0, desc: each[0].desc }; each.forEach((x) => { newData.qty += x.qty; }); return newData; }) return (newFloorSchedule) ? newFloorSchedule : []; } export function getGaurdRailSchedule(scene, layerID, catalog) { let layer = scene.getIn(['layers', layerID]); let railsAndPosts = layer.getIn(['items']).filter((i) => ['gaurdRailPost', 'gaurdRail'].includes(i.type)); railsAndPosts = railsAndPosts.map((each, key) => { let desc = ''; let qty = 1; if (each.type == 'gaurdRailPost') { let postSize = each.properties.getIn(['postsize']); let postType = each.properties.getIn(['postType']); desc = postSize + '" ' + postType.toUpperCase() + ' POSTS'; qty = 1; } else if (each.type == 'gaurdRail') { let findSmallPost = layer.getIn(['items']).find((i) => { if (i.type == 'gaurdRailPost' && each.items.includes(i.id) && i.properties.getIn(['postsize']) == 18) return true; }) if (!findSmallPost) { qty = 2; } desc = 'TG-' + each.properties.get('railsize') + ' ' + each.properties.get('railsize') + "' RAIL"; } return { qty: qty, desc: desc, type: each.type } }) let railGroup = _.groupBy(railsAndPosts.toArray(), (p) => [ p.desc ]) let newRailPostSchedule = []; newRailPostSchedule = Object.keys(railGroup).map((each) => { each = railGroup[each]; let newData = { qty: 0, desc: each[0].desc, type: each[0].type }; each.forEach((x) => { newData.qty += x.qty; }); return newData; }) newRailPostSchedule = _.orderBy(newRailPostSchedule, ['type']); return (newRailPostSchedule) ? newRailPostSchedule : []; } // export function getRacewaysSchedule(scene, layerID, catalog){ // let racewaysSchedule = []; // let layer = scene.getIn(['layers',layerID, "panels"]); // let raceways = layer.filter(rcw => rcw.type=='raceways'); // raceways.map((rcw) => { // let props = rcw.properties.toJS(); // let style = "RA1-1 Piece"; // if(props.style == "RA2") {style="RA2-2 Piece"} // let color = ""; // if(props.DeviceColor == "IV") { color = "IV-Ivory" } // else { color = "WH-White" } // let wiringOption = ""; // if(props.WiringOption == "P"){ wiringOption = "P-Raceway Pre-Wire" } // else if(props.WiringOption == "P1"){ wiringOption = "Prewire without box" } // else { wiringOption = "No Pre-wire" } // let data = { // qty:1, // style: style, // deviceStyle: props.dependentItems, // color: color, // wiringOPtion: wiringOption // } // racewaysSchedule.push(data); // }) // return (racewaysSchedule) ? racewaysSchedule : []; // } // export function getLightFixturesSchedule(scene, layerID, catalog){ // let lightFixturesSchedule = []; // let lightfixtures = ['lightfixtures', 'lightFixtureSurfaceMount'] // let layer = scene.getIn(['layers',layerID]); // let lightFixtures = layer.items.filter(lt => (lightfixtures.includes(lt.type))); // lightFixtures.map((lt) => { // let props = lt.properties.toJS(); // let description = "" // if(lt.type == "lightFixtureSurfaceMount"){ description = "1'X4' T8 Light Fixture"} // else if(props.lighttype == "AB"){ description = "2'X4' LED Light Fixture"} // else if(props.lighttype == "AH"){ description = "2'X2' LED Light Fixture"} // let data = { // qty:1, // description: description, // light: "Yes" // } // lightFixturesSchedule.push(data); // }) // let exitLightFixtures = layer.holes.filter(lt => lt.type == "exitLight"); // exitLightFixtures.map((lt) => { // let props = lt.properties.toJS(); // let light = ""; // if(props.light == "1"){ // light = "Yes" // }else{ light = "No"} // let data = { // qty:1, // description: "ExitLight", // light: light // } // lightFixturesSchedule.push(data); // }) // return (lightFixturesSchedule) ? lightFixturesSchedule : []; // } // export function getElectricalComponentsSchedule(scene, layerID, catalog){ // let electricalComponentsSchedule = []; // let layer = scene.getIn(['layers',layerID]); // let electricalComponents = layer.holes.filter(ec => ec.type == "breakerBox"); // electricalComponents.map((ec) => { // let props = ec.properties.toJS(); // let description = ""; // if(props.model == "1"){ description = "125 Amp 6 Space Load Center Single Phase"} // else if(props.model == "2"){ description = "125 Amp 12 Space Load Center Single Phase"} // else if(props.model == "3"){ description = "200A, 18 Space 120V Load center 3 Phase Interior"} // else if(props.model == "4"){ description = "125 Amp 24 Space Load Center Single Phase"} // else if(props.model == "5"){ description = "200A, 30 Space 120V Load center 3 Phase Interior"} // else if(props.model == "6"){ description = "200A, 42 Space 120V Load center 3 Phase Interior"} // let position = ""; // if(props.position == "inside") { position = "Inside"} // else if(props.position == "outside") { position = "outside"} // let data = { // qty:1, // description: description, // position: position // } // electricalComponentsSchedule.push(data); // }) // return (electricalComponentsSchedule) ? electricalComponentsSchedule : []; // } // export function getMechanicalSchedule(scene, layerID, catalog){ // let mechanicalSchedule = []; // let mechanicals = ['hvac', 'passThru', 'wallgrilles', 'hepafilters', 'ceilingGrille', 'magnehelicdifferentialpressure', 'manometer', 'hvac-window'] // let layer = scene.getIn(['layers',layerID]); // let mechanicalHoles = layer.holes.filter(mech => (mechanicals.includes(mech.type))).toJS(); // console.log("mechanicalHoles",mechanicalHoles); // mechanicalHoles.map((mech) => { // let props = mech.properties.toJS(); // let description = ""; // let type =''; // if(mech.type == "hvac"){ // description = "HVAC"; // type = ""; // } // else if(mech.type == "hvac-window"){ // description = "HVAC Window"; // type = ""; // } // else if( props.model == "NU"){ // description = "Wall Grill_X1"; // type = '18"x18" Grill' // }else if( props.model == "DG"){ // description = "Wall Grill_X2"; // type = '18"x18" Double Grill' // }else if( props.model == "QG"){ // description = "Wall Grill_X4"; // type = '18"x18" Quad Grill' // }else if( props.w_h_d == "24"){ // description = "PassThru"; // type = "24x24x24" // }else if( props.w_h_d == "30"){ // description = "PassThru"; // type = "30x30x30" // }else if( props.w_h_d == "36"){ // description = "PassThru"; // type = "36x36x24" // } // let data = { // qty:1, // description: description, // type: type // } // mechanicalSchedule.push(data); // }) // let mechanicalItems = layer.items.filter(mech => (mechanicals.includes(mech.type))); // mechanicalItems.map((mech) => { // let props = mech.properties.toJS(); // let description = ''; // let type =''; // if( props.size == "SU"){ // description = "Ceiling Air Grille"; // type = '24"x24" Supply' // }else if( props.size == "RE"){ // description = "Ceiling Air Grille"; // type = '24"x24" Return' // }else if ( mech.type == "magnehelicdifferentialpressure"){ // description = "Magnehelic Differential Pressure"; // type = ''; // }else if ( mech.type == "manometer"){ // description = "Manometer"; // type = ''; // }else if ( props.hepaType == "A"){ // description = "2'x4' Hepa Filter"; // type = "110V" // }else if ( props.hepaType == "B"){ // description = "2'x4' Hepa Filter"; // type = "220V" // } // let data = { // qty:1, // description: description, // type: type // } // mechanicalSchedule.push(data); // }) // return (mechanicalSchedule) ? mechanicalSchedule : []; // } // export function getExisistingElementsSchedule(scene, layerID, catalog){ // let exisistingElementsSchedule = []; // let exisistingElement = ['singledoor', 'doubledoor', 'windows', 'reactangle', 'circle']; // let layer = scene.getIn(['layers',layerID]); // let exisistingElements = layer.holes.filter(exis => (exisistingElement.includes(exis.type))); // exisistingElements.map((exis) => { // let props = exis.properties.toJS(); // let description = ""; // let data = {} // if (exis.type == "singledoor" || exis.type == "doubledoor"){ // if (props.doorType == "HCW38" || props.doorType == "HCW34"){ description = "HCW-Hollowcore Walnut Doors"} // else if (props.doorType == "HCO38" || props.doorType == "HCO34"){ description = "HCO-Hollowcore OAK Doors"} // else if (props.doorType == "HCX38" || props.doorType == "HCX34"){ description = "HCX-Flush Hollow Core Door"} // else if (props.doorType == "WX2"){ description = "Panel Hollow Core Door"} // else if (props.doorType == "VCG"){ description = "Vinyl Clad Gray Steel Doors"} // else if (props.doorType == "VCW"){ description = "Vinyl Clad White Steel Doors"} // data = { // qty:1, // description: description, // size: props.doorSize // } // } // if (exis.type == "windows"){ // data = { // qty:1, // description: "Window", // size: props.size // } // } // exisistingElementsSchedule.push(data); // }) // let exisistingElementss = layer.items.filter(exis => (exisistingElement.includes(exis.type))); // exisistingElementss.map((exis) => { // let props = exis.properties.toJS(); // let description = ''; // let size =''; // if (exis.type == "reactangle"){ // description = "Existing column"; // size = props.height+'"'+"X"+props.length+'"'+"X"+props.width+'"'; // } // else if (exis.type == "circle"){ // description = "Circle"; // size = props.height+'"'+"X"+props.radius*2+'"'; // } // let data = { // qty:1, // description: description, // size: size // } // exisistingElementsSchedule.push(data); // }) // return (exisistingElementsSchedule) ? exisistingElementsSchedule : []; // } // export function getCutoutSchedule(scene, layerID, catalog){ // let cutoutSchedule = []; // let layer = scene.getIn(['layers',layerID, "holes"]); // let cutout = layer.filter(cut => cut.type=='cutout'); // cutout.map((cut) => { // let props = cut.properties.toJS(); // let side; // if ( props.switchCutOutSide == "true"){ side = "Inside"} // else { side = "Outside"} // let data = { // qty:1, // size: (props.width.length/2.54)+'"'+"X"+(props.height.length/2.54)+'"', // side: side // } // cutoutSchedule.push(data); // }) // return (cutoutSchedule) ? cutoutSchedule : []; // } // export function getWallAccessoriesSchedule(scene, layerID, catalog){ // let wallAccessoriesSchedule = []; // let wallAccessoriess = ['mirror', 'wallHook', 'towel bar', 'standardBench', 'cornerBench'] // let layer = scene.getIn(['layers',layerID]); // let wallAccessories = layer.items.filter(wla => (wallAccessoriess.includes(wla.type))); // wallAccessories.map((wla) => { // let props = wla.properties.toJS(); // let description = "" // if(wla.type == "standardBench"){ description = "Standard Bench"} // else if ( wla.type == "cornerBench"){ description = "Corner Bench"} // let data = { // qty:1, // description: description // } // wallAccessoriesSchedule.push(data); // }) // let exitLightFixtures = layer.holes.filter(wla => (wallAccessoriess.includes(wla.type))); // exitLightFixtures.map((wla) => { // let props = wla.properties.toJS(); // let description = ""; // if ( wla.type == "mirror"){ description = "Mirror"} // else if ( wla.type == "wallHook"){ description = "Wall Hook"} // else if (wla.type == "towel bar"){ description = "Towel Bar"} // let data = { // qty:1, // description: description // } // wallAccessoriesSchedule.push(data); // }) // return (wallAccessoriesSchedule) ? wallAccessoriesSchedule : []; // }