Esempio n. 1
0
        addPoly3d(Point3dCollection pnt3ds, string nameLayer = "0", short color = 256, LineWeight weight = LineWeight.ByLayer)
        {
            ObjectId   idPoly3d = ObjectId.Null;
            Polyline3d poly3d   = null;

            try
            {
                using (BaseObjs._acadDoc.LockDocument())
                {
                    BaseObjs._transactionManagerDoc.EnableGraphicsFlush(true);
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                        poly3d = new Polyline3d(Poly3dType.SimplePoly, pnt3ds, false);

                        Layer.manageLayers(nameLayer);
                        poly3d.Layer      = nameLayer;
                        poly3d.Color      = Color.FromColorIndex(ColorMethod.ByLayer, color);
                        poly3d.LineWeight = weight;

                        idPoly3d = MS.AppendEntity(poly3d);
                        tr.AddNewlyCreatedDBObject(poly3d, true);
                        tr.Commit();
                    }// end using
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 477");
            }
            return(idPoly3d);
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        addPolyFromPoly3d(ObjectId idPoly3d, string nameLayer = "0")
        {
            ObjectId idPoly = ObjectId.Null;
            Polyline poly   = new Polyline();

            Layer.manageLayers(nameLayer);
            poly.Layer = nameLayer;
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();
                    int i = -1;
                    poly.SetDatabaseDefaults();
                    foreach (Point3d pnt3d in idPoly3d.getCoordinates3d())
                    {
                        i = ++i;
                        Point2d pnt2d = new Point2d(pnt3d.X, pnt3d.Y);
                        poly.AddVertexAt(i, pnt2d, 0, 0, 0);
                    }
                    idPoly = MS.AppendEntity(poly);
                    tr.AddNewlyCreatedDBObject(poly, true);
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 606");
            }

            return(idPoly);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        addPoly3d(Point3dCollection pnt3ds, string nameLayer)
        {
            ObjectId idPoly3d = ObjectId.Null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    try
                    {
                        BlockTableRecord MS     = Blocks.getBlockTableRecordMS();
                        Polyline3d       poly3d = new Polyline3d(Poly3dType.SimplePoly, pnt3ds, false);

                        Layer.manageLayers(nameLayer);
                        poly3d.Layer = nameLayer;

                        idPoly3d = MS.AppendEntity(poly3d);
                        tr.AddNewlyCreatedDBObject(poly3d, true);
                        tr.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 561");
                    }
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 567");
            }

            return(idPoly3d);
        }
Esempio n. 6
0
        addPoly(Point3dCollection pnt3ds, string nameLayer = "0", short color = 256)
        {
            ObjectId idPoly = ObjectId.Null;
            Point2d  pnt2d;
            Polyline poly = new Polyline();

            Layer.manageLayers(nameLayer);
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                    int i = -1;
                    poly.SetDatabaseDefaults();
                    foreach (Point3d pnt3d in pnt3ds)
                    {
                        i     = ++i;
                        pnt2d = new Point2d(pnt3d.X, pnt3d.Y);
                        poly.AddVertexAt(i, pnt2d, 0, 0, 0);
                    }
                    poly.Layer = nameLayer;
                    poly.Color = Color.FromColorIndex(ColorMethod.ByBlock, color);
                    idPoly     = MS.AppendEntity(poly);
                    tr.AddNewlyCreatedDBObject(poly, true);
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 332");
            }
            return(idPoly);
        }
Esempio n. 7
0
        addLineOffset(ObjectId idLine, double distOffset)
        {
            ObjectId idNewLine = ObjectId.Null;
            int      side      = -1;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    Line   line = (Line)tr.GetObject(idLine, OpenMode.ForRead);
                    double dir  = line.Angle;
                    if (distOffset < 0)
                    {
                        side = 1;
                    }
                    Point3d          pnt3dBeg = line.StartPoint.traverse(dir + System.Math.PI / 2 * side, System.Math.Abs(distOffset));
                    Point3d          pnt3dEnd = line.EndPoint.traverse(dir + System.Math.PI / 2 * side, System.Math.Abs(distOffset));
                    Line             newLine  = new Line(pnt3dBeg, pnt3dEnd);
                    BlockTableRecord MS       = Blocks.getBlockTableRecordMS();
                    idNewLine = MS.AppendEntity(newLine);
                    tr.AddNewlyCreatedDBObject(newLine, true);
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 227");
            }
            return(idNewLine);
        }
