getDockLimits() { List <Point3d> pnts3d = new List <Point3d>(); Point3d pnt3dPick; Entity ent = Select.selectEntity(typeof(Polyline3d), "\nSelect Finish Floor 3d Polyline: ", "3d Polyline selection failed. Exiting...", out pnt3dPick); Polyline3d poly3d = (Polyline3d)ent; ResultBuffer rb = poly3d.ObjectId.getXData("AVG"); if (rb == null) { return(pnts3d); } TypedValue[] tvs = rb.AsArray(); bldgNum = tvs[2].Value.ToString(); using (BaseObjs._acadDoc.LockDocument()) { Object selectCycling = Application.GetSystemVariable("SELECTIONCYCLING"); Application.SetSystemVariable("SELECTIONCYCLING", 0); Object osMode = SnapMode.getOSnap(); SnapMode.setOSnap((int)osModes.END); PromptStatus ps; try { bool escape = false; Point3d pnt3dRet = UserInput.getPoint("\nSelect Dock Begin point (CCW orientation)", Pub.pnt3dO, out escape, out ps, osMode: 1); if (escape) { return(pnts3d); } pnts3d.Add(pnt3dRet); pnt3dRet = UserInput.getPoint("\nSelect Dock End point (CCW orientation)", pnt3dRet, out escape, out ps, osMode: 1); if (escape) { return(pnts3d); } pnts3d.Add(pnt3dRet); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " cmdGD_old.cs: line: 284"); } finally { Application.SetSystemVariable("SELECTIONCYCLING", selectCycling); SnapMode.setOSnap((int)osMode); } } return(pnts3d); }
public static void GetSheetProfileThickness(/*ObjectId aSheetProfilePolyObjectId , Point3d aPickedPoint*/) { using (var acTrans = _db.TransactionManager.StartTransaction()) { var tLine = (Line)acTrans.GetObject(_tLineId, OpenMode.ForWrite); _basePolyLine = (Polyline)acTrans.GetObject(_polylineId, OpenMode.ForWrite); tLine.Erase(); // Ed.Regen(); #region endmost_thickness_segment_search var buf = _num1; _num1 = _num2; _num2 = buf; var p1 = _basePolyLine.GetLineSegmentAt(_num1).EndPoint; var p2 = _basePolyLine.GetLineSegmentAt(_num1).StartPoint; var p3 = new Point3d((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2); var p4 = new Point3d(_ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis.X + p3.X, _ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis.Y + p3.Y, _ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis.Z + p3.Z); var v3D = p3.GetVectorTo(p4); tLine = new Line(p1, p2); tLine.TransformBy(Matrix3d.Rotation(Math.PI / 4.0, v3D, p3)); tLine.SetDatabaseDefaults(); Draw(tLine, 2, acTrans); _ed.Regen(); _tLineId = tLine.ObjectId; // thickness = (BasePolyLine.GetLineSegment2dAt(NUM1)).Length; #endregion acTrans.Commit(); } _ed.Regen(); //return thickness; }
public void Unfold2DSheetProfileStart() { _ed = Application.DocumentManager.MdiActiveDocument.Editor; _db = Application.DocumentManager.MdiActiveDocument.Database; // Pick a polyline var polyOptions = new PromptEntityOptions("Pick a sheet profile :"); polyOptions.SetRejectMessage( "\nThis is not a generated sheet profile.\nSheet Profile is generated from a polyline with SHP command.\nCreate a sheet profile and try again."); polyOptions.AddAllowedClass(typeof(Polyline), true); var polyResult = _ed.GetEntity(polyOptions); if (polyResult.Status != PromptStatus.OK) { return; } var pickInsertionPoint = _ed.GetPoint(new PromptPointOptions("Pick insertion point.")); if (pickInsertionPoint.Status != PromptStatus.OK) { return; } _polylineId = polyResult.ObjectId; double thickness; using (var acTrans = _db.TransactionManager.StartTransaction()) { _basePolyLine = (Polyline)acTrans.GetObject(_polylineId, OpenMode.ForWrite); if ((CountOfArcs() + 2 != _basePolyLine.NumberOfVertices >> 1) || (CountOfArcs() % 2 > 0)) { CommandLineHelper.Command("._copy", _basePolyLine.ObjectId, "0,0", "\033", "0,0", "\033"); var acPts2D = new Point3dCollection(); for (var nCnt = 0; nCnt < _basePolyLine.NumberOfVertices; nCnt++) { acPts2D.Add(_basePolyLine.GetPoint3dAt(nCnt)); } for (var nCnt = 1; nCnt < acPts2D.Count; nCnt++) { var point1 = acPts2D[nCnt]; var point2 = acPts2D[nCnt - 1]; var dist = point1.DistanceTo(point2); if (dist < 0.001) { acPts2D.RemoveAt(nCnt); _basePolyLine.RemoveVertexAt(nCnt); nCnt--; } } for (var nCnt = 0; nCnt < acPts2D.Count; nCnt++) { var point1 = acPts2D[nCnt]; var point2 = acPts2D[nCnt + 1]; var bulge = _basePolyLine.GetBulgeAt(nCnt); if (bulge != 0) { var arc = _basePolyLine.GetArcSegmentAt(nCnt); var ppp = arc.Center; for (var nCnt1 = 1; nCnt1 < acPts2D.Count - 1; nCnt1++) { if (acPts2D[nCnt1].DistanceTo(ppp) < 0.01) { var c1 = new Complex(acPts2D[nCnt1].X, acPts2D[nCnt1].Y); var c2 = new Complex(acPts2D[nCnt1 - 1].X, acPts2D[nCnt1 - 1].Y); var c3 = new Complex(acPts2D[nCnt1 + 1].X, acPts2D[nCnt1 + 1].Y); var ml1 = new KLine2D(c1, c2); var ml2 = new KLine2D(c1, c3); var c4 = c1 - c2; c4 /= c4.abs(); c4 *= 0.1; var c5 = c1 - c3; c5 /= c5.abs(); c5 *= 0.1; var c6 = new Complex(point1.X, point1.Y); var c7 = new Complex(point2.X, point2.Y); var ml11 = new KLine2D((c1 - c3).real(), (c1 - c3).imag(), -(c1 - c3).real() * c6.real() - (c1 - c3).imag() * c6.imag()); var ml22 = new KLine2D((c1 - c2).real(), (c1 - c2).imag(), -(c1 - c2).real() * c7.real() - (c1 - c2).imag() * c7.imag()); var c55 = ml11.IntersectWitch(ml2); var c44 = ml22.IntersectWitch(ml1); //c6 -= c5; c7 -= c4; c6 -= c5 - c1 + c55; c7 -= c4 - c1 + c44; c4 = c1 - c4; c5 = c1 - c5; _basePolyLine.RemoveVertexAt(nCnt); _basePolyLine.AddVertexAt(nCnt, new Point2d(c6.real(), c6.imag()), bulge, 0, 0); _basePolyLine.RemoveVertexAt(nCnt + 1); _basePolyLine.AddVertexAt(nCnt + 1, new Point2d(c7.real(), c7.imag()), 0, 0, 0); _basePolyLine.RemoveVertexAt(nCnt1); _basePolyLine.AddVertexAt(nCnt1, new Point2d(c5.real(), c5.imag()), 0, 0, 0); _basePolyLine.AddVertexAt(nCnt1, new Point2d(c4.real(), c4.imag()), -bulge, 0, 0); acPts2D.Clear(); for (var nCnt2 = 0; nCnt2 < _basePolyLine.NumberOfVertices; nCnt2++) { acPts2D.Add(_basePolyLine.GetPoint3dAt(nCnt2)); } break; } } } } acTrans.Commit(); CommandLineHelper.Command("._u2d", _basePolyLine.ObjectId, pickInsertionPoint.Value); CommandLineHelper.Command("._erase", _basePolyLine.ObjectId, "\033"); return; // MessageBox.Show("Must have an even number of ARC segments !" , "ERROR:"); // return; } thickness = GetThickness(); if (thickness <= 0) { MessageBox.Show("PolyLine has only one segment or no ARC segment !", "ERROR:"); return; } if (_basePolyLine.Closed == false) { MessageBox.Show("The PolyLline is not closed !", "ERROR:"); return; } if (_basePolyLine.NumberOfVertices % 2 != 0) { MessageBox.Show("Must have an even number of segments !", "ERROR:"); return; } _pickPoint = pickInsertionPoint.Value; _cPickPoint = new Complex(_pickPoint.X, _pickPoint.Y); #region endmost_thickness_segment_search _num1 = -1; _num2 = -1; for (var i = 0; i < _basePolyLine.NumberOfVertices; i++) { var next = i < _basePolyLine.NumberOfVertices - 1 ? i + 1 : 0; var pre = i > 0 ? i - 1 : _basePolyLine.NumberOfVertices - 1; var seg = _basePolyLine.GetLineSegment2dAt(i); if (seg.Length - thickness < 0.000001) { var segPre = _basePolyLine.GetLineSegment2dAt(pre); var segNext = _basePolyLine.GetLineSegment2dAt(next); for (var j = next; j < _basePolyLine.NumberOfVertices; j++) { var seg1 = _basePolyLine.GetLineSegment2dAt(j); if (seg1.Length - thickness < 0.000001) { if (Math.Abs(seg.Length - seg1.Length) < 0.000001) { var cPre = new Complex(segPre.EndPoint.X, segPre.EndPoint.Y) - new Complex(segPre.StartPoint.X, segPre.StartPoint.Y); var cNext = new Complex(segNext.EndPoint.X, segNext.EndPoint.Y) - new Complex(segNext.StartPoint.X, segNext.StartPoint.Y); var ang = (cNext / cPre).arg(); if (Math.Abs(ang * 180 / Math.PI - 180) < 0.001) { if (_num1 == -1) { _num1 = i; _num2 = j; } else { if (Math.Abs(j - i) == _basePolyLine.NumberOfVertices / 2) { _num1 = i; _num2 = j; } } } } } } } } var p1 = _basePolyLine.GetLineSegmentAt(_num1).EndPoint; var p2 = _basePolyLine.GetLineSegmentAt(_num1).StartPoint; var p3 = new Point3d((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2); var p4 = new Point3d(_ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis.X + p3.X, _ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis.Y + p3.Y, _ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis.Z + p3.Z); var v3D = p3.GetVectorTo(p4); var tLine = new Line(p1, p2); tLine.TransformBy(Matrix3d.Rotation(Math.PI / 4.0, v3D, p3)); tLine.SetDatabaseDefaults(); Draw(tLine, 4, acTrans); _ed.Regen(); _tLineId = tLine.ObjectId; //thickness = (BasePolyLine.GetLineSegment2dAt(NUM1)).Length; #endregion acTrans.Commit(); } _unfoldPoints = new ArrayList(); _entityTemp = new List <ObjectId>(); Unfold2DForm = new Unfold2dForm(thickness); Unfold2DForm.U2D_PREPARE_REDRAW += PrepareRedraw; Unfold2DForm.ShowDialog(); Logger.Info(System.Reflection.MethodBase.GetCurrentMethod().Name); }
Point3d(string label, Autodesk.AutoCAD.Geometry.Point3d val) : base(label) { m_val = val; }
GD() { object snapMode = SnapMode.getOSnap(); try { ObjectId idPoly = ObjectId.Null; double dblAngDock = 0, dblAng = 0;; double dblLenDock = 0; Point3d pnt3dA = Pub.pnt3dO; //point AHEAD List <Point3d> pnts3dLim = new List <Point3d>(); ObjectId idCgPnt0 = ObjectId.Null, idCgPnt1 = ObjectId.Null, idCgPntBeg = ObjectId.Null, idCgPntEnd = ObjectId.Null; string elev = UserInput.getCogoPoint("\nSelect Dock Begin Point: ", out idCgPntBeg, ObjectId.Null, osMode: 8); if (idCgPntBeg == ObjectId.Null) { return; } Debug.Print(idCgPntBeg.getHandle().ToString()); Point3d pnt3dBeg = idCgPntBeg.getCogoPntCoordinates(); pnts3dLim.Add(pnt3dBeg); elev = UserInput.getCogoPoint("\nSelect Dock End Point", out idCgPntEnd, idCgPntBeg, osMode: 8); if (idCgPntEnd == ObjectId.Null) { return; } Debug.Print(idCgPntEnd.getHandle().ToString()); Point3d pnt3dEnd = idCgPntEnd.getCogoPntCoordinates(); pnts3dLim.Add(pnt3dEnd); bool escape = false; PromptStatus ps; Point3d pnt3dX = UserInput.getPoint("\nSpecify point on side to grade dock: ", pnt3dBeg, out escape, out ps, osMode: 0); if (pnt3dX == Pub.pnt3dO || escape) { return; } int side = 0; if (Geom.testRight(pnt3dBeg, pnt3dEnd, pnt3dX) > 0) { side = -1; } else { side = 1; } double width = 60; escape = UserInput.getUserInput(string.Format("\nEnter dock width: <{0}>:", width), out width, width); if (escape) { return; } using (BaseObjs._acadDoc.LockDocument()) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { dblAngDock = pnt3dBeg.getDirection(pnt3dEnd); dblLenDock = pnt3dBeg.getDistance(pnt3dEnd); double dblSlope = System.Math.Round(pnt3dBeg.getSlope(pnt3dEnd), 3); dblAng = dblAngDock - pi / 2 * side; ObjectIdCollection idsPoly3dX = new ObjectIdCollection(); List <ObjectId> idsCgPnts = new List <ObjectId>(); List <Point3d> pnts3d = new List <Point3d>(); pnts3d.Add(pnt3dBeg); //CgPntBeg //Slope is not 0 if (dblSlope != 0) { pnt3dA = pnt3dBeg.traverse(dblAng, width, -0.01); pnts3d.Add(pnt3dA); //Pnt 2 dblAng = dblAng + pi / 2 * side; pnt3dA = pnt3dA.traverse(dblAng, dblLenDock, dblSlope); pnts3d.Add(pnt3dA); //Pnt3 pnts3d.Add(pnt3dEnd); //Pnt4 - CgPntEnd pnts3d.Add(pnt3dBeg); //Pnt5 - CgPntBeg idsCgPnts = pnts3d.addBrklineSegmentsDock(out idsPoly3dX, apps.lnkBrks, side, idCgPntBeg, idCgPntEnd); } else { int k = 1; int intDivide = (int)System.Math.Truncate(dblLenDock / 84) + 1; if (intDivide % 2 != 0) { intDivide = intDivide + 1; } pnt3dA = pnt3dBeg.traverse(dblAng, width, -0.005); //Pnt2 pnts3d.Add(pnt3dA); k++; int x = 0; dblAng = dblAng + pi / 2 * side; double seg = dblLenDock / intDivide; int updown = 1; for (x = 0; x <= intDivide - 1; x++) { updown = -updown; pnt3dA = pnt3dA.traverse(dblAng, seg, 0.005 * updown); pnts3d.Add(pnt3dA); //points on outer edge of Dock from Pnt2 through Pnt3 k++; } pnts3d.Add(pnt3dEnd); //Pnt4 = CgPntEnd int indexPntEnd = k++; pnt3dA = pnt3dEnd; dblAng = dblAng + pi * side; //+pi because skipped turning towards bldg because we have point already for (x = 0; x <= intDivide - 1; x++) { pnt3dA = pnt3dA.traverse(dblAng, dblLenDock / intDivide, 0.0); pnts3d.Add(pnt3dA); //points on inner edge of Dock from pntBeg to pntEnd } // don't need to add pnt3dBeg to end of list because it is calc'd in loop previous idsCgPnts = pnts3d.addBrklineSegmentsDock(out idsPoly3dX, apps.lnkBrks, side, idCgPntBeg, idCgPntEnd, indexPntEnd); List <ObjectId> idCgPntsX = new List <ObjectId>(); idCgPntsX.Add(idsCgPnts[1]); //CgPnt 2 at dock limit away from building int intUBnd = idsCgPnts.Count; x = -1; int n = 1; k = intUBnd / 2; for (int j = 1; j <= k - 1; j++) { x = -x; n = n + (intUBnd - 2 * j) * x; System.Diagnostics.Debug.Print(string.Format("{0},{1}", j, n)); idCgPntsX.Add(idsCgPnts[n]); } ObjectId idPoly3d = ObjectId.Null; for (int i = 1; i < idCgPntsX.Count; i++) { idCgPnt0 = idCgPntsX[i - 1]; idCgPnt1 = idCgPntsX[i]; idPoly3d = Draw.addPoly3d(idCgPnt0.getCogoPntCoordinates(), idCgPnt1.getCogoPntCoordinates(), "CPNT-BRKLINE"); idPoly3d.lnkPntsAndPoly3d(idCgPnt0, idCgPnt1, apps.lnkBrks); idsPoly3dX.Add(idPoly3d); } } Grading_Floor.modSurface("CPNT-ON", "Finish Surface", idsPoly3dX, false); //} tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} cmdGD.cs: line: 181", ex.Message)); } } } catch (System.Exception) { } finally{ SnapMode.setOSnap((int)snapMode); } }
GD() { ObjectId idPoly = ObjectId.Null; const string nameLayer = "CPNT-BRKLINE"; double dblAngDock = 0; double dblLenDock = 0; Point3d pnt3dA = Pub.pnt3dO; //point AHEAD Point3d pnt3dB; //point BACK int intSlopeSign = 0; const double pi = System.Math.PI; bool exists = false; ObjectId idDictGRADEDOCK = Dict.getNamedDictionary("GRADEDOCK", out exists); if (!exists) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("Run AVG - exiting ....."); } List <Point3d> pnts3dLim = getDockLimits(); //use 0 as dock number i.e. do one dock at a time bool escape = false; double width = 60; escape = UserInput.getUserInput(string.Format("Enter dock width: <{0}>:", width), out width, width); if (escape) { return; } double height = 4.04; escape = UserInput.getUserInput(string.Format("Enter dock height: <{0}>:", height), out height, height); if (escape) { return; } ObjectId idDictBLDG = Dict.getSubDict(idDictGRADEDOCK, bldgNum); //bldgNum obtained @ getDockLimits ObjectId idDictDOCKS = ObjectId.Null; TypedValue[] tvs; using (BaseObjs._acadDoc.LockDocument()) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { ResultBuffer rb = Dict.getXRec(idDictBLDG, "HANDLE3D"); if (rb == null) { return; } tvs = rb.AsArray(); rb = Dict.getXRec(idDictBLDG, "SLOPE"); if (rb == null) { return; } tvs = rb.AsArray(); double dblSlope = (double)tvs[0].Value; rb = Dict.getXRec(idDictBLDG, "CENTROID"); if (rb == null) { return; } tvs = rb.AsArray(); Point3d pnt3dCEN = new Point3d((double)tvs[0].Value, (double)tvs[1].Value, (double)tvs[2].Value); rb = Dict.getXRec(idDictBLDG, "TARGET"); if (rb == null) { return; } tvs = rb.AsArray(); Point3d pnt3dTAR = new Point3d((double)tvs[0].Value, (double)tvs[1].Value, (double)tvs[2].Value); double dblAngBase = pnt3dCEN.getDirection(pnt3dTAR); ObjectIdCollection idsPoly3dX = new ObjectIdCollection(); List <Point3d> pnts3d = new List <Point3d>(); List <ObjectId> idsCgPnts = new List <ObjectId>(); try { Point3d pnt3dBEG = pnts3dLim[0]; Point3d pnt3dEND = pnts3dLim[1]; dblAngDock = Measure.getAzRadians(pnt3dBEG, pnt3dEND); dblLenDock = pnt3dBEG.getDistance(pnt3dEND); pnt3dB = pnt3dBEG; if (pnt3dTAR != Pub.pnt3dO) { pnt3dA = new Point3d(pnt3dBEG.X, pnt3dBEG.Y, pnt3dTAR.Z + Geom.getCosineComponent(pnt3dCEN, pnt3dTAR, pnt3dBEG) * (dblSlope * -1) - height); } else { pnt3dA = new Point3d(pnt3dBEG.X, pnt3dBEG.Y, pnt3dCEN.Z - height); //assuming flat floor if pnt3dTAR is -1,-1,-1 } pnts3d.Add(pnt3dA); //CgPnt 1 } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " cmdGD_old.cs: line: 113"); } ObjectId idPoly3d = ObjectId.Null; if (dblSlope != 0) { double angDock2 = System.Math.Round(dblAngDock, 2); double angBase2 = System.Math.Round(dblAngBase, 2); double modAngles = 0; double angDiff = System.Math.Round(angBase2 - angDock2, 2); if (angDiff == 0) { intSlopeSign = 1; } else { if (angBase2 > angDock2) { modAngles = angBase2.mod(angDock2); } else { modAngles = angDock2.mod(angBase2); } if (modAngles == 0) { if (angDiff > 0) { intSlopeSign = 1; } else if (angDiff < 0) { intSlopeSign = -1; } } if (System.Math.Abs(angDiff) == System.Math.Round(pi / 2, 2)) { intSlopeSign = 0; } } } if (intSlopeSign != 0) { // sloped floor dblAngDock = dblAngDock - pi / 2; pnt3dA = pnt3dA.traverse(dblAngDock, width, -0.01); pnts3d.Add(pnt3dA); //CgPnt 2 dblAngDock = dblAngDock + pi / 2; pnt3dA = pnt3dA.traverse(dblAngDock, dblLenDock, dblSlope * intSlopeSign * 1); pnts3d.Add(pnt3dA); //Pnt3 dblAngDock = dblAngDock + pi / 2; pnt3dA = pnt3dA.traverse(dblAngDock, width, 0.01); pnts3d.Add(pnt3dA); //CgPnt 4 dblAngDock = dblAngDock + pi / 2; pnt3dA = pnt3dA.traverse(dblAngDock, dblLenDock, dblSlope * intSlopeSign * -1); pnts3d.Add(pnt3dA); //Pnt5 idPoly3d = pnts3d.build3dPolyDockApron("CPNT-ON", nameLayer, "GD", out idsCgPnts); idsPoly3dX.Add(idPoly3d); } else { dblAngDock = dblAngDock - pi / 2; pnt3dA = pnt3dA.traverse(dblAngDock, width, -0.005); pnts3d.Add(pnt3dA); //Pnt2 int intDivide = (int)System.Math.Truncate(dblLenDock / 84) + 1; if (intDivide % 2 != 0) { intDivide = intDivide + 1; } int x = 0; dblAngDock = dblAngDock + pi / 2; double seg = dblLenDock / intDivide; int updown = 1; for (x = 0; x <= intDivide - 1; x++) { updown = -updown; pnt3dA = pnt3dA.traverse(dblAngDock, seg, 0.005 * updown); pnts3d.Add(pnt3dA); } dblAngDock = dblAngDock + pi / 2; pnt3dA = pnt3dA.traverse(dblAngDock, width, 0.005); pnts3d.Add(pnt3dA); dblAngDock = dblAngDock + pi / 2; for (x = 0; x <= intDivide - 1; x++) { pnt3dA = pnt3dA.traverse(dblAngDock, dblLenDock / intDivide, 0.0); pnts3d.Add(pnt3dA); } idPoly3d = pnts3d.build3dPolyDockApron("CPNT-ON", nameLayer, "GD", out idsCgPnts); idsPoly3dX.Add(idPoly3d); List <ObjectId> idCgPntsX = new List <ObjectId>(); idCgPntsX.Add(idsCgPnts[1]); //CgPnt 2 at dock limit away from building int intUBnd = idsCgPnts.Count; x = -1; int n = 1; int k = intUBnd / 2; for (int j = 1; j <= k - 1; j++) { x = -x; n = n + (intUBnd - 2 * j) * x; System.Diagnostics.Debug.Print(string.Format("{0},{1}", j, n)); idCgPntsX.Add(idsCgPnts[n]); } for (int i = 1; i < idCgPntsX.Count; i++) { List <ObjectId> idsCogoPnts = new List <ObjectId> { idCgPntsX[i - 1], idCgPntsX[i - 0] }; idPoly3d = BrkLine.makeBreakline(apps.lnkBrks, "GD", out idPoly, idsCogoPnts); idsPoly3dX.Add(idPoly3d); } } Grading_Floor.modSurface("CPNT-ON", "Finish Surface", idsPoly3dX, false); tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " cmdGD_old.cs: line: 238"); } } }
public int Add(Autodesk.AutoCAD.Geometry.Point3d point) { return(base.List.Add(new Point(point.X, point.Y, point.Z))); }
static public void TableFromMetalSpec() { const string dlName = "MetalSpec"; var json = File.ReadAllText(Environment.GetEnvironmentVariable("TEMP") + @"\metalSpec_sd.json"); var tempSheetData = JsonConvert.DeserializeObject <SortedDictionary <string, int> >(json); var fileName = tempSheetData.Where(s => s.Key.Contains("_SPEC_FILE_PATH_")).First().Key.Replace("_SPEC_FILE_PATH_", ""); var sheetData = tempSheetData.Where(s => !s.Key.Contains("_SPEC_FILE_PATH_")).ToList(); var doc = Application.DocumentManager.MdiActiveDocument; var db = doc.Database; var ed = doc.Editor; // Ask the user to select an XLS(X) file //var ofd = // new OpenFileDialog( // "Select Excel spreadsheet to link", // null, // "xls; xlsx; xlsm", // "Файл Excel для связи", // OpenFileDialog.OpenFileDialogFlags. // DoNotTransferRemoteFiles // ); //var dr = ofd.ShowDialog(); //if (dr != System.Windows.Forms.DialogResult.OK) // return; if (!File.Exists(fileName)) { return; } // Display the name of the file and the contained sheets ed.WriteMessage( "\nВыбранный файл \"{0}\" содержал листы:", //ofd.Filename fileName ); // First we get the sheet names var sheetNames = GetSheetNames(fileName /*ofd.Filename*/); if (sheetNames.Count == 0) { ed.WriteMessage( "\nВ книге нет листов." ); return; } // And loop through, printing their names for (int i = 0; i < sheetNames.Count; i++) { var name = sheetNames[i]; ed.WriteMessage("\n{0} - {1}", i + 1, name); } var ppr = ed.GetPoint("\nУкажите точку вставки таблицы"); if (ppr.Status != PromptStatus.OK) { return; } string firstCell = "A1"; int lim = 4; try { // Remove any Data Link, if one exists already ObjectId newTableId; var dlm = db.DataLinkManager; Autodesk.AutoCAD.Geometry.Point3d pos = ppr.Value; // Create and add the new Data Link, this time with // a direction connection to the selected sheet foreach (var sheet in sheetData) { var dlId = dlm.GetDataLink(dlName + " " + sheet.Key); if (dlId != ObjectId.Null) { dlm.RemoveDataLink(dlId); } var dl = new DataLink(); dl.DataAdapterId = "AcExcel"; dl.Name = dlName + " " + sheet.Key; dl.Description = ""; dl.ConnectionString = fileName + "!" + sheet.Key + ((sheet.Value == 0) ? "" : "!" + firstCell + ":" + "S" + sheet.Value); dl.DataLinkOption = DataLinkOption.PersistCache; dl.UpdateOption |= (int)UpdateOption.AllowSourceUpdate; dlId = dlm.AddDataLink(dl); using (var tr = doc.TransactionManager.StartTransaction()) { tr.AddNewlyCreatedDBObject(dl, true); var bt = (BlockTable)tr.GetObject( db.BlockTableId, OpenMode.ForRead ); DBDictionary sd = (DBDictionary)tr.GetObject( db.TableStyleDictionaryId, OpenMode.ForRead ); // Use the style if it already exists ObjectId tsId = ObjectId.Null; // Create our table var tb = new Table(); if (sd.Contains("ROM35")) { tsId = sd.GetAt("ROM35"); tb.TableStyle = tsId; } else { TextStyleTable newTextStyleTable = tr.GetObject(doc.Database.TextStyleTableId, OpenMode.ForRead) as TextStyleTable; if (!newTextStyleTable.Has("ROM35")) //The TextStyle is currently not in the database { newTextStyleTable.UpgradeOpen(); var newTextStyleTableRecord = new TextStyleTableRecord(); newTextStyleTableRecord.FileName = "romans.shx"; newTextStyleTableRecord.Name = "ROM35"; newTextStyleTableRecord.XScale = 0.8; newTextStyleTableRecord.TextSize = 3.5; //Autodesk.AutoCAD.GraphicsInterface.FontDescriptor myNewTextStyle = new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor("ROMANS", false, false, 0, 0); //newTextStyleTableRecord.Font = myNewTextStyle; newTextStyleTable.Add(newTextStyleTableRecord); tr.AddNewlyCreatedDBObject(newTextStyleTableRecord, true); } // Otherwise we have to create it TableStyle ts = new TableStyle(); #region Тут всякие цвета - шрифты // With yellow text everywhere (yeuch :-) ts.SetColor( Color.FromColorIndex(ColorMethod.ByAci, 2), (int)(RowType.TitleRow | RowType.HeaderRow | RowType.DataRow) ); // And now with magenta outer grid-lines ts.SetGridColor( Color.FromColorIndex(ColorMethod.ByAci, 6), (int)GridLineType.OuterGridLines, (int)(RowType.TitleRow | RowType.HeaderRow | RowType.DataRow) ); // And red inner grid-lines ts.SetGridColor( Color.FromColorIndex(ColorMethod.ByAci, 1), (int)GridLineType.InnerGridLines, (int)(RowType.TitleRow | RowType.HeaderRow | RowType.DataRow) ); if (newTextStyleTable.Has("ROM35")) // And we'll make the grid-lines nice and chunky { ts.SetTextStyle(newTextStyleTable["ROM35"], (int)RowType.TitleRow); // title row ts.SetTextStyle(newTextStyleTable["ROM35"], (int)RowType.HeaderRow); // header row ts.SetTextStyle(newTextStyleTable["ROM35"], (int)RowType.DataRow); // data row } // Add our table style to the dictionary // and to the transaction #endregion tsId = ts.PostTableStyleToDatabase(db, "ROM35"); tr.AddNewlyCreatedDBObject(ts, true); } tb.Position = pos; tb.Cells.SetDataLink(dlId, true); tb.GenerateLayout(); double w = tb.Width; double h = tb.Height; tb.Width = 340; // Table Height if (lim == 4) { tb.Height = 8 + 22 + 4 + 8 * sheet.Value; } else { tb.Height = 14 + 4 + 8 * sheet.Value; } // Add it to the drawing /* */ var btr = (BlockTableRecord)tr.GetObject( db.CurrentSpaceId, OpenMode.ForWrite ); btr.AppendEntity(tb); tr.AddNewlyCreatedDBObject(tb, true); newTableId = tb.ObjectId; tb.Cells.ClearStyleOverrides(); tb.TableStyle = sd.GetAt("ROM35"); tb.RemoveDataLink(); tb.UpgradeOpen(); for (int c = 0; c < tb.Columns.Count; c++) { if (c < 3) { tb.Columns[c].Width = 30; } else if (c == 3) { tb.Columns[c].Width = 10; } else if (c != tb.Columns.Count - 1) { tb.Columns[c].Width = 15; } else { tb.Columns[c].Width = 25; } } using (var mt = new MText()) { for (int r = 0; r < tb.Rows.Count; r++) { tb.Rows[r].Height = 8; for (int c = 0; c < tb.Columns.Count; c++) { // Get the cell and its contents var cell = tb.Cells[r, c]; mt.Contents = cell.TextString; mt.Height = 3.5; cell.ContentColor = Color.FromColorIndex(ColorMethod.ByColor, 2); cell.TextHeight = 3.5; cell.Alignment = CellAlignment.MiddleCenter; if (r < lim) { cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); } else { if (tb.Cells[cell.Row, 1].TextString.Contains("Итого")) { cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 2); cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 2); if (c > 3) { cell.ContentColor = Color.FromColorIndex(ColorMethod.ByColor, 3); } } else if (tb.Cells[cell.Row, 0].TextString.Contains("Всего масса металла") || tb.Cells[cell.Row, 0].TextString.Contains("B том числе по маркам")) { cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); if (c > 3) { cell.ContentColor = Color.FromColorIndex(ColorMethod.ByColor, 6); } } else if (tb.Cells[cell.Row, 0].TextString.Contains("Всего профиля")) { cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); if (c > 3) { cell.ContentColor = Color.FromColorIndex(ColorMethod.ByColor, 5); } } else if (tb.Cells[cell.Row - 1, 0].TextString.Contains("Всего профиля")) { cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 1); cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); } else if (tb.Cells[cell.Row - 1, 1].TextString.Contains("Итого")) { cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 2); cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 2); if (c > 3) { cell.ContentColor = Color.FromColorIndex(ColorMethod.ByColor, 3); } } else { if (tb.Cells[cell.Row - 1, 1].TextString.Contains("Итого")) { cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 2); } else { cell.Borders.Top.Color = Color.FromColorIndex(ColorMethod.ByColor, 1); } cell.Borders.Bottom.Color = Color.FromColorIndex(ColorMethod.ByColor, 1); } } cell.Borders.Left.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); cell.Borders.Right.Color = Color.FromColorIndex(ColorMethod.ByColor, 6); //tb.Cells[r, c].Style = "_HEADER"; //cell.Style = "_HEADER"; mt.Contents = @"{\W0.75;" + mt.Text + "}"; mt.Width = tb.Columns[c].Width; // Explode the text fragments cell.TextString = mt.Contents; } } } if (firstCell == "A1") { tb.Rows[1].Height = 55.0; } pos = new Autodesk.AutoCAD.Geometry.Point3d(new double[] { pos.X + tb.Width + 20, pos.Y, pos.Z }); tb.DowngradeOpen(); tr.Commit(); } firstCell = "A3"; lim = 2; } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessage("\nИсключение: {0}", ex.Message); } }
public void ExportSubassemblyLinksToXml() { string path = Path.Combine(Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.User), "CorridorLinks.xml"); if (File.Exists(path)) { File.Delete(path); } Document doc = Application.DocumentManager.MdiActiveDocument; CivilDocument cdoc = CivilApplication.ActiveDocument; short fd = (short)Application.GetSystemVariable("FILEDIA"); string corridorHandle = ""; int bi = -1; int ri = -1; try { PromptStringOptions pso = new PromptStringOptions("\nEnter Corridor Handle"); PromptResult resCorr = doc.Editor.GetString(pso); corridorHandle = resCorr.StringResult; PromptIntegerOptions pio = new PromptIntegerOptions("\nEnter Baseline Index"); PromptIntegerResult resBI = doc.Editor.GetInteger(pio); bi = resBI.Value; PromptIntegerOptions pior = new PromptIntegerOptions("\nEnter BaselineRegion Index"); PromptIntegerResult resRg = doc.Editor.GetInteger(pior); ri = resRg.Value; } catch { } Application.SetSystemVariable("FILEDIA", fd); XmlDocument xmlDoc = new XmlDocument(); XmlElement docElement = xmlDoc.CreateElement("Document"); xmlDoc.AppendChild(docElement); XmlElement corridors = xmlDoc.CreateElement("Corridors"); docElement.AppendChild(corridors); docElement.SetAttribute("Name", doc.Name); using (doc.LockDocument()) { using (Database db = doc.Database) { using (Transaction t = db.TransactionManager.StartTransaction()) { foreach (ObjectId oid in cdoc.CorridorCollection) { Autodesk.Civil.DatabaseServices.Corridor corr = t.GetObject(oid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Corridor; if (!string.IsNullOrWhiteSpace(corridorHandle) && !string.IsNullOrEmpty(corridorHandle)) { if (corr.Handle.ToString() != corridorHandle) { continue; } } bool toRebuild = false; foreach (Autodesk.Civil.DatabaseServices.Baseline b in corr.Baselines) { foreach (Autodesk.Civil.DatabaseServices.BaselineRegion r in b.BaselineRegions) { int rIndex = b.BaselineRegions.IndexOf(r); if (rIndex > 0 && r.AssemblyId != b.BaselineRegions[rIndex - 1].AssemblyId && r.StartStation - b.BaselineRegions[rIndex - 1].EndStation < 0.001) { if (!toRebuild) { toRebuild = true; } if (r.SortedStations()[1] - r.StartStation > 0.001) { r.AddStation(r.StartStation + 0.001, "Extra Station"); // Need to rebuild the corridor !!! } } } } if (toRebuild) { corr.UpgradeOpen(); corr.Rebuild(); corr.DowngradeOpen(); } XmlElement corridor = xmlDoc.CreateElement("Corridor"); corridors.AppendChild(corridor); corridor.SetAttribute("Name", corr.Name); XmlElement baselines = xmlDoc.CreateElement("Baselines"); corridor.AppendChild(baselines); int blCounter = 0; foreach (Autodesk.Civil.DatabaseServices.Baseline b in corr.Baselines) { if (bi != -1) { if (blCounter != bi) { ++blCounter; continue; } } XmlElement baseline = xmlDoc.CreateElement("Baseline"); baselines.AppendChild(baseline); baseline.SetAttribute("Name", b.Name); baseline.SetAttribute("Index", blCounter.ToString()); XmlElement regions = xmlDoc.CreateElement("Regions"); baseline.AppendChild(regions); int rCounter = 0; foreach (Autodesk.Civil.DatabaseServices.BaselineRegion r in b.BaselineRegions) { int rIndex = b.BaselineRegions.IndexOf(r); if (ri != -1) { if (rCounter != ri) { ++rCounter; continue; } } XmlElement region = xmlDoc.CreateElement("Region"); regions.AppendChild(region); region.SetAttribute("Name", r.Name); region.SetAttribute("Index", rIndex.ToString()); // WARNING: Baselines can have multiple regions and differnet assemblies associated. // In this case only the first assembly has the starting station in the first region. // The other regions will not have the starting station if it is equal to // the last station of the previous region. // SOLUTION: Use multiple regions on the same baseline IF AND ONLY IF the regions have gaps in between. // If the regions have to be contiguous and the assemblies are differnet it is better // to model a baseline with a single region for each assembly instead. foreach (Autodesk.Civil.DatabaseServices.AppliedAssembly aa in r.AppliedAssemblies) { Autodesk.Civil.DatabaseServices.Assembly assembly = null; if (r.AssemblyId != ObjectId.Null) { try { assembly = t.GetObject(r.AssemblyId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Assembly; } catch { } } string assemblyName = ""; if (assembly != null) { assemblyName = assembly.Name; } foreach (Autodesk.Civil.DatabaseServices.AppliedSubassembly asa in aa.GetAppliedSubassemblies()) { Autodesk.Civil.DatabaseServices.Subassembly subassembly = null; if (asa.SubassemblyId != ObjectId.Null) { try { subassembly = t.GetObject(asa.SubassemblyId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Subassembly; } catch { } } string subassemblyName = ""; string handle = ""; string station = asa.OriginStationOffsetElevationToBaseline.X.ToString(); if (subassembly != null) { subassemblyName = subassembly.Name; handle = asa.SubassemblyId.Handle.ToString(); } int linkCounter = 0; foreach (Autodesk.Civil.DatabaseServices.CalculatedLink cl in asa.Links) { XmlElement shape = xmlDoc.CreateElement("Link"); region.AppendChild(shape); shape.SetAttribute("Corridor", corr.Name); shape.SetAttribute("BaselineIndex", blCounter.ToString()); shape.SetAttribute("RegionIndex", rCounter.ToString()); shape.SetAttribute("AssemblyName", assemblyName); shape.SetAttribute("SubassemblyName", subassemblyName); shape.SetAttribute("Handle", handle); shape.SetAttribute("LinkIndex", linkCounter.ToString()); shape.SetAttribute("Station", station); XmlElement codes = xmlDoc.CreateElement("Codes"); shape.AppendChild(codes); foreach (string cd in cl.CorridorCodes) { XmlElement code = xmlDoc.CreateElement("Code"); codes.AppendChild(code); code.SetAttribute("Name", cd); } IList <Autodesk.AutoCAD.Geometry.Point3d> points = new List <Autodesk.AutoCAD.Geometry.Point3d>(); foreach (Autodesk.Civil.DatabaseServices.CalculatedPoint cp in cl.CalculatedPoints) { Autodesk.AutoCAD.Geometry.Point3d soe = cp.StationOffsetElevationToBaseline; Autodesk.AutoCAD.Geometry.Point3d p3d = b.StationOffsetElevationToXYZ(soe); if (!points.Contains(p3d)) { points.Add(p3d); } } foreach (Autodesk.AutoCAD.Geometry.Point3d p3d in points) { XmlElement point = xmlDoc.CreateElement("Point"); shape.AppendChild(point); point.SetAttribute("X", p3d.X.ToString()); point.SetAttribute("Y", p3d.Y.ToString()); point.SetAttribute("Z", p3d.Z.ToString()); } ++linkCounter; } } } ++rCounter; } ++blCounter; } } } } } xmlDoc.Save(path); }
public void ExportCorridorFeatureLinesToXml() { string path = Path.Combine(Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.User), "CorridorFeatureLines.xml"); if (File.Exists(path)) { File.Delete(path); } XmlDocument xmlDoc = new XmlDocument(); XmlElement docElement = xmlDoc.CreateElement("Document"); xmlDoc.AppendChild(docElement); XmlElement corridors = xmlDoc.CreateElement("Corridors"); docElement.AppendChild(corridors); Document doc = Application.DocumentManager.MdiActiveDocument; CivilDocument cdoc = CivilApplication.ActiveDocument; docElement.SetAttribute("Name", doc.Name); short fd = (short)Application.GetSystemVariable("FILEDIA"); PromptStringOptions pso = new PromptStringOptions("\nInsert Corridor Handle"); pso.AllowSpaces = false; PromptResult pr = doc.Editor.GetString(pso); string handle1 = pr.StringResult.Replace("\"", ""); Application.SetSystemVariable("FILEDIA", fd); using (doc.LockDocument()) { using (Database db = doc.Database) { using (Transaction t = db.TransactionManager.StartTransaction()) { ObjectId oid1 = ObjectId.Null; try { if (!string.IsNullOrEmpty(handle1) && !string.IsNullOrWhiteSpace(handle1)) { oid1 = db.GetObjectId(false, new Handle(Convert.ToInt64(handle1, 16)), 0); } } catch { } if (oid1 == ObjectId.Null) { foreach (ObjectId oid in cdoc.CorridorCollection) { if (oid == ObjectId.Null) { continue; } Autodesk.Civil.DatabaseServices.Corridor corr = null; try { corr = t.GetObject(oid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Corridor; } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(string.Format("ERROR: {0}", ex.Message)); } if (corr == null) { continue; } XmlElement corridor = xmlDoc.CreateElement("Corridor"); corridors.AppendChild(corridor); corridor.SetAttribute("Name", corr.Name); XmlElement baselines = xmlDoc.CreateElement("Baselines"); corridor.AppendChild(baselines); int blCounter = 0; foreach (Autodesk.Civil.DatabaseServices.Baseline b in corr.Baselines) { XmlElement baseline = xmlDoc.CreateElement("Baseline"); baselines.AppendChild(baseline); baseline.SetAttribute("Name", b.Name); baseline.SetAttribute("Index", blCounter.ToString()); XmlElement featurelines = xmlDoc.CreateElement("FeatureLines"); baseline.AppendChild(featurelines); foreach (string cn in b.MainBaselineFeatureLines.FeatureLineCollectionMap.CodeNames()) { foreach (Autodesk.Civil.DatabaseServices.CorridorFeatureLine cfl in b.MainBaselineFeatureLines.FeatureLineCollectionMap[cn]) { XmlElement featureline = xmlDoc.CreateElement("FeatureLine"); featureline.SetAttribute("Code", cfl.CodeName); featureline.SetAttribute("Style", cfl.StyleName); featurelines.AppendChild(featureline); XmlElement points = xmlDoc.CreateElement("Points"); featureline.AppendChild(points); foreach (Autodesk.Civil.DatabaseServices.FeatureLinePoint cflp in cfl.FeatureLinePoints) { double offset = cflp.Offset; double station = cflp.Station; Autodesk.AutoCAD.Geometry.Point3d p3d = cflp.XYZ; XmlElement point = xmlDoc.CreateElement("Point"); point.SetAttribute("X", p3d.X.ToString()); point.SetAttribute("Y", p3d.Y.ToString()); point.SetAttribute("Z", p3d.Z.ToString()); point.SetAttribute("Station", station.ToString()); point.SetAttribute("Offset", offset.ToString()); point.SetAttribute("IsBreak", cflp.IsBreak ? "1" : "0"); points.AppendChild(point); } double s = Convert.ToDouble(points.ChildNodes[points.ChildNodes.Count / 2].Attributes["Station"].Value); double o = Convert.ToDouble(points.FirstChild.Attributes["Offset"].Value); var reg = b.BaselineRegions.Cast <Autodesk.Civil.DatabaseServices.BaselineRegion>().First(x => x.StartStation <s && x.EndStation> s); featureline.SetAttribute("RegionIndex", b.BaselineRegions.IndexOf(reg).ToString()); featureline.SetAttribute("Side", o < 0 ? "-1" : "1"); } } ++blCounter; } } } else { Autodesk.Civil.DatabaseServices.Corridor corr = null; try { corr = t.GetObject(oid1, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Corridor; } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(string.Format("ERROR: {0}", ex.Message)); } if (corr == null) { System.Windows.Forms.MessageBox.Show(string.Format("ERROR: {0}", "Cannot find the specified corridor.")); return; } XmlElement corridor = xmlDoc.CreateElement("Corridor"); corridors.AppendChild(corridor); corridor.SetAttribute("Name", corr.Name); XmlElement baselines = xmlDoc.CreateElement("Baselines"); corridor.AppendChild(baselines); int blCounter = 0; foreach (Autodesk.Civil.DatabaseServices.Baseline b in corr.Baselines) { XmlElement baseline = xmlDoc.CreateElement("Baseline"); baselines.AppendChild(baseline); baseline.SetAttribute("Name", b.Name); baseline.SetAttribute("Index", blCounter.ToString()); XmlElement featurelines = xmlDoc.CreateElement("FeatureLines"); baseline.AppendChild(featurelines); foreach (string cn in b.MainBaselineFeatureLines.FeatureLineCollectionMap.CodeNames()) { foreach (Autodesk.Civil.DatabaseServices.CorridorFeatureLine cfl in b.MainBaselineFeatureLines.FeatureLineCollectionMap[cn]) { XmlElement featureline = xmlDoc.CreateElement("FeatureLine"); featureline.SetAttribute("Code", cfl.CodeName); featureline.SetAttribute("Style", cfl.StyleName); featurelines.AppendChild(featureline); XmlElement points = xmlDoc.CreateElement("Points"); featureline.AppendChild(points); foreach (Autodesk.Civil.DatabaseServices.FeatureLinePoint cflp in cfl.FeatureLinePoints) { double offset = cflp.Offset; double station = cflp.Station; Autodesk.AutoCAD.Geometry.Point3d p3d = cflp.XYZ; XmlElement point = xmlDoc.CreateElement("Point"); point.SetAttribute("X", p3d.X.ToString()); point.SetAttribute("Y", p3d.Y.ToString()); point.SetAttribute("Z", p3d.Z.ToString()); point.SetAttribute("Station", station.ToString()); point.SetAttribute("Offset", offset.ToString()); point.SetAttribute("IsBreak", cflp.IsBreak ? "1" : "0"); points.AppendChild(point); } double s = Convert.ToDouble(points.ChildNodes[points.ChildNodes.Count / 2].Attributes["Station"].Value); double o = Convert.ToDouble(points.FirstChild.Attributes["Offset"].Value); var reg = b.BaselineRegions.Cast <Autodesk.Civil.DatabaseServices.BaselineRegion>().First(x => x.StartStation <s && x.EndStation> s); featureline.SetAttribute("RegionIndex", b.BaselineRegions.IndexOf(reg).ToString()); featureline.SetAttribute("Side", o < 0 ? "-1" : "1"); } } ++blCounter; } } } } } xmlDoc.Save(path); }
public override void WritePoint3d(Autodesk.AutoCAD.Geometry.Point3d value) { }