public static void makeSurfaceOX() { bool boolFirstPass = false; timeBeg = DateTime.Now; Layer.manageLayers("SG-BRKLINE"); Layer.manageLayers("_YY-BLDG LIM"); SelectionSet objSSetBLDG_LIM = EW_Utility1.buildSSetBLDG_LIM(); //get _YY-BLDG LIM(s) SelectionSet objSSetFLOOR_SLAB = EW_Utility1.buildSSetFLOOR_SLAB(); //get _XX-FLOOR SLAB(s) if (objSSetBLDG_LIM.Count == 0) { // For i = 0 To objSSetFLOOR_SLAB.Count - 1 // // Set objFLOORSLAB = objSSetFLOOR_SLAB.Item(i) // strLayer = objFLOORSLAB.Layer // // objFLOORSLAB.Closed = False // Call forceClosed(objFLOORSLAB) // // varXDataVal = Empty // objFLOORSLAB.getXdata "OX", varXDataType, varXDataVal // // If Not IsEmpty(varXDataVal) Then // intBldgNo = varXDataVal(1) // Else // intBldgNo = i // End If // // Set objBldgOX2 = getBldgOX2(objFLOORSLAB, intBldgNo, "MAKE", strLayer) 'get BLDG OX limits // objBldgOX2.color = acMagenta // objBldgOX2.Lineweight = acLnWt100 // // If i = 0 Then // boolFirstPass = True // Else // boolFirstPass = False // End If // // Call modAdjacentAreas_Subtract(objBldgOX2, boolFirstPass) 'get modified areas adjacent to BLDG OX limits // // Next i Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("There are Zero BLDG LIMs - there needs to be one BLDG LIM for each Building. Exiting..."); return; //BLDG LIM exists } else { color = Misc.getColorByBlock(6); ObjectId[] ids = objSSetBLDG_LIM.GetObjectIds(); for (int i = 0; i < ids.Length; i++) { string strLayer = EW_Build3dPoly.getBldgLayer(ids[i]); //FOR EACH BLDG LIM GET CORRESPONDING FLOOR SLAB //as is will return last bldg area inside BLDG LIM if more than one FLOOR SLAB ObjectId idBldgOX2 = EW_GetBldgOX2.getBldgOX2(ids[i], 1, "MADE", strLayer); //get BLDG OX limits if ((idBldgOX2 == ObjectId.Null)) { return; } idBldgOX2.changeProp(LineWeight.LineWeight100, color); if (i == 0) { boolFirstPass = true; //FOR MULTIPLE BUILDINGS } else { boolFirstPass = false; } EW_ModAdjacentAreas.modAdjacentAreas_Subtract(idBldgOX2, boolFirstPass); //build modified areas adjacent to BLDG OX limits } // If objSSetBLDG_LIM.Count <> objSSetFLOOR_SLAB.Count Then // MsgBox "Number of Building Limit not equal to Number of FLOOR SLAB" // End If } SelectionSet ss = EW_Utility1.buildSSet22(); //OX-LIM-OUTER ObjectId[] idsOX_LIM_OUTER = ss.GetObjectIds(); for (int i = 0; i < idsOX_LIM_OUTER.Length; i++) { ObjectId idBldgOX2 = idsOX_LIM_OUTER[i]; Point3dCollection varPnts3d = idBldgOX2.getCoordinates3d(); ss = EW_Utility1.buildSSet21(varPnts3d); //get OX-AREAS-2d - inside OX limit for removal ObjectId[] idsAreas = ss.GetObjectIds(); for (int j = 0; j < idsAreas.Length; j++) { idsAreas[j].changeProp(LineWeight.LineWeight050, clr.red); idsAreas[j].delete(); //delete areas inside OX-LIM-OUTER } } ss = EW_Utility1.buildSSet19(); //get OX-AREAS-2d - select all ObjectId[] idsOX_AREAS_2d = ss.GetObjectIds(); for (int i = 0; i < idsOX_AREAS_2d.Length; i++) { ObjectId idLWPlineT = idsOX_AREAS_2d[i]; idLWPlineT.changeProp(LineWeight.LineWeight000, clr.wht); ResultBuffer rb = idLWPlineT.getXData("OX-Layer"); if (rb == null) { continue; } string strLayer = rb.AsArray()[1].Value.ToString(); color = Misc.getColorByBlock(140); ObjectId idLWPlineX = idLWPlineT.offset(-0.05); if (idLWPlineX == ObjectId.Null) { idLWPlineT.changeProp(LineWeight.LineWeight200, color); continue; } else { idLWPlineX.changeProp(LineWeight.LineWeight100, clr.mag); idLWPlineT.delete(); if (!offsetSegments("SG", "OX", idLWPlineX, strLayer)) { return; } } } viewResults("OX", true); if (!pub.boolDebug) { ss = EW_Utility1.buildSSetOX2d(); ss.eraseSelectedItems(); } ss = EW_Utility1.buildSSetLinesLayer0(); ss.eraseSelectedItems(); }
getBldgOX2(ObjectId idLWPline_LIM, int intBldgNo, string strOption, string strLayer) { bool exists; TinSurface surf = Surf.getTinSurface("CPNT-ON", out exists); TypedValue[] tvs = new TypedValue[3] { new TypedValue(1001, "OX"), new TypedValue(1000, intBldgNo), new TypedValue(1000, "OX0") }; Layer.manageLayers("OX-LIM-OUTER"); Layer.manageLayers("OX-AREAS-BLDG"); Layer.manageLayers("OX-AREAS-2d"); if (!idLWPline_LIM.isRightHand()) { idLWPline_LIM.reversePolyX(); } //BLDGOX0 Color color = Misc.getColorByBlock(7); ObjectId idBldgOX0 = ObjectId.Null; if (strOption == "MAKE") { Polyline objBldgOX0 = (Polyline)Misc.getBldgLimitsEW(idLWPline_LIM); //returns BldgOX0 2dPolyline idBldgOX0 = objBldgOX0.ObjectId; //outer limit of building footprint idBldgOX0.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); idBldgOX0.checkIfClosed(); if (!idBldgOX0.isRightHand()) { idBldgOX0.reversePolyX(); } idBldgOX0.setXData(tvs, "OX"); } else if (strOption == "MADE") { idBldgOX0 = idLWPline_LIM.copy("OX-AREAS-BLDG"); //limit of building footprint already made idBldgOX0.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); idBldgOX0.checkIfClosed(); if (!idBldgOX0.isRightHand()) { idBldgOX0.reversePolyX(); } idBldgOX0.setXData(tvs, "OX"); } //BLDGOX1 color = Misc.getColorByBlock(1); ObjectId idBldgOX1 = idBldgOX0.offset(EW_Pub.OX_LIMIT_H); //BldgOX1 2dPolyline idBldgOX1.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); //BLDGOX2 color = Misc.getColorByBlock(2); ObjectId idBldgOX2 = idBldgOX0.offset(EW_Pub.OX_LIMIT_H + 2); //BldgOX2 2dPolyline idBldgOX2.changeProp(color, "OX-LIM-OUTER", LineWeight.LineWeight020); SelectionSet objSSet = EW_Utility1.buildSSetGradingLim(); //GRADING LIMIT ObjectId idGradingLim = objSSet.GetObjectIds()[0]; int intSide = 0; if (idBldgOX1.isOutsideGradingLimit(idGradingLim)) { if (!idGradingLim.isRightHand()) { intSide = 1; } else { intSide = -1; } ObjectId idGradingLimOffset = idGradingLim.offset(0.2 * intSide); color = Misc.getColorByBlock(4); idGradingLimOffset.changeProp(LineWeight.LineWeight020, color); idBldgOX1 = EW_ModAdjacentAreas.modAdjacentOX_Intersect(idBldgOX1, idGradingLimOffset); //modified OX1 - portion was outside GRADING LIMIT color = Misc.getColorByBlock(1); idBldgOX1.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); tvs[2] = new TypedValue(1000, "OX1"); idBldgOX1.setXData(tvs, "OX"); idGradingLimOffset = idGradingLim.offset(0.1 * intSide); color = Misc.getColorByBlock(5); idGradingLimOffset.changeProp(LineWeight.LineWeight020, color); idBldgOX2 = EW_ModAdjacentAreas.modAdjacentOX_Intersect(idBldgOX2, idGradingLimOffset); //modified OX2 - portion was outside GRADING LIMIT color = Misc.getColorByBlock(2); idBldgOX2.changeProp(color, "OX-LIM-OUTER", LineWeight.LineWeight020); tvs[2] = new TypedValue(1000, "OX2"); idBldgOX2.setXData(tvs, "OX"); } else if (idBldgOX2.isOutsideGradingLimit(idGradingLim)) { if (!idGradingLim.isRightHand()) { intSide = 1; } else { intSide = -1; } ObjectId idGradingLimOffset = idGradingLim.offset(0.1 * intSide); color = Misc.getColorByBlock(4); idGradingLimOffset.changeProp(LineWeight.LineWeight020, color); idBldgOX2 = EW_ModAdjacentAreas.modAdjacentOX_Intersect(idBldgOX2, idGradingLimOffset); //modified OX2 - portion was outside GRADING LIMIT color = Misc.getColorByBlock(1); idBldgOX2.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); tvs[2] = new TypedValue(1000, "OX1"); idBldgOX1.setXData(tvs, "OX"); tvs[2] = new TypedValue(1000, "OX2"); idBldgOX2.setXData(tvs, "OX"); } else { tvs[2] = new TypedValue(1000, "OX1"); idBldgOX1.setXData(tvs, "OX"); tvs[2] = new TypedValue(1000, "OX2"); idBldgOX2.setXData(tvs, "OX"); } //BLDGOX3 ObjectId idBldgOX3 = ObjectId.Null; if (strOption == "MAKE") { ObjectId idBldgOXT = getOX_PadLim(idLWPline_LIM, idBldgOX0); //building footprint and outer limit of building footprint idBldgOX3 = idBldgOXT.offset(-EW_Pub.FOOTING_LIMIT_IN_H); color = Misc.getColorByBlock(3); idBldgOX3.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); idBldgOXT.delete(); tvs[2] = new TypedValue(1000, "OX3"); idBldgOX3.setXData(tvs, "OX"); } else if (strOption == "MADE") { idBldgOX3 = idBldgOX0.offset(-EW_Pub.FOOTING_LIMIT_IN_H); color = Misc.getColorByBlock(3); idBldgOX3.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); tvs[2] = new TypedValue(1000, "OX3"); idBldgOX3.setXData(tvs, "OX"); } //BLDGOX4 ObjectId idBldgOX4 = idBldgOX3.offset(-2); //BldgOX4 2dPolyline color = Misc.getColorByBlock(4); idBldgOX4.changeProp(color, "OX-AREAS-BLDG", LineWeight.LineWeight020); tvs[2] = new TypedValue(1000, "OX4"); idBldgOX4.setXData(tvs, "OX"); ObjectId idLine = ObjectId.Null; Handle h2d, h3d; double dblSlope, dblAngBase, dblAngTest; Point3d pnt3dCEN = Pub.pnt3dO, pnt3dTAR = Pub.pnt3dO, pnt3dX = Pub.pnt3dO; ObjectId idDict = Dict.getNamedDictionary("GRADEDOCK", out exists); if (!exists) { Point3d varPntCen = idLWPline_LIM.getCentroid(); // objLWPline_LIM.getXdata "BldgSlab", varXDataType, varXData // // Dim objBldgSlab As Polyline // Set objBldgSlab = clsdwg.thisdrawing.HandleToObject(varXData(1)) // Dim varPntsLWPline As Variant // varPntsLWPline = objBldgSlab.getCoordinates3d // Dim varPnts3dPoly As Variant // varPnts3dPoly = convert2dCoordsTo3dCoords(varPntsLWPline) // // // Dim varVector As Vector // varVector = getClosetAdjacentSegment(dPntCen, objBldgSlab) // MsgBox ("Direction to nearest segment is: " & varVector.Dir & _ //' vbCr & _ //' "Distance to nearest segment is: " & varVector.Dist) // // If isInside(varPntCen, varPnts3dPoly) = False Then // MsgBox "Calculated centroid location is outside limits of Building footprint" // Exit Function // End If double elevCen = surf.FindElevationAtXY(varPntCen.X, varPntCen.Y); //SURFACE = "CPNT-ON" double dblAngTar = 0; int intMark = 0; Geom.getEastWestBaseLineDir(idLWPline_LIM, ref dblAngTar, ref intMark); Point3d dPntTAR = varPntCen.traverse(dblAngTar, 20); double elevTar = surf.FindElevationAtXY(dPntTAR.X, dPntTAR.Y); dblSlope = System.Math.Round((elevTar - varPntCen.Z) / 20, 4); if (dblSlope == 0) { dPntTAR = varPntCen.traverse(dblAngTar + pi / 2, 20); elevTar = surf.FindElevationAtXY(dPntTAR.X, dPntTAR.Y); dblSlope = System.Math.Round((elevTar - varPntCen.Z) / 20, 4); if (System.Math.Round(dblSlope, 3) == 0) { dPntTAR = varPntCen.traverse(dblAngTar - pi / 2, 20); //back to original orientation elevTar = surf.FindElevationAtXY(dPntTAR.X, dPntTAR.Y); } } else if (dblSlope < 0) { dblAngTar = dblAngTar + pi; } dblAngBase = varPntCen.getDirection(dPntTAR); idLine = Draw.addLine(varPntCen, dPntTAR); EW_Dict.updateDictGRADEDOCK(idLWPline_LIM.getHandle(), "0".stringToHandle(), dblSlope, varPntCen, dPntTAR); //obj3dPoly.handle not pertinent at earthwork stage } else { EW_Dict.retrieveDictGRADEDOCK(out h2d, out h3d, out dblSlope, out pnt3dCEN, out pnt3dTAR); dblAngBase = pnt3dCEN.getDirection(pnt3dTAR); double dblLenBase = pnt3dCEN.getDistance(pnt3dTAR); Point3d varPntPolar = pnt3dCEN.traverse(dblAngBase, dblLenBase); idLine = Draw.addLine(pnt3dCEN, varPntPolar); } List <Point3d> varPntInt = idLine.intersectWith(idBldgOX0, extend.source); if (varPntInt.Count > 0) { for (int i = 0; i < varPntInt.Count; i++) { pnt3dX = varPntInt[i]; dblAngTest = pnt3dCEN.getDirection(pnt3dX); if (System.Math.Round(dblAngTest, 4) == System.Math.Round(dblAngBase, 4)) { idLine = Draw.addLine(pnt3dCEN, pnt3dX); pnt3dTAR = new Point3d(pnt3dX.X, pnt3dX.Y, pnt3dCEN.Z + pnt3dCEN.getDistance(pnt3dTAR) * dblSlope); } } } double elev = surf.FindElevationAtXY(pnt3dCEN.X, pnt3dCEN.Y); pnt3dCEN = new Point3d(pnt3dCEN.X, pnt3dCEN.Y, elev); double dblOffOX = EW_Pub.OUTER_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX"); color = Misc.getColorByLayer(); //OX1 ObjectId id3dPoly = EW_Build3dPoly.build3dPoly(idBldgOX1, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OX1", dblOffOX, 20); id3dPoly.changeProp(LineWeight.LineWeight050, color); varPntInt = idLine.intersectWith(idBldgOX2, extend.source); idLine.delete(); if (varPntInt.Count > 2) { for (int i = 0; i < varPntInt.Count; i++) { pnt3dX = varPntInt[i]; dblAngTest = pnt3dCEN.getDirection(pnt3dX); if (System.Math.Round(dblAngTest, 4) == System.Math.Round(dblAngBase, 4)) { idLine = Draw.addLine(pnt3dCEN, pnt3dX); pnt3dTAR = pnt3dTAR.addElevation(pnt3dCEN.Z + pnt3dCEN.getDistance(pnt3dX) * dblSlope); idLine.delete(); break; } } } dblOffOX = EW_Pub.OUTER_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX"); //OX3 id3dPoly = EW_Build3dPoly.build3dPoly(idBldgOX3, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OX3", dblOffOX); id3dPoly.changeProp(LineWeight.LineWeight050, color); dblOffOX = EW_Pub.COLUMN_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX"); //OX4 id3dPoly = EW_Build3dPoly.build3dPoly(idBldgOX4, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OX4", dblOffOX); id3dPoly.changeProp(LineWeight.LineWeight050, color); Point3dCollection pnts3d = idBldgOX0.poly_pnt3dColl(); objSSet = EW_Utility1.buildSSet17(pnts3d); //get K BRACE areas ObjectId[] ids = objSSet.GetObjectIds(); color = Misc.getColorByBlock(7); //BEGIN K BRACE for (int i = 0; i < ids.Length; i++) { ObjectId idBrace = ids[i]; idBrace = idBrace.offset(5.0); idBrace.changeProp(LineWeight.LineWeight030, color); dblOffOX = EW_Pub.K_BRACE_V + EW_Utility1.getDepth(strLayer, "OX"); id3dPoly = EW_Build3dPoly.build3dPoly(idBrace, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OTHER", dblOffOX); id3dPoly.changeProp(color, "OX-BRKLINE"); //bottom of K-Brace overexcavation dblOffOX = EW_Pub.COLUMN_FOOTINGS_V + EW_Utility1.getDepth(strLayer, "OX"); color = Misc.getColorByBlock(5); idBrace = idBrace.offset(0.2); idBrace.changeProp(color); List <Point3d> pnts3dBrace = idBrace.getCoordinates3dList(); List <Point3d> pnts3dNew = new List <Point3d>(); for (int j = 0; j < pnts3dBrace.Count; j++) { Point3d pnt3dBEG = pnts3dBrace[i + 0]; Point3d pnt3dEND = pnts3dBrace[i + 1]; double dblAng = pnt3dBEG.getDirection(pnt3dEND); //angle of each segment double angDiff = System.Math.Round(dblAngBase - dblAng, 2); if (angDiff == 0) { pnt3dX = pnt3dBEG.traverse(dblAng - pi / 2, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0); pnts3dNew.Add(pnt3dX); } else if (angDiff == System.Math.Round(pi / 2, 2) || angDiff == System.Math.Round(3 * pi / 2, 2)) { pnt3dX = pnt3dBEG.traverse(dblAng + pi, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0); pnts3dNew.Add(pnt3dX); } else if (angDiff == System.Math.Round(-1 * pi / 2, 2) || angDiff == System.Math.Round(-3 * pi / 2, 2)) { pnt3dX = pnt3dBEG.traverse(dblAng - pi, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0); pnts3dNew.Add(pnt3dX); } else if (angDiff == System.Math.Round(1 * pi, 2) || angDiff == System.Math.Round(3 * pi, 2)) { pnt3dX = pnt3dBEG.traverse(dblAng + pi / 2, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0); pnts3dNew.Add(pnt3dX); } else if (angDiff == System.Math.Round(-1 * pi, 2) || angDiff == System.Math.Round(-3 * pi, 2)) { pnt3dX = pnt3dBEG.traverse(dblAng - pi / 2, (EW_Pub.K_BRACE_V - dblOffOX) * 5.0); pnts3dNew.Add(pnt3dX); } //Call addCircle(dPntPolar, 2, 1) } pnts3dNew.Add(pnts3dNew[0]); ObjectId idPoly = Draw.addPoly(pnts3dNew); idPoly.checkIfClosed3d(); id3dPoly = EW_Build3dPoly.build3dPoly(id3dPoly, pnt3dCEN, pnt3dTAR, dblSlope, "OX", "OX-BRKLINE", "OTHER", dblOffOX); id3dPoly.changeProp(color, "OX-BRKLINE"); idPoly.delete(); } //END K BRACE return(idBldgOX2); }