Esempio n. 8
0
        addArc(Point3d pnt3dCen, double radius, double angBeg, double angEnd, string nameLayer = "0", short color = 256)
        {
            ObjectId id = ObjectId.Null;

            Layer.manageLayers(nameLayer);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();
                    Arc arc             = new Arc(pnt3dCen, radius, angBeg, angEnd);

                    arc.SetDatabaseDefaults();
                    arc.Layer  = nameLayer;
                    arc.Color  = Color.FromColorIndex(ColorMethod.ByBlock, color);
                    arc.Center = pnt3dCen;
                    arc.Normal = new Vector3d(0, 0, 1);

                    id = MS.AppendEntity(arc);
                    tr.AddNewlyCreatedDBObject(arc, true);
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 43");
            }

            return(id);
        }
Esempio n. 9
0
        addLine(Point3d pntBEG, Point3d pntEND, string nameLayer = "0", short color = 256, LineWeight weight = LineWeight.ByLayer)
        {
            ObjectId idLine = ObjectId.Null;
            Line     line   = new Line();

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                    line.SetDatabaseDefaults();
                    line.StartPoint = pntBEG;
                    line.EndPoint   = pntEND;

                    Layer.manageLayers(nameLayer);
                    line.Layer = nameLayer;

                    line.Color      = Color.FromColorIndex(ColorMethod.ByBlock, color);
                    line.LineWeight = weight;
                    idLine          = MS.AppendEntity(line);
                    tr.AddNewlyCreatedDBObject(line, true);
                    tr.Commit();
                }//end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 195");
            }

            return(idLine);
        }
Esempio n. 10
0
        addCircle(Point3d pntCEN, double RADIUS, string nameLayer = "0", short color = 256)
        {
            ObjectId id     = ObjectId.Null;
            Circle   circle = new Circle();

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                    circle.SetDatabaseDefaults();
                    circle.Center = pntCEN;
                    circle.Radius = RADIUS;
                    Layer.manageLayers(nameLayer);
                    circle.Layer = nameLayer;
                    circle.Color = Color.FromColorIndex(ColorMethod.ByBlock, color);

                    id = MS.AppendEntity(circle);
                    tr.AddNewlyCreatedDBObject(circle, true);

                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 116");
            }

            return(id);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        addLdr(Point3dCollection pnt3ds, bool isSplined = false, MText mTxt = null, string nameLayer = "0", short color = 256)
        {
            ObjectId idLdr = ObjectId.Null;
            Leader   ldr   = new Leader();
            double   scale = Misc.getCurrAnnoScale();

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                    ldr.SetDatabaseDefaults();
                    ldr.HasArrowHead = true;
                    ldr.IsSplined    = isSplined;
                    ldr.Dimasz       = scale * 0.09;

                    Layer.manageLayers(nameLayer);
                    ldr.Layer = nameLayer;
                    ldr.Color = Color.FromColorIndex(ColorMethod.ByBlock, color);

                    foreach (Point3d pnt3d in pnt3ds)
                    {
                        ldr.AppendVertex(pnt3d);
                    }
                    idLdr = MS.AppendEntity(ldr);
                    tr.AddNewlyCreatedDBObject(ldr, true);
                    if (mTxt != null)
                    {
                        ldr.Annotation = mTxt.ObjectId;
                        ldr.Dimtad     = 0;
                        ldr.EvaluateLeader();
                    }
                    ldr.Annotative = AnnotativeStates.True;
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 162");
            }

            return(idLdr);
        }
