addPoly3d(Point3d[] pnt3ds, string nameLayer = "0", short color = 256) { ObjectId idPoly3d = ObjectId.Null; Polyline3d poly3d = new Polyline3d(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); idPoly3d = MS.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); int i = -1; poly3d.SetDatabaseDefaults(); Layer.manageLayers(nameLayer); poly3d.Layer = nameLayer; poly3d.Color = Color.FromColorIndex(ColorMethod.ByBlock, color); foreach (Point3d pnt3d in pnt3ds) { i = ++i; PolylineVertex3d poly3dVertex = new PolylineVertex3d(pnt3d); poly3d.AppendVertex(poly3dVertex); tr.AddNewlyCreatedDBObject(poly3dVertex, true); } tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 443"); } return(idPoly3d); }
public static ObjectId?addPolyline3d(List <Point3d> plist, ObjectId layerId, bool ifClosed = false) { try { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; using (Transaction tran = acCurDb.TransactionManager.StartTransaction()) { BlockTable bt = tran.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord modelSpace = tran.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Polyline3d b = new Polyline3d(); ObjectId oid = modelSpace.AppendEntity(b); for (int i = 0; i < plist.Count; i++) { b.AppendVertex(new PolylineVertex3d(plist[i])); } b.Closed = ifClosed; if (layerId != ObjectId.Null) { b.LayerId = layerId; } tran.AddNewlyCreatedDBObject(b, true); tran.Commit(); return(oid); } } catch (System.Exception ex) { } return(null); }
updatePoly3dCoordinates(this ObjectId idPoly3dOrg, List <Point3d> pnts3d) { ObjectId idPoly3dNew = ObjectId.Null; Polyline3d poly3dNew = new Polyline3d(); using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord ms = Blocks.getBlockTableRecordMS(); idPoly3dNew = ms.AppendEntity(poly3dNew); poly3dNew.SetDatabaseDefaults(); poly3dNew.Layer = idPoly3dOrg.getLayer(); foreach (Point3d pnt3dX in pnts3d) { PolylineVertex3d v3d = new PolylineVertex3d(pnt3dX); poly3dNew.AppendVertex(v3d); tr.AddNewlyCreatedDBObject(v3d, true); } tr.AddNewlyCreatedDBObject(poly3dNew, true); tr.Commit(); } using (Transaction tr1 = BaseObjs.startTransactionDb()) { DBObject dbObjOrg = tr1.GetObject(idPoly3dOrg, OpenMode.ForRead); DBObject dbObjNew = tr1.GetObject(idPoly3dNew, OpenMode.ForRead); dbObjNew.UpgradeOpen(); dbObjNew.SwapIdWith(dbObjOrg.ObjectId, true, true); idPoly3dNew.delete(); tr1.Commit(); } }
addPoly3d(this List <Point3d> pnt3ds, string nameLayer = "0", short color = 256) { ObjectId idPoly3d = ObjectId.Null; Polyline3d poly3d = new Polyline3d(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTable bt = (BlockTable)BaseObjs._db.BlockTableId.GetObject(OpenMode.ForRead); BlockTableRecord MS = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite); idPoly3d = MS.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); poly3d.SetDatabaseDefaults(); Layer.manageLayers(nameLayer); poly3d.Layer = nameLayer; poly3d.Color = Color.FromColorIndex(ColorMethod.ByBlock, color); foreach (Point3d pnt3d in pnt3ds) { PolylineVertex3d poly3dVertex = new PolylineVertex3d(pnt3d); poly3d.AppendVertex(poly3dVertex); tr.AddNewlyCreatedDBObject(poly3dVertex, true); } tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 406"); } return(idPoly3d); }
/// <summary> /// create the 3D polyline in specifed layer /// </summary> /// <param name="doc"></param> /// <param name="pts"></param> /// <param name="layerName"></param> /// <returns></returns> public static Polyline3d CreatePolylineFromPoint(Document doc, List <Point3d> pts, string layerName) { Polyline3d pl = new Polyline3d(); Database db = doc.Database; #region create polyline with points using (Transaction tr = db.TransactionManager.StartTransaction()) { try { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); pl.Layer = layerName; btr.AppendEntity(pl); tr.AddNewlyCreatedDBObject(pl, true); foreach (Point3d pt in pts) { PolylineVertex3d vex3d = new PolylineVertex3d(pt); pl.AppendVertex(vex3d);//apdd point into 3d polyline tr.AddNewlyCreatedDBObject(vex3d, true); } } catch { } tr.Commit(); } #endregion return(pl); }
addVertexToPoly3d(this ObjectId idPoly3dOrg, Point3d pnt3d, int pos, Handle hCgPNt) { List <Point3d> pnts3d = idPoly3dOrg.getCoordinates3dList(); ObjectId idPoly3dNew = ObjectId.Null; Polyline3d poly3dNew = new Polyline3d(); using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord ms = Blocks.getBlockTableRecordMS(); idPoly3dNew = ms.AppendEntity(poly3dNew); poly3dNew.SetDatabaseDefaults(); poly3dNew.Layer = idPoly3dOrg.getLayer(); pnts3d.Insert(pos + 1, pnt3d); foreach (Point3d pnt3dX in pnts3d) { PolylineVertex3d v3d = new PolylineVertex3d(pnt3dX); poly3dNew.AppendVertex(v3d); tr.AddNewlyCreatedDBObject(v3d, true); } tr.AddNewlyCreatedDBObject(poly3dNew, true); tr.Commit(); } using (Transaction tr1 = BaseObjs.startTransactionDb()) { DBObject dbObjOrg = tr1.GetObject(idPoly3dOrg, OpenMode.ForRead); DBObject dbObjNew = tr1.GetObject(idPoly3dNew, OpenMode.ForRead); dbObjNew.UpgradeOpen(); dbObjNew.SwapIdWith(dbObjOrg.ObjectId, true, true); idPoly3dNew.delete(); tr1.Commit(); } ResultBuffer rb = idPoly3dOrg.getXData(apps.lnkBrks); TypedValue[] tvs = rb.AsArray(); TypedValue[] tvsNew = new TypedValue[tvs.Length + 1]; for (int i = 0; i < pos + 2; i++) { tvsNew[i] = tvs[i]; } tvsNew.SetValue(new TypedValue(1005, hCgPNt), pos + 2); for (int i = pos + 2; i < tvs.Length; i++) { tvsNew[i + 1] = tvs[i]; } idPoly3dOrg.clearXData(apps.lnkBrks); idPoly3dOrg.setXData(tvsNew, apps.lnkBrks); }
private void CreatePolyline(List <SimplePoint3d> points) { Polyline3d polyline = new Polyline3d(); _transaction.AddObjectToActiveModelSpace(polyline); foreach (SimplePoint3d point in points) { var point3d = new Point3d(point.X, point.Y, point.Z); using (PolylineVertex3d vertex = new PolylineVertex3d(point3d)) { polyline.AppendVertex(vertex); } } }
/// <summary> /// Adds vertices to a polyline and adds it to a transaction. /// </summary> /// <param name="polyLine"></param> /// <param name="pointCollection"></param> public static void AddVertices(this Polyline3d polyLine, Point3dCollection pointCollection) { AutoCadHelper.AppendAndAddToTransaction(polyLine); foreach (Point3d point in pointCollection) { var vertex = new PolylineVertex3d(point); polyLine.AppendVertex(vertex); AutoCadHelper.AddToTransaction(vertex); } // Erase the polyline before commiting so it's not drawn. polyLine.Erase(); }
private static Entity Draw3dPline(Point[] points, bool closePart) { Document document = AfaDocData.ActiveDocData.Document; Database database = document.Database; var transactionManager = document.TransactionManager; Polyline3d polyline3d = new Polyline3d(); using (document.LockDocument()) { using (Transaction transaction = transactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(database.BlockTableId, 0); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[(BlockTableRecord.ModelSpace)], (OpenMode)1); polyline3d.ColorIndex = (256); blockTableRecord.AppendEntity(polyline3d); transaction.AddNewlyCreatedDBObject(polyline3d, true); int num = 0; if (points != null && points.Length > 0) { for (int i = 0; i < points.Length; i++) { Point point = points[i]; PointN pointN = (PointN)point; PolylineVertex3d polylineVertex3d = new PolylineVertex3d(new Point3d(pointN.X, pointN.Y, pointN.Z)); polyline3d.AppendVertex(polylineVertex3d); num++; } } if (num == 0) { return(null); } if (closePart) { polyline3d.Closed = (true); } polyline3d.ColorIndex = (256); document.TransactionManager.QueueForGraphicsFlush(); document.TransactionManager.FlushGraphics(); document.Editor.UpdateScreen(); transaction.Commit(); } } return(polyline3d); }
//convert parts to splines (works for line and arcs*Not arcs yet) static private Spline convertSpline(DBObject dbo) { if (dbo is Spline) { return(dbo as Spline); } if (dbo is Arc) { Arc arcDat = dbo as Arc; Spline seg = new Spline(); //whatever that is return(seg); } else if (dbo is Line) { Line lDat = dbo as Line; Point3dCollection vertices = new Point3dCollection(); vertices.Add(lDat.StartPoint); vertices.Add(lDat.EndPoint); Polyline3d tempPline = new Polyline3d(); //polyine 3D has to be in btr before adding vertices Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { BlockTableRecord btr = (BlockTableRecord)(trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)); btr.AppendEntity(tempPline); foreach (Point3d pnt in vertices) { using (PolylineVertex3d poly3dVert = new PolylineVertex3d(pnt)) { tempPline.AppendVertex(poly3dVert); } } trans.Commit(); } Spline seg = tempPline.Spline; tempPline.Erase(true); return(seg); } return(null); }
private static void CreatePolyline3dFromPoints(Database db, IEnumerable <Point3d> points, bool shouldClose) { var trans = db.TransactionManager.TopTransaction; var acBlkTbl = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); var acBlkTblRec = (BlockTableRecord)trans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite); var poly3d = new Polyline3d(); acBlkTblRec.AppendEntity(poly3d); trans.AddNewlyCreatedDBObject(poly3d, true); foreach (var point in points) { using (var poly3dVertex = new PolylineVertex3d(point)) { poly3d.AppendVertex(poly3dVertex); } } poly3d.Closed = shouldClose; }
/// <summary> /// Adds the polyline3d. /// </summary> /// <param name="sidedb">The sidedb.</param> /// <param name="points">The points.</param> /// <param name="layername">The layername.</param> /// <param name="isClosed">if set to <c>true</c> [is closed].</param> /// <param name="colorIndex">Index of the color.</param> /// <returns>ObjectId.</returns> public static ObjectId AddPolyline3d(Autodesk.AutoCAD.DatabaseServices.Database sidedb, Point3dCollection points, string layername, bool isClosed, int colorIndex) { //_logger.Debug("Start AddPolyline"); ObjectId id = ObjectId.Null; Autodesk.AutoCAD.DatabaseServices.Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; HostApplicationServices.WorkingDatabase = sidedb; using (Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = sidedb.TransactionManager) { using (Transaction tr = tm.StartTransaction()) { Polyline3d pline = new Polyline3d(); pline.SetDatabaseDefaults(); pline.Layer = layername; if ((colorIndex > 0) && (colorIndex < 256)) { pline.ColorIndex = colorIndex; } // int index = 0; // double width = 0.0; foreach (PolylineVertex3d pt in points) { pline.AppendVertex(pt); } pline.Closed = isClosed; id = AddToDatabase(db, pline, tr); tr.Commit(); } } //_logger.Debug("End AddPolyline"); return(id); }
/// <summary> /// project 3d polyline in XY plane, return a flattened polyline on XY plane and orignal 3d polyline /// </summary> /// <param name="doc"></param> /// <param name="id">ObjectId of the 3d Polyline</param> /// <param name="originalPoly3d"></param> /// <returns></returns> public static Polyline3d CreatePolylineOnXYPlane(Document doc, ObjectId id, ref Polyline3d originalPoly3d) { Polyline3d pl = new Polyline3d(); Database db = doc.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); DBObject obj = tr.GetObject(id, OpenMode.ForRead); Entity ent = obj as Entity; string layerName = ent.Layer.ToString(); pl.Layer = layerName; btr.AppendEntity(pl); tr.AddNewlyCreatedDBObject(pl, true); Polyline3d p3d = obj as Polyline3d; if (p3d != null) { originalPoly3d = p3d; foreach (ObjectId vId in p3d) { PolylineVertex3d v3d = (PolylineVertex3d)tr.GetObject(vId, OpenMode.ForRead); PolylineVertex3d v3d_new = new PolylineVertex3d(new Point3d(v3d.Position.X, v3d.Position.Y, 0)); pl.AppendVertex(v3d_new);//apdd point into 3d polyline tr.AddNewlyCreatedDBObject(v3d_new, true); } } tr.Commit(); } return(pl); }
public void ExtractSpillwayPositions() { Document adoc = Application.DocumentManager.MdiActiveDocument; if (adoc == null) { return; } Database db = adoc.Database; Editor ed = adoc.Editor; List <Polyline3d> highlighted = new List <Polyline3d>(); try { Plane horizontalPlane = new Plane(Point3d.Origin, Vector3d.ZAxis); //Указать линию КПЧ и линии перелома откоса (они должны быть в соответствующих слоях) TypedValue[] tv = new TypedValue[] { new TypedValue(0, "POLYLINE"), new TypedValue(8, "КПЧ,ОТК") };//ограничение по слоям SelectionFilter flt = new SelectionFilter(tv); PromptSelectionOptions opts = new PromptSelectionOptions(); opts.MessageForAdding = "\nВыберите 3d-полилинии, обозначающие край проезжей части" + "и переломы откоса (только с одной стороны дороги). Линии должны быть в слоях КПЧ и ОТК"; PromptSelectionResult res = ed.GetSelection(opts, flt); if (res.Status == PromptStatus.OK) { SelectionSet sset = res.Value; //Отобрать только полилинии в нужных слоях Dictionary <string, List <Polyline3dInfo> > slopeLines = new Dictionary <string, List <Polyline3dInfo> >(); //Считать направление полилинии соответствующим направлению дороги bool? toTheRight = null;//водосброс справа от КПЧ Polyline3dInfo baseLine = null; using (Transaction tr = db.TransactionManager.StartTransaction()) { WrongPolylinesException wrongPolylinesException = new WrongPolylinesException(); //Отбор линий в служебных слоях foreach (SelectedObject acSSObj in sset) { Polyline3d currPoly = tr.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Polyline3d; if (currPoly != null) { if (currPoly.Layer.Equals("КПЧ") || currPoly.Layer.Equals("ОТК")) { List <Polyline3dInfo> polylines = null; slopeLines.TryGetValue(currPoly.Layer, out polylines); if (polylines == null) { polylines = new List <Polyline3dInfo>(); slopeLines.Add(currPoly.Layer, polylines); } polylines.Add(new Polyline3dInfo(currPoly.Layer, currPoly)); } } } //Проверить, что есть весь набор слоев - КПЧ, ОТК if (!slopeLines.ContainsKey("КПЧ") || !slopeLines.ContainsKey("ОТК")) { wrongPolylinesException.Mistakes = wrongPolylinesException.Mistakes | Mistake.NotEnoughLayers; } //Проверить, что в слое КПЧ находится только 1 полилиния List <Polyline3dInfo> checkList1 = null; slopeLines.TryGetValue("КПЧ", out checkList1); if (checkList1 == null || checkList1.Count != 1) { wrongPolylinesException.Mistakes = wrongPolylinesException.Mistakes | Mistake.TooManyLinesInOneLayer; } #region Проперка непересечения линий //Проверить что линии откоса не пересекают друг друга в плане //TODO: ВРЕМЕННО отказался от проверки взаимного пересечения линий откоса. Нужно учесть возможность частичного совпадения линий /* * List<Polyline3dInfo> slopeLinesList = slopeLines.Values.ToList().Aggregate((l1, l2) => * { * return l1.Concat(l2).ToList(); * }); * bool exitLoop = false; * for (int i = 0; i < slopeLinesList.Count; i++) * { * for (int j = i + 1; j < slopeLinesList.Count; j++) * { * Polyline3d poly1 = slopeLinesList[i].Poly3d; * Polyline3d poly2 = slopeLinesList[j].Poly3d; * Point3dCollection intersectPts = new Point3dCollection(); * poly1.IntersectWith(poly2, Intersect.OnBothOperands, * horizontalPlane, intersectPts, * new IntPtr(0), new IntPtr(0)); * * //TODO!!!!! Не считать точки пересечения если в точках пересечения происходит полное совпадение вершин двух полилиний * //В это случае скорее всего полилинии просто сливаются в одну. Это допустимо для коридора * * * * if (intersectPts.Count > 0) * { * * * * wrongPolylinesException.Mistakes = wrongPolylinesException.Mistakes | Mistake.LinesAreIntersecting; * exitLoop = true; * break; * } * } * if (exitLoop) * break; * } */ #endregion //Проверить, что все точки откоса расположены с одной стороны от КПЧ //Определить водосброс направо или налево //TODO: Проверить сонаправленность линий! (низкий приоритет) //Для всех кодов определить участки КПЧ. Параметры взаимного расположения расчитываются в горизонтальной проекции //По начальным точкам линий определить расположение линии справа или слева от КПЧ //базовая линия - КПЧ List <Polyline3dInfo> list = null; slopeLines.TryGetValue("КПЧ", out list); if (list != null && list.Count > 0) { baseLine = list.First(); foreach (KeyValuePair <string, List <Polyline3dInfo> > kvp in slopeLines) { if (!kvp.Key.Equals("КПЧ")) { foreach (Polyline3dInfo poly3dInfo in kvp.Value) { poly3dInfo.BaseLine = baseLine.Poly2d; poly3dInfo.ComputeParameters(); poly3dInfo.ComputeOrientation(); //проверка, что все линии с одной стороны от базовой if (toTheRight != null) { if (toTheRight != poly3dInfo.ToTheRightOfBaseLine) { wrongPolylinesException.Mistakes = wrongPolylinesException.Mistakes | Mistake.WrongOrientation; } } else { toTheRight = poly3dInfo.ToTheRightOfBaseLine; } } } } } if (wrongPolylinesException.Mistakes != Mistake.None) { throw wrongPolylinesException; } #region Test //ed.WriteMessage("\nОшибок нет\ntoTheRight = " + toTheRight); ////Начертить круги в точках начала и конца полилиний //BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; //BlockTableRecord ms // = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); //foreach (KeyValuePair<string, List<Polyline3dInfo>> kvp in slopeLines) //{ // if (!kvp.Key.Equals("КПЧ")) // { // foreach (Polyline3dInfo poly3dInfo in kvp.Value) // { // Point3d pt1 = poly3dInfo.Poly3d.GetPointAtParameter(poly3dInfo.StartParameter); // Point3d pt2 = poly3dInfo.Poly3d.GetPointAtParameter(poly3dInfo.EndParameter); // Point3d pt3 = baseLine.Poly3d.GetPointAtParameter(poly3dInfo.StartParameterBase); // Point3d pt4 = baseLine.Poly3d.GetPointAtParameter(poly3dInfo.EndParameterBase); // foreach (Point3d pt in new Point3d[] { pt1, pt2, pt3, pt4 }) // { // using (Circle circle = new Circle(pt, Vector3d.ZAxis, 1)) // { // circle.Color = Color.FromColorIndex(ColorMethod.ByAci, 1); // ms.AppendEntity(circle); // tr.AddNewlyCreatedDBObject(circle, true); // } // } // using (Line line = new Line(pt1, pt3)) // { // line.Color = Color.FromColorIndex(ColorMethod.ByAci, 1); // ms.AppendEntity(line); // tr.AddNewlyCreatedDBObject(line, true); // } // using (Line line = new Line(pt2, pt4)) // { // line.Color = Color.FromColorIndex(ColorMethod.ByAci, 1); // ms.AppendEntity(line); // tr.AddNewlyCreatedDBObject(line, true); // } // } // } //} #endregion tr.Commit(); } //Включать подсветку 3d полилиний, которые участвуют в расчете highlighted.Clear(); foreach (KeyValuePair <string, List <Polyline3dInfo> > kvp in slopeLines) { foreach (Polyline3dInfo p3dI in kvp.Value) { p3dI.Poly3d.Highlight(); highlighted.Add(p3dI.Poly3d); } } int spillwayNum = 1; PositionData positionData = new PositionData(); while (true) { //Указать точку расположения водосброса PromptPointResult pPtRes; PromptPointOptions pPtOpts = new PromptPointOptions(""); pPtOpts.Message = "\nУкажите точку расположения водосброса: "; pPtRes = adoc.Editor.GetPoint(pPtOpts); if (pPtRes.Status == PromptStatus.OK) { Point3d pickedPt = new Point3d(pPtRes.Value.X, pPtRes.Value.Y, 0); Point3d nearestPtOnBase = baseLine.Poly2d.GetClosestPointTo(pickedPt, true); //найти ближайшую точку базовой линии double pickedParameterBase = baseLine.Poly2d.GetParameterAtPoint(nearestPtOnBase); //параметр базовой линии в этой точке //Найти все линии откоса, которые расположены в районе данного параметра //Предполагается, что для каждого кода есть только одна такая List <Polyline3dInfo> pickedPtSlopeLines = slopeLines["ОТК"].FindAll(l => l.StartParameterBase <= pickedParameterBase && l.EndParameterBase >= pickedParameterBase); if (pickedPtSlopeLines.Count > 1)//Проверить, что найдены минимум 2 линии перелома откоса { //Найти ближайшую линию к базовой линии - это бровка Polyline3dInfo edgeLine = null; double minDist = double.MaxValue; foreach (Polyline3dInfo p3dI in pickedPtSlopeLines) { Point3d ptOnLine = p3dI.Poly2d.GetClosestPointTo(nearestPtOnBase, false); double distance = ptOnLine.DistanceTo(nearestPtOnBase); if (distance < minDist) { minDist = distance; edgeLine = p3dI; } } Point3d nearestPtOnEdge = edgeLine.Poly2d.GetClosestPointTo(pickedPt, true); //найти ближайшую точку бровки double pickedParameterEdge = edgeLine.Poly2d.GetParameterAtPoint(nearestPtOnEdge); //параметр бровки в этой точке //Найти касательную к бровке Vector3d tangentVector = edgeLine.Poly2d.GetFirstDerivative(pickedParameterEdge); double rotateAngle = toTheRight.Value ? -Math.PI / 2 : Math.PI / 2; Vector3d spillWayVector = tangentVector.RotateBy(rotateAngle, Vector3d.ZAxis).GetNormal();//вектор водосброса, перпендикулярный бровке Line spillWayAxis = new Line(nearestPtOnEdge, nearestPtOnEdge + spillWayVector); Point3dCollection intersections = new Point3dCollection(); baseLine.Poly2d.IntersectWith(spillWayAxis, Intersect.ExtendArgument, horizontalPlane, intersections, new IntPtr(0), new IntPtr(0)); if (intersections.Count > 0) { Point3d basePt = intersections[0];//Точка пересечения оси водосброса с КПЧ //Найти точки пересечения перпендикуляра к ОТК0 и остальными линиями откоса //Отсортировать все линии по удаленности от КПЧ в этой точке SortedDictionary <Point3d, Polyline3dInfo> intersectionPts = new SortedDictionary <Point3d, Polyline3dInfo>(new PtsSortComparer(basePt)); pickedPtSlopeLines.Add(baseLine); foreach (Polyline3dInfo p3dI in pickedPtSlopeLines) { intersections.Clear(); p3dI.Poly2d.IntersectWith(spillWayAxis, Intersect.ExtendArgument, horizontalPlane, intersections, new IntPtr(0), new IntPtr(0)); if (intersections.Count > 0) { intersectionPts.Add(intersections[0], p3dI); } } if (intersectionPts.Count == pickedPtSlopeLines.Count)//Проверить, что все пересечения найдены { //intersectionPts содержит все линии с точками пересечения в нужном порядке, //но все точки пересечения лежат на плоскости XY //Расчитать трехмерные точки Point3dCollection pts = new Point3dCollection(); foreach (KeyValuePair <Point3d, Polyline3dInfo> kvp in intersectionPts) { Point3d pt2d = kvp.Key; pt2d = kvp.Value.Poly2d.GetClosestPointTo(pt2d, false);//по какой-то причине в некоторых случаях без этой строки вылетала ошибка при получении параметра double param = kvp.Value.Poly2d.GetParameterAtPoint(pt2d); Point3d pt3d = kvp.Value.Poly3d.GetPointAtParameter(param); pts.Add(pt3d); } using (Transaction tr = db.TransactionManager.StartTransaction()) { //Регистрация приложения Utils.RegisterApp(db, tr); ObjectId layerId = Utils.CreateLayerIfNotExists("ВОДОСБРОС", db, tr, null, Color.FromColorIndex(ColorMethod.ByAci, 150), LineWeight.LineWeight030); BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); //Вычерчивание 3d полилинии по линии водосброса using (Polyline3d poly3d = new Polyline3d()) { poly3d.LayerId = layerId; poly3d.PolyType = Poly3dType.SimplePoly; ms.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); foreach (Point3d pt in pts) { PolylineVertex3d vertex = new PolylineVertex3d(pt); poly3d.AppendVertex(vertex); tr.AddNewlyCreatedDBObject(vertex, true); } //В расширенные данные записать название водосброса poly3d.XData = new ResultBuffer( new TypedValue(1001, Constants.AppName), new TypedValue(1000, spillwayNum.ToString())); } tr.Commit(); } Vector3d baseVector = Vector3d.YAxis; int sign = Math.Sign(baseVector.CrossProduct(spillWayVector).Z); double rotation = spillWayVector.GetAngleTo(baseVector) * sign; //в радианах rotation = rotation * 180 / (Math.PI); //в градусах List <Slope> slopes = new List <Slope>(); //Сохраниение расположения водосброса и всех уклонов for (int i = 0; i < pts.Count - 1; i++) { Point3d pt1 = pts[i]; Point3d pt2 = pts[i + 1]; Point2d pt1_2d = new Point2d(pt1.X, pt1.Y); Point2d pt2_2d = new Point2d(pt2.X, pt2.Y); double len = pt1_2d.GetDistanceTo(pt2_2d); if (len > 0) { double s = (pt2.Z - pt1.Z) / len; slopes.Add(new Slope() { S = s, Len = len }); } } SpillwayPosition spillwayPosition = new SpillwayPosition() { Name = spillwayNum.ToString(), X = pts[0].X, Y = pts[0].Y, Z = pts[0].Z, Z_Rotation = rotation, ToTheRight = toTheRight.Value, Slopes = slopes }; spillwayNum++; positionData.SpillwayPositions.Add(spillwayPosition); } } } } else { //ed.WriteMessage("\nвыбор закончен"); break; } } //ed.WriteMessage("\nпродолжение выполнения"); //Сериализация расположений. Сохранить xml в папку рядом с файлом if (positionData.SpillwayPositions.Count > 0) { //TODO: Учесть возможные ошибки из-за отсутствия прав string filename = null; int n = 0; do { filename = Path.Combine(Path.GetDirectoryName(adoc.Name), Path.GetFileNameWithoutExtension(adoc.Name) /*"SpillwayPositions"*/ + "_" + n + ".xml"); n++; } while (File.Exists(filename)); XmlSerializer xmlSerializer = new XmlSerializer(typeof(PositionData)); using (StreamWriter sw = new StreamWriter(filename)) { xmlSerializer.Serialize(sw, positionData); } //Cообщение о том, что все выполнено ed.WriteMessage("\nПоложение водосбросов сохранено в файле " + filename); } } } catch (System.Exception ex) { //Utils.ErrorToCommandLine(ed, "Ошибка при извлечении расположений водосбросов", ex); CommonException(ex, "Ошибка при извлечении расположений водосбросов"); } finally { foreach (Polyline3d p3d in highlighted) { p3d.Unhighlight(); } } }
private static Entity DrawPart(Segment[] segs, Point[] points, Point[] densifiedPoints, bool closePart, bool hasZ, double defaultElevation) { double num = 0.0; if (segs != null) { if (segs.Length == 1) { CircularArc circularArc = segs[0] as CircularArc; EllipticArc ellipticArc = segs[0] as EllipticArc; BezierCurve bezierCurve = segs[0] as BezierCurve; ArcGIS10Types.Line line = segs[0] as ArcGIS10Types.Line; if (circularArc != null) { if (((PointN)circularArc.FromPoint).X == ((PointN)circularArc.ToPoint).X && ((PointN)circularArc.FromPoint).Y == ((PointN)circularArc.ToPoint).Y) { return(GIS2CAD.DrawCircle(circularArc, defaultElevation)); } return(GIS2CAD.DrawCircularArc(circularArc, defaultElevation, densifiedPoints)); } else if (ellipticArc != null) { if (!ellipticArc.IsCounterClockwise) { return(AGSEllipticalArc.ToCadSpline(ellipticArc, defaultElevation)); } return(AGSEllipticalArc.ToCadEllipse(ellipticArc, defaultElevation)); } else { if (line != null) { return(GIS2CAD.DrawPolyline(densifiedPoints, false)); } if (bezierCurve != null) { return(GIS2CAD.DrawPolyline(densifiedPoints, closePart)); } } } else if (segs.Length > 1) { PointN pointN = segs[0].FromPoint as PointN; num = pointN.Z; if (num == 0.0) { num = defaultElevation; } if (GIS2CAD.CanBeDrawnAsPolyline(segs)) { var polyline = new Autodesk.AutoCAD.DatabaseServices.Polyline(); polyline.ColorIndex = (256); int num2 = 0; PointN pointN2 = (PointN)segs[0].ToPoint; for (int i = 0; i < segs.Length; i++) { Segment segment = segs[i]; CircularArc circularArc2 = segment as CircularArc; var line2 = segment as ArcGIS10Types.Line; if (line2 != null) { PointN pointN3 = (PointN)line2.FromPoint; polyline.AddVertexAt(num2++, new Point2d(pointN3.X, pointN3.Y), 0.0, -1.0, -1.0); pointN2 = (PointN)line2.ToPoint; } else if (circularArc2 != null) { PointN pointN4 = (PointN)circularArc2.CenterPoint; PointN pointN5 = (PointN)circularArc2.FromPoint; PointN pointN6 = (PointN)circularArc2.ToPoint; new Point2d(pointN5.X - pointN4.X, pointN5.Y - pointN4.Y); new Point2d(pointN6.X - pointN4.X, pointN6.Y - pointN4.Y); Point2d point2d = new Point2d(pointN5.X, pointN5.Y); Point2d centerPoint = new Point2d(pointN4.X, pointN4.Y); Point2d point2d2 = new Point2d(pointN6.X, pointN6.Y); double num3 = Math.Abs(centerPoint.GetDistanceTo(point2d)); double num4 = Math.Abs(point2d.GetDistanceTo(point2d2)); double num5 = num3; double num6 = num3; double d = (num5 * num5 + num6 * num6 - num4 * num4) / (2.0 * num5 * num6); double num7 = Math.Acos(d); num7 = GIS2CAD.CalcThetaFromVectors(point2d, point2d2, centerPoint, circularArc2.IsCounterClockwise); double num8 = Math.Tan(num7 / 4.0); if (!circularArc2.IsCounterClockwise) { num8 *= -1.0; } polyline.AddVertexAt(num2++, point2d, num8, -1.0, -1.0); pointN2 = pointN6; } } polyline.AddVertexAt(num2, new Point2d(pointN2.X, pointN2.Y), 0.0, -1.0, -1.0); if (closePart) { polyline.Closed = (true); } return(polyline); } return(GIS2CAD.Draw3dPline(densifiedPoints, closePart)); } } else if (points != null) { if (points.Length == 2) { var line3 = new Autodesk.AutoCAD.DatabaseServices.Line(); line3.ColorIndex = (256); GIS2CAD.AdjustZ(ref points, defaultElevation); Point3d startPoint = GIS2CAD.ToCadPoint3d((PointN)points[0]); Point3d endPoint = GIS2CAD.ToCadPoint3d((PointN)points[1]); line3.StartPoint = (startPoint); line3.EndPoint = (endPoint); return(line3); } if (points.Length > 0) { if (!GIS2CAD.IsPlanar(points)) { try { Document document = AfaDocData.ActiveDocData.Document; var database = document.Database; var transactionManager = document.TransactionManager; using (document.LockDocument()) { using (Transaction transaction = transactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(database.BlockTableId, 0); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[(BlockTableRecord.ModelSpace)], (OpenMode)1); Polyline3d polyline3d = new Polyline3d(); polyline3d.ColorIndex = (256); blockTableRecord.AppendEntity(polyline3d); transaction.AddNewlyCreatedDBObject(polyline3d, true); Point[] array = points; for (int j = 0; j < array.Length; j++) { PointN srcPt = (PointN)array[j]; PolylineVertex3d polylineVertex3d = new PolylineVertex3d(GIS2CAD.ToCadPoint3d(srcPt)); polyline3d.AppendVertex(polylineVertex3d); transaction.AddNewlyCreatedDBObject(polylineVertex3d, true); } if (closePart) { polyline3d.Closed = (true); } document.TransactionManager.QueueForGraphicsFlush(); document.TransactionManager.FlushGraphics(); document.Editor.UpdateScreen(); transaction.Commit(); return(polyline3d); } } } catch (System.Exception ex) { string arg_526_0 = ex.Message; } } var polyline2 = new Autodesk.AutoCAD.DatabaseServices.Polyline(); polyline2.ColorIndex = (256); polyline2.Elevation = (num); num = ((PointN)points[0]).Z; if (num == 0.0) { num = defaultElevation; } int num9 = 0; Point[] array2 = points; for (int k = 0; k < array2.Length; k++) { PointN pointN7 = (PointN)array2[k]; polyline2.AddVertexAt(num9++, new Point2d(pointN7.X, pointN7.Y), 0.0, -1.0, -1.0); } if (closePart) { polyline2.Closed = (true); } return(polyline2); } } return(null); }
public static void UpdateSurface(ObjectId objectId, dynamic xb) { Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor; Document acDoc = acApp.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Point3d minPoint = new Point3d(Convert.ToDouble(xb.x1), Convert.ToDouble(xb.y1), Convert.ToDouble(xb.z1)); Point3d maxPoint = new Point3d(Convert.ToDouble(xb.x2), Convert.ToDouble(xb.y2), Convert.ToDouble(xb.z2)); using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { // Open the Block table record for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Point3d pStart = minPoint; Point3d pEnd = new Point3d(maxPoint.X, maxPoint.Y, minPoint.Z); Vector3d vec = new Vector3d(0, 0, maxPoint.Z - minPoint.Z); if (minPoint.Z == maxPoint.Z) { pStart = minPoint; pEnd = new Point3d(maxPoint.X, minPoint.Y, maxPoint.Z); vec = new Vector3d(0, maxPoint.Y - minPoint.Y, 0); } // Create polyline Polyline3d poly = new Polyline3d(); acBlkTblRec.AppendEntity(poly); acTrans.AddNewlyCreatedDBObject(poly, true); // Add vertex foreach (Point3d pnt in new List <Point3d>() { pStart, pEnd }) { PolylineVertex3d vex3d = new PolylineVertex3d(pnt); poly.AppendVertex(vex3d); acTrans.AddNewlyCreatedDBObject(vex3d, true); } poly.Closed = false; #if BRX_APP ExtrudedSurface extrSurf = (Teigha.DatabaseServices.ExtrudedSurface)acTrans.GetObject(objectId, OpenMode.ForWrite); #elif ARX_APP ExtrudedSurface extrSurf = (Autodesk.AutoCAD.DatabaseServices.ExtrudedSurface)acTrans.GetObject(objectId, OpenMode.ForWrite); #endif extrSurf.SetDatabaseDefaults(); SweepOptions sweepOpts = new SweepOptions(); extrSurf.CreateExtrudedSurface(poly, vec, sweepOpts); extrSurf.UIsoLineDensity = 0; extrSurf.VIsoLineDensity = 0; extrSurf.Draw(); poly.Erase(); acTrans.Commit(); ed.UpdateScreen(); } }
public static void Lay() { bool promptGradient = false; int gradient = 0; Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; PromptKeywordOptions pKeyOpts = new PromptKeywordOptions(""); pKeyOpts.Message = "\nPlease enter mode"; pKeyOpts.Keywords.Add("Gradient"); pKeyOpts.Keywords.Add("Storm"); pKeyOpts.Keywords.Add("Foul"); pKeyOpts.Keywords.Default = "Storm"; pKeyOpts.AllowNone = true; PromptResult pKeyRes = acDoc.Editor.GetKeywords(pKeyOpts); switch (pKeyRes.StringResult) { case "Gradient": promptGradient = true; break; case "Storm": gradient = 100; break; case "Foul": gradient = 80; break; } PromptStringOptions pStrOpts; PromptResult pStrRes; bool run = true; while (run) { if (promptGradient) { //Prompt for the gradient pStrOpts = new PromptStringOptions("\nEnter gradient: "); pStrRes = acDoc.Editor.GetString(pStrOpts); gradient = Int32.Parse(pStrRes.StringResult); } PromptPointResult pPtRes; PromptPointOptions pPtOpts = new PromptPointOptions(""); // Prompt for the start point pPtOpts.Message = "\nEnter the start point of the line: "; pPtRes = acDoc.Editor.GetPoint(pPtOpts); if (pPtRes.Status == PromptStatus.Cancel) { run = false; break; } Point3d ptStart = pPtRes.Value; //Prompt for the starting IL pStrOpts = new PromptStringOptions("\nEnter starting IL: "); pStrOpts.AllowSpaces = true; pStrOpts.DefaultValue = ptStart.Z.ToString(); pStrRes = acDoc.Editor.GetString(pStrOpts); if (pStrRes.Status == PromptStatus.Cancel) { run = false; break; } double invert = double.Parse(pStrRes.StringResult); // Prompt for the end point pPtOpts.Message = "\nEnter the end point of the line: "; pPtRes = acDoc.Editor.GetPoint(pPtOpts); if (pPtRes.Status == PromptStatus.Cancel) { run = false; break; } Point3d ptEnd = pPtRes.Value; //Adjust start coordinate IL ptStart = new Point3d(ptStart.X, ptStart.Y, invert); //Set to plane for accurate distance measure //Adjust end coordinate to gradient Point3d temp = new Point3d(ptEnd.X, ptEnd.Y, ptStart.Z); //Set to plane for accurate distance measure double distance = Math.Abs(temp.DistanceTo(ptStart)); double fall = distance / gradient; fall = Math.Round(fall, 3); ptEnd = new Point3d(temp.X, temp.Y, temp.Z - fall); using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { // Open the Block table record for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record M odel space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // Create a 3D polyline using (Polyline3d acPoly3d = new Polyline3d()) { // Add the new object to the block table record and the transaction acBlkTblRec.AppendEntity(acPoly3d); acTrans.AddNewlyCreatedDBObject(acPoly3d, true); // Before adding vertexes, the polyline must be in the drawing Point3dCollection acPts3dPoly = new Point3dCollection(); acPts3dPoly.Add(ptStart); acPts3dPoly.Add(ptEnd); foreach (Point3d acPt3d in acPts3dPoly) { using (PolylineVertex3d acPolVer3d = new PolylineVertex3d(acPt3d)) { acPoly3d.AppendVertex(acPolVer3d); acTrans.AddNewlyCreatedDBObject(acPolVer3d, true); } } Annotate(acPoly3d); } // Save the new object to the database acTrans.Commit(); } } }
public void Figura1() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db); Editor ed = doc.Editor; PromptDoubleOptions GetIlgis = new PromptDoubleOptions("\nĮveskite mikroskemos ilgį"); double Ilgis; GetIlgis.AllowNegative = false; GetIlgis.AllowZero = false; GetIlgis.AllowNone = false; PromptDoubleResult GetIlgisRezultatas = ed.GetDouble(GetIlgis); Ilgis = GetIlgisRezultatas.Value; PromptDoubleOptions GetPlotis = new PromptDoubleOptions("\nĮveskite mikroskemos plotį"); double Plotis; GetPlotis.AllowNegative = false; GetPlotis.AllowZero = false; GetPlotis.AllowNone = false; PromptDoubleResult GetPlotisRezultatas = ed.GetDouble(GetPlotis); Plotis = GetPlotisRezultatas.Value; PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite tašką"); Point3d Taskas; GetTaskas.AllowNone = false; PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas); Taskas = GetTaskasRezultatas.Value; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite,false); Polyline3d polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); PolylineVertex3d vex3d = new PolylineVertex3d(); //Pradinis taskas vex3d = new PolylineVertex3d(Taskas); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp pradinio ir pirmo kampo double betaIlgis = Ilgis / 8; double AtsakosIlgis = Math.Min(Ilgis / 4, Plotis / 4); for (int i = 1; i < 8; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X, Taskas.Y + betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X - AtsakosIlgis, Taskas.Y + betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X, Taskas.Y + betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } // Pirmas kampas vex3d = new PolylineVertex3d(new Point3d(Taskas.X, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp pirmo ir angtro kampo double betaPlotis = Plotis / 2; for (int i = 1; i < 2; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X + betaPlotis * i, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X + betaPlotis * i, Taskas.Y + Ilgis + AtsakosIlgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X + betaPlotis * i, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } //Antras kampas vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp antro ir trecio kampo for (int i = 1; i < 8; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y + Ilgis - betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis + AtsakosIlgis, Taskas.Y + Ilgis - betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y + Ilgis - betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } //Trecias kampas vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp trecio ir pradinio kampo for (int i = 1; i < 2; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis - betaPlotis * i, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis - betaPlotis * i, Taskas.Y - AtsakosIlgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis - betaPlotis * i, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } //Ketvirtas kampas / Pradinis taskas vex3d = new PolylineVertex3d(Taskas); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); tr.Commit(); } }
public void Figura2() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db); Editor ed = doc.Editor; PromptDoubleOptions GetSpindulys = new PromptDoubleOptions("\nĮveskite detalės spindulį"); double Spindulys; GetSpindulys.AllowNegative = false; GetSpindulys.AllowZero = false; GetSpindulys.AllowNone = false; PromptDoubleResult GetSpindulysRezultatas = ed.GetDouble(GetSpindulys); Spindulys = GetSpindulysRezultatas.Value; PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite centro tašką"); Point3d Taskas; GetTaskas.AllowNone = false; PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas); Taskas = GetTaskasRezultatas.Value; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); //Apskritimas Circle Apskritimas = new Circle(Taskas, new Vector3d(0, 0, 1), Spindulys); btr.AppendEntity(Apskritimas); tr.AddNewlyCreatedDBObject(Apskritimas, true); //Linijos Polyline3d polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); PolylineVertex3d vex3d = new PolylineVertex3d(); // Linija NR1 (centrine) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2 + Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2 - Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2 - Spindulys / 1.5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); // Linija NR2 (virsutine) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2 + Spindulys / 5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2 - Spindulys / 5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y + Spindulys / 2 + Spindulys / 1.5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); // Linija NR3 (kaire) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2 - Spindulys / 2 - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Apskritimas FIll Viduryje Circle ApskritimasFillMIni = new Circle(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0), new Vector3d(0, 0, 1), Spindulys / 8); btr.AppendEntity(ApskritimasFillMIni); tr.AddNewlyCreatedDBObject(ApskritimasFillMIni, true); Hatch hatch = new Hatch(); btr.AppendEntity(hatch); tr.AddNewlyCreatedDBObject(hatch, true); ObjectIdCollection ID = new ObjectIdCollection(); ID.Add(ApskritimasFillMIni.ObjectId); hatch.HatchStyle = HatchStyle.Ignore; hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); hatch.Associative = true; hatch.AppendLoop(HatchLoopTypes.Outermost, ID); hatch.EvaluateHatch(true); //Trikampis Solid trikampis = new Solid(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y, 0), new Point3d(Taskas.X, Taskas.Y + Spindulys / 6, 0), new Point3d(Taskas.X, Taskas.Y - Spindulys / 6, 0)); btr.AppendEntity(trikampis); tr.AddNewlyCreatedDBObject(trikampis, true); tr.Commit(); } }
public static void Polyline_2D_3D() { // 获取当前文档和数据库,启动事务 var acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; var acCurDb = acDoc.Database; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { // Open the Block table record for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // 以写模式打开块表记录模型空间 BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // 用2条线段(3个点)创建一条多段线 var acPoly = new Polyline(); acPoly.AddVertexAt(0, new Point2d(1, 1), 0, 0, 0); acPoly.AddVertexAt(1, new Point2d(1, 2), 0, 0, 0); acPoly.AddVertexAt(2, new Point2d(2, 2), 0, 0, 0); acPoly.ColorIndex = 1; // 将新对象添加到块表记录和事务 acBlkTblRec.AppendEntity(acPoly); acTrans.AddNewlyCreatedDBObject(acPoly, true); // 用2条线段(3个点)创建一条3D多段线 var acPoly3d = new Polyline3d(); acPoly3d.ColorIndex = 5; // 将新对象添加到块表记录和事务 acBlkTblRec.AppendEntity(acPoly3d); acTrans.AddNewlyCreatedDBObject(acPoly3d, true); // Before adding vertexes, the polyline must be in the drawing // 先创建多段线对象,然后才能给它添加顶点 var acPts3dPoly = new Point3dCollection(); acPts3dPoly.Add(new Point3d(1, 1, 0)); acPts3dPoly.Add(new Point3d(2, 1, 0)); acPts3dPoly.Add(new Point3d(2, 2, 0)); foreach (Point3d acPt3d in acPts3dPoly) { var acPolVer3d = new PolylineVertex3d(acPt3d); acPoly3d.AppendVertex(acPolVer3d); acTrans.AddNewlyCreatedDBObject(acPolVer3d, true); } // 获取多段线的顶点坐标 var acPts2d = new Point2dCollection(); for (var nCnt = 0; nCnt < acPoly.NumberOfVertices; nCnt++) { acPts2d.Add(acPoly.GetPoint2dAt(nCnt)); } // 获取3D多段线的顶点坐标 var acPts3d = new Point3dCollection(); foreach (ObjectId acObjIdVert in acPoly3d) { PolylineVertex3d acPolVer3d; acPolVer3d = acTrans.GetObject(acObjIdVert, OpenMode.ForRead) as PolylineVertex3d; acPts3d.Add(acPolVer3d.Position); } // 显示坐标 Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("2D polyline (red): \n" + acPts2d[0] + "\n" + acPts2d[1] + "\n" + acPts2d[2]); Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowAlertDialog("3D polyline (blue): \n" + acPts3d[0] + "\n" + acPts3d[1] + "\n" + acPts3d[2]); //提交事务 acTrans.Commit(); } }
public void Figura1() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db); Editor ed = doc.Editor; PromptDoubleOptions GetIlgis = new PromptDoubleOptions("\nĮveskite mikroskemos ilgį"); double Ilgis; GetIlgis.AllowNegative = false; GetIlgis.AllowZero = false; GetIlgis.AllowNone = false; PromptDoubleResult GetIlgisRezultatas = ed.GetDouble(GetIlgis); Ilgis = GetIlgisRezultatas.Value; PromptDoubleOptions GetPlotis = new PromptDoubleOptions("\nĮveskite mikroskemos plotį"); double Plotis; GetPlotis.AllowNegative = false; GetPlotis.AllowZero = false; GetPlotis.AllowNone = false; PromptDoubleResult GetPlotisRezultatas = ed.GetDouble(GetPlotis); Plotis = GetPlotisRezultatas.Value; PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite tašką"); Point3d Taskas; GetTaskas.AllowNone = false; PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas); Taskas = GetTaskasRezultatas.Value; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); Polyline3d polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); PolylineVertex3d vex3d = new PolylineVertex3d(); //Pradinis taskas vex3d = new PolylineVertex3d(Taskas); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp pradinio ir pirmo kampo double betaIlgis = Ilgis / 8; double AtsakosIlgis = Math.Min(Ilgis / 4, Plotis / 4); for (int i = 1; i < 8; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X, Taskas.Y + betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X - AtsakosIlgis, Taskas.Y + betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X, Taskas.Y + betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } // Pirmas kampas vex3d = new PolylineVertex3d(new Point3d(Taskas.X, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp pirmo ir angtro kampo double betaPlotis = Plotis / 2; for (int i = 1; i < 2; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X + betaPlotis * i, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X + betaPlotis * i, Taskas.Y + Ilgis + AtsakosIlgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X + betaPlotis * i, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } //Antras kampas vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y + Ilgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp antro ir trecio kampo for (int i = 1; i < 8; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y + Ilgis - betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis + AtsakosIlgis, Taskas.Y + Ilgis - betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y + Ilgis - betaIlgis * i, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } //Trecias kampas vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos tarp trecio ir pradinio kampo for (int i = 1; i < 2; i++) { // Linija iki atsakos vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis - betaPlotis * i, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos linija vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis - betaPlotis * i, Taskas.Y - AtsakosIlgis, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Atsakos grizimas atgal i kontura vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Plotis - betaPlotis * i, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); } //Ketvirtas kampas / Pradinis taskas vex3d = new PolylineVertex3d(Taskas); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); tr.Commit(); } }
public void LandXmlHandling() { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; settings.IgnoreComments = true; int pntListCount = 0; int profileCount = 0; int pviCount = 0; string[] fileNames = OpenFiles(); foreach (string fileName in fileNames) { XmlReader reader = XmlReader.Create(fileName, settings); List <string> alignmentCollection = new List <string>(); List <List <double> > pntListCollection = new List <List <double> >(); List <double> pviList = new List <double>(); try { while (reader.Read()) { if (reader.IsStartElement() == true) { switch (reader.Name) { case "PntList2D": pntListCount++; reader.Read(); Console.WriteLine("{0}.PntList", pntListCount); Console.WriteLine(reader.Value); Console.ReadLine(); List <double> pntList = new List <double>(); string[] pntListStr = reader.Value.Split(' '); for (int i = 0; i < pntListStr.Length; i += 2) { pntList.Add(Convert.ToDouble(pntListStr[i + 1])); pntList.Add(Convert.ToDouble(pntListStr[i])); Console.WriteLine("{0}", pntList[i]); } pntListCollection.Add(pntList); break; case "ProfAlign": if (pntListCollection.Count == 0) { break; } profileCount++; Console.WriteLine("{0}.Profile", profileCount); Console.WriteLine(reader.Value); Console.ReadLine(); alignmentCollection.Add(reader.GetAttribute("name")); break; case "PVI": if (pntListCollection.Count == 0) { break; } pviCount++; reader.Read(); Console.WriteLine(reader.Value); Console.ReadLine(); string[] pviListStr = reader.Value.Split(' '); pviList.Add(Convert.ToDouble(pviListStr[1])); break; default: break; } } } } catch (Exception) { throw; } //----------------------------------------------------------// //---------------MERGING PVI LIST TO THE POINT LIST---------// //----------------------------------------------------------// int k = 0; while (k < pviList.Count) { foreach (List <double> item in pntListCollection) { int i = 2; do { item.Insert(i, pviList[k]); i += 3; k++; } while (i <= item.Count); } } //----------------------------------------------------------// //---------------CREEATING LAYERS----------------------------// //----------------------------------------------------------// foreach (string alignment in alignmentCollection) { CreateLayer(alignment); } //---------------CREATING 3DPOLYLINE-----------// using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { BlockTable acBlkTbl; acBlkTbl = ts.GetObject(Db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec; acBlkTblRec = ts.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; int sayac = 0; foreach (List <double> item in pntListCollection) { Polyline3d poly = new Polyline3d(); acBlkTblRec.AppendEntity(poly); for (int i = 0; i < item.Count; i += 3) { Point3d pnt = new Point3d(item[i], item[i + 1], item[i + 2]); PolylineVertex3d vertex = new PolylineVertex3d(pnt); poly.AppendVertex(vertex); ts.AddNewlyCreatedDBObject(vertex, true); } poly.Layer = alignmentCollection[sayac]; sayac++; ts.AddNewlyCreatedDBObject(poly, true); } ts.Commit(); } } }
public void Figura2() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db); Editor ed = doc.Editor; PromptDoubleOptions GetSpindulys = new PromptDoubleOptions("\nĮveskite detalės spindulį"); double Spindulys; GetSpindulys.AllowNegative = false; GetSpindulys.AllowZero = false; GetSpindulys.AllowNone = false; PromptDoubleResult GetSpindulysRezultatas = ed.GetDouble(GetSpindulys); Spindulys = GetSpindulysRezultatas.Value; PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite centro tašką"); Point3d Taskas; GetTaskas.AllowNone = false; PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas); Taskas = GetTaskasRezultatas.Value; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); //Apskritimas Circle Apskritimas = new Circle(Taskas, new Vector3d(0, 0, 1), Spindulys); btr.AppendEntity(Apskritimas); tr.AddNewlyCreatedDBObject(Apskritimas, true); //Linijos Polyline3d polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); PolylineVertex3d vex3d = new PolylineVertex3d(); // Linija NR1 (centrine) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2 + Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2 - Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2 - Spindulys / 1.5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); // Linija NR2 (virsutine) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2 + Spindulys / 5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2 - Spindulys / 5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y + Spindulys / 2 + Spindulys / 1.5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); // Linija NR3 (kaire) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2 - Spindulys / 2 - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Apskritimas FIll Viduryje Circle ApskritimasFillMIni = new Circle(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0), new Vector3d(0, 0, 1), Spindulys / 8); btr.AppendEntity(ApskritimasFillMIni); tr.AddNewlyCreatedDBObject(ApskritimasFillMIni, true); Hatch hatch = new Hatch(); btr.AppendEntity(hatch); tr.AddNewlyCreatedDBObject(hatch, true); ObjectIdCollection ID = new ObjectIdCollection(); ID.Add(ApskritimasFillMIni.ObjectId); hatch.HatchStyle = HatchStyle.Ignore; hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); hatch.Associative = true; hatch.AppendLoop(HatchLoopTypes.Outermost, ID); hatch.EvaluateHatch(true); //Trikampis Solid trikampis = new Solid(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y, 0), new Point3d(Taskas.X, Taskas.Y + Spindulys / 6, 0), new Point3d(Taskas.X, Taskas.Y - Spindulys / 6, 0)); btr.AppendEntity(trikampis); tr.AddNewlyCreatedDBObject(trikampis, true); tr.Commit(); } }