Esempio n. 13
0
        clone(ObjectIdCollection ids, Point3d pnt3dBase)
        {
            Database           db     = BaseObjs._db;
            ObjectIdCollection idsNew = new ObjectIdCollection();

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord ms = Blocks.getBlockTableRecordMS();

                    foreach (ObjectId id in ids)
                    {
                        Entity ent     = (Entity)tr.GetObject(id, OpenMode.ForRead);
                        Entity entCopy = (Entity)ent.Clone();
                        ms.AppendEntity(entCopy);
                        tr.AddNewlyCreatedDBObject(entCopy, true);
                        idsNew.Add(entCopy.ObjectId);
                    }

                    db.Dispose();
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Blocks.cs: line: 671");
            }

            JigDraw jDraw = new JigDraw(pnt3dBase);

            jDraw.AddEntity(idsNew);

            PromptResult jRes = BaseObjs._editor.Drag(jDraw);

            if (jRes.Status == PromptStatus.OK)
            {
                jDraw.TransformEntities();
            }
            else
            {
                return;
            }
        }
Esempio n. 14
0
File: Txt.cs Progetto: 15831944/EM
        addText(string contents, Point3d pnt3d, double angle, AttachmentPoint attachPoint,
                string nameStyle = "Annotative", AnnotativeStates annoState = AnnotativeStates.True)
        {
            ObjectId idTxt = ObjectId.Null;
            Database DB    = BaseObjs._db;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord ms  = Blocks.getBlockTableRecordMS();
                    TextStyleTable   tst = (TextStyleTable)tr.GetObject(DB.TextStyleTableId, OpenMode.ForRead);

                    ObjectId idTxtStyle = ObjectId.Null;

                    if (!tst.Has(nameStyle))
                    {
                        makeTextStyle(nameStyle, annoState);
                        idTxtStyle = tst[nameStyle];
                    }

                    using (DBText txt = new DBText())
                    {
                        txt.SetDatabaseDefaults();
                        txt.TextString = contents;
                        txt.Position   = pnt3d;

                        txt.Rotation    = angle;
                        txt.Justify     = attachPoint;
                        txt.TextStyleId = idTxtStyle;

                        ms.AppendEntity(txt);
                        tr.AddNewlyCreatedDBObject(txt, true);
                        tr.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Txt.cs: line: 161");
            }
            return(idTxt);
        }
Esempio n. 15
0
File: Conv.cs Progetto: 15831944/EM
        convertLineToPolyline(this Line line, string nameLayer)
        {
            Point2d  p2dBeg = line.StartPoint.Convert2d(BaseObjs.xyPlane);
            Point2d  p2dEnd = line.EndPoint.Convert2d(BaseObjs.xyPlane);
            ObjectId idPoly = ObjectId.Null;
            Polyline poly   = new Polyline();

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                BlockTableRecord ms = Blocks.getBlockTableRecordMS();
                poly.SetDatabaseDefaults();
                poly.Layer = nameLayer;
                poly.AddVertexAt(0, p2dBeg, 0, 0, 0);
                poly.AddVertexAt(1, p2dEnd, 0, 0, 0);
                idPoly = ms.AppendEntity(poly);
                tr.AddNewlyCreatedDBObject(poly, true);
                tr.Commit();
            }
            return(idPoly);
        }
Esempio n. 16
0
        addDimRotated(Point3d pnt3d1, Point3d pnt3d2, Point3d pnt3dX, double rotation, ObjectId idStyle, string nameLayer, double dblTxtHeight, int precision)
        {
            ObjectId idDim = ObjectId.Null;

            Layer.manageLayers(nameLayer);
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS     = Blocks.getBlockTableRecordMS();
                    RotatedDimension rotDim = new RotatedDimension();

                    rotDim.XLine1Point    = pnt3d1;
                    rotDim.XLine2Point    = pnt3d2;
                    rotDim.DimLinePoint   = pnt3dX;
                    rotDim.DimensionStyle = idStyle;
                    rotDim.Annotative     = AnnotativeStates.True;
                    rotDim.Dimasz         = rotation;
                    try
                    {
                        rotDim.Layer = nameLayer;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 38");
                    }
                    rotDim.Dimtxt = dblTxtHeight;
                    rotDim.Dimdec = precision;

                    idDim = MS.AppendEntity(rotDim);
                    tr.AddNewlyCreatedDBObject(rotDim, true);

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 51");
            }
            return(idDim);
        }
Esempio n. 17
0
        addRegion(this ObjectId idEnt)
        {
            ObjectId idReg = ObjectId.Null;

            using (var tr = BaseObjs.startTransactionDb()){
                BlockTableRecord ms   = Blocks.getBlockTableRecordMS();
                Polyline         poly = (Polyline)tr.GetObject(idEnt, OpenMode.ForRead);

                DBObjectCollection dbObjs = new DBObjectCollection {
                    poly
                };

                DBObjectCollection dbRegions = new DBObjectCollection();
                dbRegions = Region.CreateFromCurves(dbObjs);
                Region region = (Region)dbRegions[0];
                ms.AppendEntity(region);
                tr.AddNewlyCreatedDBObject(region, true);
                tr.Commit();
            }
            return(idReg);
        }
Esempio n. 18
0
File: Conv.cs Progetto: 15831944/EM
        convertArcToPolyline(this Arc arc, string nameLayer)
        {
            Polyline poly   = new Polyline();
            Point2d  p2dBeg = arc.StartPoint.Convert2d(BaseObjs.xyPlane);
            Point2d  p2dEnd = arc.EndPoint.Convert2d(BaseObjs.xyPlane);
            int      n      = (arc.Normal.Z > 0) ? 1 : -1;
            double   bulge  = System.Math.Tan(arc.TotalAngle / 4) * n;
            ObjectId idPoly = ObjectId.Null;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                BlockTableRecord ms = Blocks.getBlockTableRecordMS();
                poly.SetDatabaseDefaults();
                poly.Layer = nameLayer;
                poly.AddVertexAt(0, p2dBeg, bulge, 0, 0);
                poly.AddVertexAt(1, p2dEnd, 0, 0, 0);
                idPoly = ms.AppendEntity(poly);
                tr.AddNewlyCreatedDBObject(poly, true);
                tr.Commit();
            }
            return(idPoly);
        }
Esempio n. 19
0
        addArc(Point3d pnt3dBeg, Point3d pnt3dEnd, double bulge, string nameLayer = "0", short color = 256)
        {
            ObjectId id = ObjectId.Null;

            Layer.manageLayers(nameLayer);

            double  delta    = Geom.getDelta(bulge);
            double  radius   = Geom.getRadius(pnt3dBeg, pnt3dEnd, bulge);
            double  AzChord  = Base_Tools45.Measure.getAzRadians(pnt3dBeg, pnt3dEnd);
            double  AzTan    = AzChord - delta / 2;
            double  angBeg   = (bulge < 0) ? AzTan + PI / 2 : AzTan - PI / 2;
            Point3d pnt3dCen = pnt3dBeg.traverse((AzTan + PI / 2), radius);
            double  angEnd   = pnt3dCen.getDirection(pnt3dEnd);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();
                    Arc arc             = new Arc(pnt3dCen, radius, angBeg, angEnd);

                    arc.SetDatabaseDefaults();
                    arc.Layer  = nameLayer;
                    arc.Color  = Color.FromColorIndex(ColorMethod.ByBlock, color);
                    arc.Normal = new Vector3d(0, 0, 1);

                    id = MS.AppendEntity(arc);
                    tr.AddNewlyCreatedDBObject(arc, true);
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 83");
            }

            return(id);
        }
Esempio n. 20
0
        addPoly(List <Vertex2d> vtxs2d, string nameLayer = "0", short color = 256)
        {
            ObjectId idPoly = ObjectId.Null;
            Polyline poly   = new Polyline();

            Layer.manageLayers(nameLayer);
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    BlockTableRecord MS = Blocks.getBlockTableRecordMS();

                    int i = -1;
                    poly.SetDatabaseDefaults();
                    foreach (Vertex2d vtx2d in vtxs2d)
                    {
                        i = ++i;
                        Point2d pnt2d = new Point2d(vtx2d.Position.X, vtx2d.Position.Y);
                        poly.AddVertexAt(i, pnt2d, vtx2d.Bulge, vtx2d.StartWidth, vtx2d.EndWidth);
                    }
                    Layer.manageLayers(nameLayer);
                    poly.Layer = nameLayer;
                    poly.Color = Color.FromColorIndex(ColorMethod.ByBlock, color);

                    idPoly = MS.AppendEntity(poly);
                    tr.AddNewlyCreatedDBObject(poly, true);
                    tr.Commit();
                }// end using
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 368");
            }

            return(idPoly);
        }
Esempio n. 21
0
        addSymbolAndWipeout(Point3d pnt3d, double angleView, out ObjectId idWO, double radius, int numSides, bool addWipeOut = false)
        {
            ObjectId idSYM = ObjectId.Null;

            double            pi         = System.Math.PI;
            double            pi2        = pi * 2.0;
            double            angleBase  = 0;
            double            length     = 0;
            double            delta      = 0;
            double            scale      = Misc.getCurrAnnoScale();
            double            deltaBegin = 0;
            Point2d           pnt2dBase  = Point2d.Origin;
            Point2dCollection pnts2d     = new Point2dCollection();
            Point2d           pnt2dCen   = new Point2d(pnt3d.X, pnt3d.Y);

            delta = 2 * pi / numSides;
            idWO  = ObjectId.Null;

            switch (numSides)
            {
            case 3:
                length    = 1.33 * scale * 2 * radius;
                pnt2dBase = pnt2dCen.traverse(angleView - pi / 2, length / 4);
                pnt2dBase = pnt2dBase.traverse(angleView, length / 2);
                pnts2d.Add(pnt2dBase);
                deltaBegin = delta + angleView;
                break;

            case 4:
                angleBase = angleView + 7.0 / 8.0 * pi2;
                length    = 0.5 * 1.68 * scale * radius * System.Math.Sqrt(2);
                pnt2dBase = pnt2dCen.traverse(angleBase, length);
                pnts2d.Add(pnt2dBase);
                length     = scale * 1.68 * radius;
                deltaBegin = delta + angleView;
                break;

            case 6:
                angleBase = angleView + 10.0 / 12.0 * pi2;
                //angleBase = angleView;
                length    = 1.03 * scale * radius / System.Math.Cos(delta / 3);
                pnt2dBase = pnt2dCen.traverse(angleBase, length);
                pnts2d.Add(pnt2dBase);     //pnt0
                deltaBegin = angleBase + 2 * delta;
                break;

            case 1024:
                //angleBase = angleView + 3.0 / 2.0 * pi;
                angleBase = angleView;
                length    = scale * 2.0 * radius * System.Math.Sin(delta / 2);
                pnt2dBase = pnt2dCen.traverse(angleBase, scale * radius);
                pnts2d.Add(pnt2dBase);
                deltaBegin = angleBase + delta + pi / 2;
                break;

            default:
                break;
            }

            //adjust first segment to account for viewtwist
            pnt2dBase = pnt2dBase.traverse(deltaBegin, length);
            pnts2d.Add(pnt2dBase); //pnt1
            //pnt2dBase.addPointNode(34, 0.01);

            double deltaTotal = deltaBegin;

            //from then on it is
            for (int i = 1; i < numSides; i++)
            {
                deltaTotal = deltaTotal + delta;
                pnt2dBase  = pnt2dBase.traverse(deltaTotal, length);
                pnts2d.Add(pnt2dBase); //pnts 2-6
                //pnt2dBase.addPointNode(34, 0.01);
            }

            if (numSides < 1024)
            {
                idSYM = addPoly(pnts2d, "BUBBLE", 5);
            }
            else
            {
                idSYM = Draw.addCircle(pnt3d, scale * radius, "BUBBLE", 5);
            }

            if (addWipeOut)
            {
                Wipeout wo = new Wipeout();
                try
                {
                    using (Transaction tr = BaseObjs.startTransactionDb())
                    {
                        BlockTableRecord ms = Blocks.getBlockTableRecordMS();
                        wo.SetFrom(pnts2d, Vector3d.ZAxis);
                        wo.Layer = "BUBBLE";
                        wo.Color = Color.FromColorIndex(ColorMethod.ByBlock, 8);
                        ms.AppendEntity(wo);
                        tr.AddNewlyCreatedDBObject(wo, true);
                        idWO = wo.ObjectId;
                        tr.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 804");
                }
            }

            return(idSYM);
        }