Пример #1
0
        private void DrawAxisLine(Point3d point, Vector3d direction, double chainage)
        {
            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var db  = doc.Database;

            using (Transaction tr = db.TransactionManager.StartTransaction())
                using (TextStyleTable tt = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead))
                    using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite))
                    {
                        // Draw axis
                        ObjectId textStyleId = ObjectId.Null;
                        if (tt.Has(TextStyleName))
                        {
                            textStyleId = tt[TextStyleName];
                        }

                        // Line
                        Point3d pt1  = point - direction * AxisLineLength / 2;
                        Point3d pt2  = point + direction * AxisLineLength / 2;
                        Line    line = AcadEntity.CreateLine(db, pt1, pt2);
                        btr.AppendEntity(line);
                        tr.AddNewlyCreatedDBObject(line, true);

                        // Axis text
                        Point3d ptt      = pt2 + direction * TextHeight / 2;
                        double  rotation = Vector3d.YAxis.GetAngleTo(direction, Vector3d.ZAxis);
                        DBText  text     = AcadEntity.CreateText(db, ptt, AxisName, TextHeight, rotation, 1, TextHorizontalMode.TextCenter, TextVerticalMode.TextBottom, textStyleId);

                        btr.AppendEntity(text);
                        tr.AddNewlyCreatedDBObject(text, true);

                        tr.Commit();
                    }
        }
Пример #2
0
        public override void DeleteCADObject(Autodesk.AutoCAD.ApplicationServices.Document doc)
        {
            string[] Layers = null;

            if (this.SURVEY_ID.StartsWith("WS"))
            {
                Layers = new string[] { "0", "WSPoint", "WSText" }
            }
            ;
            else
            {
                Layers = new string[] { "0", "YSPoint", "YSText" }
            };
            Autodesk.AutoCAD.Interop.AcadDocument AcadDoc = doc.AcadDocument as Autodesk.AutoCAD.Interop.AcadDocument;

            Editor ed    = doc.Editor;
            int    count = 0;

            foreach (string Layer in Layers)
            {
                TypedValue[] tvs = new TypedValue[]

                {
                    new TypedValue((int)DxfCode.LayerName, Layer)
                };
                SelectionFilter sf = new SelectionFilter(tvs);

                PromptSelectionResult psr = ed.SelectAll(sf);

                if (psr.Status == PromptStatus.OK)
                {
                    SelectionSet SS = psr.Value;

                    ObjectId[] idArray = SS.GetObjectIds();

                    for (int i = 0; i < idArray.Length; i++)
                    {
                        if (this is IPipePoint && count == 2)
                        {
                            break;
                        }
                        else if (this is IPIPELine && count == 3)
                        {
                            break;
                        }
                        //Entity ent = (Entity)Tools.GetDBObject(idArray[i]);
                        AcadEntity pAcadEntity = AcadDoc.ObjectIdToObject(idArray[i].OldIdPtr.ToInt64()) as AcadEntity;

                        string ObjectID = GetPointObjectID(pAcadEntity);
                        if (ObjectID.Equals(this.ID))
                        {
                            pAcadEntity.Delete();
                            count++;
                        }
                    }
                }
            }
            AcadDoc.Save();
        }
Пример #3
0
 /// <summary>
 /// 替换审核者、设计者、日期等属性
 /// </summary>
 /// <param name="entity"></param>
 public static void ReplaceProperty(AcadEntity entity, AcadBlocks blocks, Bussiness.Rules rules)
 {
     if (entity.ObjectName == "AcDbBlockReference")
     {
         var s    = ((AcadBlockReference)entity);
         var name = blocks.Item(s.Name).Name;
         blocks.Item(s.Name).Name = rand.Next().ToString();
         if (s.HasAttributes)
         {
             AcadAttributeReference bb;
             object[] aa = (object[])s.GetAttributes();
             for (int i = 0; i < aa.Length; i++)
             {
                 bb = aa[i] as AcadAttributeReference;
                 if (bb != null)
                 {
                     if (bb.TagString != "---------" && bb.TagString != "------" && !bb.TagString.Contains("GEN-TITLE-MAT") && !bb.TagString.Contains("GEN-TITLE-DES") && bb.TagString != "01" && !bb.TagString.Contains("GEN-TITLE-SCA{6.14,1}"))
                     {
                         bb.TextString = "";
                     }
                     if (bb.TagString == "---------")
                     {
                         oldCode = bb.TextString;
                         oldCode = ReplaceStr(oldCode);
                         var       startCode = oldCode.Substring(0, RegexCode());
                         var       endCode   = oldCode.Substring(RegexCode(), oldCode.Length - RegexCode());
                         Hashtable hash      = rules.GetRules();
                         foreach (DictionaryEntry de in hash)
                         {
                             if (startCode == de.Key.ToString())
                             {
                                 startCode = de.Value.ToString();
                             }
                         }
                         newCode = startCode + "0" + Rand();
                         if (!string.IsNullOrEmpty(newCode))
                         {
                             bb.TextString = newCode;
                         }
                     }
                 }
             }
         }
     }
     else if (entity.ObjectName == "AcDbMText")
     {
         AcadMText mtext = entity as AcadMText;
         if (mtext != null)
         {
             if (mtext.TextString.Contains("FAX") || mtext.TextString.Contains("TEL") || mtext.TextString.Contains("TOMITA"))
             {
                 mtext.TextString = "";
             }
         }
     }
 }
Пример #4
0
        private static void AddHatch(AcadEntity entity, string Pattern, string LayerHatch, double ScaleHacth, double PatternScale, double PatternAngle)
        {
            AcadHatch hatch = AcadDoc.ModelSpace.AddHatch(0, Pattern, true);

            AcadEntity[] entities = new AcadEntity[] { entity };
            hatch.AppendInnerLoop(entities);
            hatch.Layer         = LayerHatch;
            hatch.LinetypeScale = ScaleHacth;
            hatch.PatternAngle  = PatternAngle;
            BackHatch((AcadObject)hatch);
            hatch.Update();
        }
Пример #5
0
 /// <summary>
 /// 替换装配图中的明细表中的编号
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="acAppComObj"></param>
 /// <param name="ds"></param>
 public static void ReplaceDrawingCode(AcadEntity entity, AcadApplication acAppComObj)
 {
     if (entity.ObjectName == "AcmPartRef")
     {
         AXDBLib.AcadObject obj    = entity as AXDBLib.AcadObject;
         McadSymbolBBMgr    symbb  = (McadSymbolBBMgr)acAppComObj.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr");
         McadBOMMgr         bommgr = (McadBOMMgr)symbb.BOMMgr;
         oldCode = bommgr.GetPartAttribute(obj, "DESCR", false);
         string newCode = getByNewCode(oldCode);
         if (!string.IsNullOrEmpty(newCode))
         {
             bommgr.SetPartAttribute(obj, "DESCR", newCode);
         }
     }
 }
Пример #6
0
        protected string GetPointObjectID(AcadEntity pAcadObject)
        {
            if (pAcadObject == null)
            {
                return("");
            }

            AcadDictionary pAcadDictionary = pAcadObject.GetExtensionDictionary();

            if (pAcadDictionary.Count == 1)
            {
                AcadXRecord pAcadXRecord = pAcadDictionary.Item(0) as AcadXRecord;
                string      ID           = pAcadXRecord.Name;

                return(ID);
                //}
            }
            return(string.Empty);
        }
Пример #7
0
 /// <summary>
 /// 画填充矩形
 /// </summary>
 /// <param name="rectf"></param>
 /// <param name="color"></param>
 public void drawFillRects(RectangleF[] rects, Color color) {
     for (int i = 0; i < rects.Length; i++) {
         double[] pnt = new double[3];
         pnt[0] = rects[i].Location.X;
         pnt[1] = rects[i].Location.Y;
         pnt[2] = 0;
         Acad3DSolid r = cad.ActiveDocument.ModelSpace.AddBox(pnt, 0, rects[i].Width, rects[i].Height);
         r.Layer = "line";
         AcadAcCmColor color2 = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.17");
         color2.SetRGB(color.R, color.G, color.B);
         r.TrueColor = color2;
         AcadHatch wt = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
         wt.color = ACAD_COLOR.acBlue;
         AcadEntity[] ot = new AcadEntity[1];
         ot[0] = (AcadEntity)r;
         wt.AppendOuterLoop(ot);
         wt.Evaluate();
         cad.Application.Update();
     }
 }
Пример #8
0
        public void DrawGirder()
        {
            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var db  = doc.Database;
            var ed  = doc.Editor;

            Matrix3d ucs2wcs = AcadGraphics.UcsToWcs;
            Matrix3d wcs2ucs = AcadGraphics.WcsToUcs;

            PromptEntityOptions centerlineOpts = new PromptEntityOptions("\nEksen: ");

            centerlineOpts.SetRejectMessage("\nSelect a curve.");
            centerlineOpts.AddAllowedClass(typeof(Curve), false);
            PromptEntityResult centerlineRes = ed.GetEntity(centerlineOpts);

            if (centerlineRes.Status != PromptStatus.OK)
            {
                return;
            }
            ObjectId centerlineId = centerlineRes.ObjectId;

            PromptEntityOptions blockOpts = new PromptEntityOptions("\nBlok: ");

            blockOpts.SetRejectMessage("\nSelect a block reference.");
            blockOpts.AddAllowedClass(typeof(BlockReference), false);
            PromptEntityResult blockRes = ed.GetEntity(blockOpts);

            if (blockRes.Status != PromptStatus.OK)
            {
                return;
            }
            ObjectId blockReferenceId = blockRes.ObjectId;

            var resp1 = ed.GetPoint("\nBlok üzerinde hizalanacak ilk nokta: ");

            if (resp1.Status != PromptStatus.OK)
            {
                return;
            }
            Point3d alignmentPoint1 = resp1.Value.TransformBy(ucs2wcs);

            var resp2 = ed.GetPoint("\nBlok üzerinde hizalanacak ikinci nokta: ");

            if (resp2.Status != PromptStatus.OK)
            {
                return;
            }
            Point3d alignmentPoint2 = resp2.Value.TransformBy(ucs2wcs);

            GirderAlignment      alignment = GirderAlignment.TopSurface;
            PromptKeywordOptions kopts     = new PromptKeywordOptions("\nHizalama yöntemi [üst Yüzey/Alt yüzey]: ", "Top Bottom");

            kopts.AllowNone        = true;
            kopts.Keywords.Default = "Top";
            var resk = ed.GetKeywords(kopts);

            if (resk.Status == PromptStatus.OK && resk.StringResult == "Bottom")
            {
                alignment = GirderAlignment.BottomSurface;
            }
            else if (resk.Status == PromptStatus.OK && resk.StringResult == "Top")
            {
                alignment = GirderAlignment.TopSurface;
            }
            else if (resk.Status == PromptStatus.None)
            {
                alignment = GirderAlignment.TopSurface;
            }
            else
            {
                return;
            }

            using (Transaction tr = db.TransactionManager.StartTransaction())
                using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite))
                {
                    try
                    {
                        Curve centerline = tr.GetObject(centerlineId, OpenMode.ForRead) as Curve;

                        BlockReference blockRef            = tr.GetObject(blockReferenceId, OpenMode.ForRead) as BlockReference;
                        ObjectId       blockDefinitionId   = AcadEntity.GetBlockDefinitionFromReference(db, blockReferenceId);
                        Point3d        blockInsertionPoint = blockRef.Position;
                        Scale3d        blockScale          = blockRef.ScaleFactors;
                        blockInsertionPoint = blockInsertionPoint.TransformBy(blockRef.BlockTransform.Inverse());
                        alignmentPoint1     = alignmentPoint1.TransformBy(blockRef.BlockTransform.Inverse());
                        alignmentPoint2     = alignmentPoint2.TransformBy(blockRef.BlockTransform.Inverse());
                        Vector3d dist1 = alignmentPoint1 - blockInsertionPoint;
                        Vector3d dist2 = alignmentPoint2 - blockInsertionPoint;

                        while (true)
                        {
                            var opts = new PromptPointOptions("\nInsertion point: ");
                            opts.AllowNone = true;
                            var res = ed.GetPoint(opts);
                            if (res.Status != PromptStatus.OK)
                            {
                                break;
                            }
                            Point3d insertionPoint = res.Value.TransformBy(ucs2wcs);

                            // 10 iterations to approximate rotation
                            Point3d centerlinePoint1 = Point3d.Origin;
                            Point3d centerlinePoint2 = Point3d.Origin;
                            double  rotation         = 0;
                            double  ucsRotation      = 0;
                            for (int i = 0; i < 10; i++)
                            {
                                centerlinePoint1 = centerline.GetClosestPointTo((insertionPoint.TransformBy(wcs2ucs) + dist1.RotateBy(ucsRotation, Vector3d.ZAxis)).TransformBy(ucs2wcs), true);
                                centerlinePoint2 = centerline.GetClosestPointTo((insertionPoint.TransformBy(wcs2ucs) + dist2.RotateBy(ucsRotation, Vector3d.ZAxis)).TransformBy(ucs2wcs), true);
                                ucsRotation      = Vector3d.XAxis.GetAngleTo(centerlinePoint2.TransformBy(wcs2ucs) - centerlinePoint1.TransformBy(wcs2ucs), Vector3d.ZAxis);
                                rotation         = Vector3d.XAxis.GetAngleTo(centerlinePoint2 - centerlinePoint1, Vector3d.ZAxis);
                            }

                            if (alignment == GirderAlignment.TopSurface)
                            {
                                insertionPoint = (centerlinePoint1.TransformBy(wcs2ucs) - dist1.RotateBy(ucsRotation, Vector3d.ZAxis)).TransformBy(ucs2wcs);
                            }

                            BlockReference newBlock = AcadEntity.CreateBlockReference(db, blockDefinitionId, insertionPoint, blockScale, rotation);
                            btr.AppendEntity(newBlock);
                            tr.AddNewlyCreatedDBObject(newBlock, true);

                            tr.TransactionManager.QueueForGraphicsFlush();
                        }
                    }
                    catch (System.Exception e)
                    {
                        MessageBox.Show(e.ToString(), "XCOM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    tr.Commit();
                }
        }
Пример #9
0
        public void PrintChainage()
        {
            if (!CheckLicense.Check())
            {
                return;
            }

            Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Autodesk.AutoCAD.DatabaseServices.Database    db  = doc.Database;

            ObjectId textStyleId = ObjectId.Null;

            using (Transaction tr = db.TransactionManager.StartTransaction())
                using (TextStyleTable tt = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead))
                {
                    if (tt.Has(TextStyleName))
                    {
                        textStyleId = tt[TextStyleName];
                    }
                    tr.Commit();
                }

            Matrix3d ucs2wcs = AcadUtility.AcadGraphics.UcsToWcs;
            Matrix3d wcs2ucs = AcadUtility.AcadGraphics.WcsToUcs;

            // Pick polyline
            bool     flag         = true;
            ObjectId centerlineId = ObjectId.Null;

            while (flag)
            {
                PromptEntityOptions entityOpts = new PromptEntityOptions("\nEksen: [Seçenekler]", "Settings");
                entityOpts.SetRejectMessage("\nSelect a curve.");
                entityOpts.AddAllowedClass(typeof(Curve), false);
                PromptEntityResult entityRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetEntity(entityOpts);

                if (entityRes.Status == PromptStatus.Keyword && entityRes.StringResult == "Settings")
                {
                    ShowSettings();
                    continue;
                }
                else if (entityRes.Status == PromptStatus.OK)
                {
                    centerlineId = entityRes.ObjectId;
                    break;
                }
                else
                {
                    return;
                }
            }

            // Start point
            Point3d           startPoint;
            PromptPointResult pointRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetPoint("\nBaşlangıç Noktası: ");

            if (pointRes.Status == PromptStatus.OK)
            {
                startPoint = pointRes.Value.TransformBy(ucs2wcs);
            }
            else
            {
                return;
            }

            // Start CH
            string       startCH   = "";
            PromptResult stringRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetString("\nBaşlangıç KM: <0+000.00>");

            startCH = stringRes.StringResult;
            if (stringRes.Status == PromptStatus.None)
            {
                startCH = "0+000.00";
            }
            else if (stringRes.Status != PromptStatus.OK)
            {
                return;
            }

            // Print chainages
            using (Transaction tr = db.TransactionManager.StartTransaction())
                using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite))
                    using (TextStyleTable tt = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead))
                    {
                        Autodesk.AutoCAD.DatabaseServices.Curve centerline = tr.GetObject(centerlineId, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Curve;
                        if (centerline != null)
                        {
                            double curveStartCH          = AcadText.ChainageFromString(startCH) - centerline.GetDistAtPoint(startPoint);
                            double distToNearestInterval = Math.Ceiling(curveStartCH / Interval) * Interval - curveStartCH;
                            double currentDistance       = distToNearestInterval;
                            double curveLength           = centerline.GetDistanceAtParameter(centerline.EndParam);
                            while (currentDistance < curveLength)
                            {
                                string   currentCH    = AcadText.ChainageToString(currentDistance + curveStartCH, Precision);
                                Point3d  currentPoint = centerline.GetPointAtDist(currentDistance);
                                Vector3d perp         = centerline.GetFirstDerivative(currentPoint).RotateBy(Math.PI / 2.0, Vector3d.ZAxis);
                                perp /= perp.Length;
                                Point3d lineStart = currentPoint + perp * TextHeight / 2.0;
                                Point3d lineEnd   = currentPoint - perp * TextHeight / 2.0;
                                Point3d textStart = currentPoint + perp * TextHeight / 2.0 * 1.2;

                                // Tick mark
                                Line line = new Line();
                                line.StartPoint = lineStart;
                                line.EndPoint   = lineEnd;
                                btr.AppendEntity(line);
                                tr.AddNewlyCreatedDBObject(line, true);

                                // CH text
                                double             textRotation       = Vector3d.XAxis.GetAngleTo(perp, Vector3d.ZAxis);
                                double             rot                = textRotation * 180 / Math.PI;
                                TextHorizontalMode textHorizontalMode = TextHorizontalMode.TextLeft;
                                if (rot > 90.0 && rot < 270.0)
                                {
                                    textRotation       = textRotation + Math.PI;
                                    textHorizontalMode = TextHorizontalMode.TextRight;
                                }
                                textStyleId = ObjectId.Null;
                                if (tt.Has(TextStyleName))
                                {
                                    textStyleId = tt[TextStyleName];
                                }
                                DBText text = AcadEntity.CreateText(db, textStart, currentCH, TextHeight, textRotation, 0.8, textHorizontalMode, TextVerticalMode.TextVerticalMid, textStyleId);

                                btr.AppendEntity(text);
                                tr.AddNewlyCreatedDBObject(text, true);

                                currentDistance += Interval;
                            }
                        }

                        tr.Commit();
                    }
        }
Пример #10
0
        /// <summary>
        /// Returns the contour polylines at the given elevation.
        /// </summary>
        /// <param name="surface">The type of surface being operated on</param>
        /// <param name="z">Elevation</param>
        public IEnumerable <Polyline> ContourAt(SurfaceType surface, double z)
        {
            Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Autodesk.AutoCAD.DatabaseServices.Database    db  = doc.Database;

            Point3d  planePoint  = new Point3d(0, 0, z);
            Vector3d planeNormal = Vector3d.ZAxis;

            // List of segments
            Queue <Tuple <Point3d, Point3d> > segments = new Queue <Tuple <Point3d, Point3d> >();

            foreach (TriangleNet.Data.Triangle tri in ((surface == SurfaceType.Original) ? originalSurface : proposedSurface).Triangles)
            {
                TriangleNet.Data.Vertex v1 = tri.GetVertex(0);
                TriangleNet.Data.Vertex v2 = tri.GetVertex(1);
                TriangleNet.Data.Vertex v3 = tri.GetVertex(2);
                Point3d p1 = new Point3d(v1.X, v1.Y, v1.Attributes[0]);
                Point3d p2 = new Point3d(v2.X, v2.Y, v2.Attributes[0]);
                Point3d p3 = new Point3d(v3.X, v3.Y, v3.Attributes[0]);

                if (PlaneTriangleIntersection(planePoint, planeNormal, p1, p2, p3, out Point3d ptOut1, out Point3d ptOut2))
                {
                    segments.Enqueue(new Tuple <Point3d, Point3d>(ptOut1, ptOut2));
                }
            }

            // Create curves from segments
            double          epsilon  = 0.000001;
            Tolerance       tol      = new Tolerance(epsilon, epsilon);
            List <Polyline> contours = new List <Polyline>();

            while (segments.Count > 0)
            {
                LinkedList <Point3d>     curvePoints  = new LinkedList <Point3d>();
                Tuple <Point3d, Point3d> firstSegment = segments.Dequeue();
                curvePoints.AddFirst(firstSegment.Item1);
                curvePoints.AddLast(firstSegment.Item2);
                bool added = false;
                do
                {
                    int n = segments.Count;
                    added = false;
                    for (int i = 0; i < n; i++)
                    {
                        Tuple <Point3d, Point3d> segment = segments.Dequeue();
                        Point3d p1         = segment.Item1;
                        Point3d p2         = segment.Item2;
                        Point3d startPoint = curvePoints.First.Value;
                        Point3d endPoint   = curvePoints.Last.Value;
                        if (startPoint.IsEqualTo(p1, tol))
                        {
                            curvePoints.AddFirst(p2);
                            added = true;
                        }
                        else if (startPoint.IsEqualTo(p2, tol))
                        {
                            curvePoints.AddFirst(p1);
                            added = true;
                        }
                        else if (endPoint.IsEqualTo(p1, tol))
                        {
                            curvePoints.AddLast(p2);
                            added = true;
                        }
                        else if (endPoint.IsEqualTo(p2, tol))
                        {
                            curvePoints.AddLast(p1);
                            added = true;
                        }
                        else
                        {
                            segments.Enqueue(segment);
                        }
                    }
                } while (added);
                Polyline pline = AcadEntity.CreatePolyLine(db, curvePoints.First().IsEqualTo(curvePoints.Last(), tol), curvePoints.ToArray());
                pline.ColorIndex = 31;
                pline.Elevation  = z;
                contours.Add(pline);
            }

            return(contours);
        }
Пример #11
0
        public void DrawDeck()
        {
            if (!CheckLicense.Check())
            {
                return;
            }

            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var db  = doc.Database;
            var ed  = doc.Editor;

            Matrix3d ucs2wcs = AcadGraphics.UcsToWcs;
            Matrix3d wcs2ucs = AcadGraphics.WcsToUcs;

            Alignment = Bridge.PickAlignment();
            if (Alignment == Bridge.AlignmentType.None)
            {
                return;
            }

            PromptEntityOptions entityOpts = new PromptEntityOptions("\nEksen: ");

            entityOpts.SetRejectMessage("\nSelect a curve.");
            entityOpts.AddAllowedClass(typeof(Curve), false);
            PromptEntityResult entityRes = ed.GetEntity(entityOpts);

            if (entityRes.Status != PromptStatus.OK)
            {
                return;
            }
            CenterlineId = entityRes.ObjectId;

            var resp1 = ed.GetPoint("\nBaşlangıç noktası: ");

            if (resp1.Status != PromptStatus.OK)
            {
                return;
            }
            StartPoint = resp1.Value.TransformBy(ucs2wcs);

            var resp2 = ed.GetPoint("\nBitiş noktası: ");

            if (resp2.Status != PromptStatus.OK)
            {
                return;
            }
            EndPoint = resp2.Value.TransformBy(ucs2wcs);

            var opts = new PromptDistanceOptions("\nAsktan taşma mesafesi: ");

            opts.AllowNegative   = false;
            opts.AllowZero       = false;
            opts.DefaultValue    = OverhangDistance;
            opts.UseDefaultValue = true;
            opts.BasePoint       = resp1.Value;
            var res = ed.GetDistance(opts);

            if (res.Status != PromptStatus.OK)
            {
                return;
            }
            OverhangDistance = res.Value;

            if (Alignment == Bridge.AlignmentType.Plan)
            {
                var opts1 = new PromptDistanceOptions("\nTabliye genişliği: ");
                opts1.AllowNegative   = false;
                opts1.AllowZero       = false;
                opts1.DefaultValue    = DeckWidth;
                opts1.UseDefaultValue = true;
                opts1.BasePoint       = resp1.Value;
                var reso1 = ed.GetDistance(opts1);
                if (reso1.Status != PromptStatus.OK)
                {
                    return;
                }
                DeckWidth = reso1.Value;
            }
            else
            {
                var opts1 = new PromptDistanceOptions("\nAsfalt kalınlığı: ");
                opts1.AllowNegative   = false;
                opts1.AllowZero       = false;
                opts1.DefaultValue    = AsphaltThickness;
                opts1.UseDefaultValue = true;
                var reso1 = ed.GetDistance(opts1);
                if (reso1.Status != PromptStatus.OK)
                {
                    return;
                }
                AsphaltThickness = reso1.Value;

                var opts2 = new PromptDistanceOptions("\nTabliye kalınlığı: ");
                opts2.AllowNegative   = false;
                opts2.AllowZero       = false;
                opts2.DefaultValue    = DeckThickness;
                opts2.UseDefaultValue = true;
                var reso2 = ed.GetDistance(opts2);
                if (reso2.Status != PromptStatus.OK)
                {
                    return;
                }
                DeckThickness = reso2.Value;

                var opts3 = new PromptDistanceOptions("\nKaldırım kalınlığı: ");
                opts3.AllowNegative   = false;
                opts3.AllowZero       = false;
                opts3.DefaultValue    = SidewalkThickness;
                opts3.UseDefaultValue = true;
                var reso3 = ed.GetDistance(opts3);
                if (reso3.Status != PromptStatus.OK)
                {
                    return;
                }
                SidewalkThickness = reso3.Value;
            }

            using (Transaction tr = db.TransactionManager.StartTransaction())
                using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite))
                {
                    try
                    {
                        ObjectId lineLayerId     = AcadUtility.AcadEntity.GetOrCreateLayer(db, DeckLayerName, Color.FromColorIndex(ColorMethod.ByAci, 4));
                        ObjectId hatchLayerId    = AcadUtility.AcadEntity.GetOrCreateLayer(db, HatchLayerName, Color.FromColorIndex(ColorMethod.ByAci, 31));
                        ObjectId sidewalkLayerId = AcadUtility.AcadEntity.GetOrCreateLayer(db, SidewalkLayerName, Color.FromColorIndex(ColorMethod.ByAci, 21));

                        // Adjust start and end point to account for overhang
                        Curve centerline = tr.GetObject(CenterlineId, OpenMode.ForRead) as Curve;
                        if (Alignment == Bridge.AlignmentType.Plan)
                        {
                            StartPoint = centerline.GetClosestPointTo(StartPoint, false);
                            double startDistance = centerline.GetDistAtPoint(StartPoint) - OverhangDistance;
                            StartPoint = centerline.GetPointAtDist(startDistance);

                            EndPoint = centerline.GetClosestPointTo(EndPoint, false);
                            double endDistance = centerline.GetDistAtPoint(EndPoint) + OverhangDistance;
                            EndPoint = centerline.GetPointAtDist(endDistance);

                            using (Plane horizontal = new Plane(Point3d.Origin, Vector3d.ZAxis))
                            {
                                Curve planCurve = centerline.GetOrthoProjectedCurve(horizontal);
                                planCurve = planCurve.GetTrimmedCurve(StartPoint, EndPoint, true);

                                Vector3d dir = planCurve.GetFirstDerivative(planCurve.StartParam).CrossProduct(Vector3d.ZAxis);
                                dir /= dir.Length;

                                var rightCurve = planCurve.GetOffsetCurves(planCurve.StartPoint + dir * DeckWidth / 2)[0] as Curve;
                                var leftCurve  = planCurve.GetOffsetCurves(planCurve.StartPoint - dir * DeckWidth / 2)[0] as Curve;

                                // Join curves and close ends with lines
                                var finalCurve = AcadEntity.CreatePolyLine(db, true,
                                                                           rightCurve,
                                                                           AcadEntity.CreateLine(db, rightCurve.StartPoint, leftCurve.StartPoint),
                                                                           leftCurve,
                                                                           AcadEntity.CreateLine(db, rightCurve.EndPoint, leftCurve.EndPoint));
                                var finalCurveId = btr.AppendEntity(finalCurve);
                                tr.AddNewlyCreatedDBObject(finalCurve, true);
                                finalCurve.LayerId = lineLayerId;

                                // Hatch inside
                                var hatch = new Hatch();
                                btr.AppendEntity(hatch);
                                tr.AddNewlyCreatedDBObject(hatch, true);
                                hatch.LayerId     = hatchLayerId;
                                hatch.Associative = true;
                                hatch.AppendLoop(HatchLoopTypes.Outermost, new ObjectIdCollection()
                                {
                                    finalCurveId
                                });
                                hatch.PatternScale = HatchScale;
                                hatch.SetHatchPattern(HatchPatternType.PreDefined, HatchPattern);
                                hatch.EvaluateHatch(true);
                            }
                        }
                        else
                        {
                            Vector3d upDir        = db.Ucsydir;
                            var      topline      = centerline.GetTransformedCopy(Matrix3d.Displacement(upDir * -AsphaltThickness)) as Curve;
                            var      bottomline   = topline.GetTransformedCopy(Matrix3d.Displacement(upDir * -DeckThickness)) as Curve;
                            var      sidewalkline = topline.GetTransformedCopy(Matrix3d.Displacement(upDir * SidewalkThickness)) as Curve;

                            using (Plane horizontal = new Plane(Point3d.Origin, upDir))
                            {
                                Curve planCurve = centerline.GetOrthoProjectedCurve(horizontal);

                                Point3d startPointOnPlan = planCurve.GetClosestPointTo(StartPoint, true);
                                double  startDistance    = planCurve.GetDistAtPoint(startPointOnPlan) - OverhangDistance;
                                startPointOnPlan = planCurve.GetPointAtDist(startDistance);
                                StartPoint       = centerline.GetClosestPointTo(startPointOnPlan, upDir, true);

                                Point3d endPointOnPlan = planCurve.GetClosestPointTo(EndPoint, true);
                                double  endDistance    = planCurve.GetDistAtPoint(endPointOnPlan) + OverhangDistance;
                                endPointOnPlan = planCurve.GetPointAtDist(endDistance);
                                EndPoint       = centerline.GetClosestPointTo(endPointOnPlan, upDir, true);
                            }

                            topline = topline.GetTrimmedCurve(topline.GetClosestPointTo(StartPoint, upDir, true),
                                                              topline.GetClosestPointTo(EndPoint, upDir, true), true);
                            bottomline = bottomline.GetTrimmedCurve(bottomline.GetClosestPointTo(StartPoint, upDir, true),
                                                                    bottomline.GetClosestPointTo(EndPoint, upDir, true), true);
                            sidewalkline = sidewalkline.GetTrimmedCurve(sidewalkline.GetClosestPointTo(StartPoint, upDir, true),
                                                                        sidewalkline.GetClosestPointTo(EndPoint, upDir, true), true);

                            // Sidewalk
                            var finalSWCurve = AcadEntity.CreatePolyLine(db, false,
                                                                         AcadEntity.CreateLine(db, topline.StartPoint, sidewalkline.StartPoint),
                                                                         sidewalkline,
                                                                         AcadEntity.CreateLine(db, topline.EndPoint, sidewalkline.EndPoint));
                            btr.AppendEntity(finalSWCurve);
                            tr.AddNewlyCreatedDBObject(finalSWCurve, true);
                            finalSWCurve.LayerId = sidewalkLayerId;

                            // Deck polyline
                            var finalCurve = AcadEntity.CreatePolyLine(db, true,
                                                                       topline,
                                                                       AcadEntity.CreateLine(db, topline.StartPoint, bottomline.StartPoint),
                                                                       bottomline,
                                                                       AcadEntity.CreateLine(db, topline.EndPoint, bottomline.EndPoint));
                            ObjectId finalCurveId = btr.AppendEntity(finalCurve);
                            tr.AddNewlyCreatedDBObject(finalCurve, true);
                            finalCurve.LayerId = lineLayerId;

                            // Hatch inside
                            var hatch = new Hatch();
                            btr.AppendEntity(hatch);
                            tr.AddNewlyCreatedDBObject(hatch, true);
                            hatch.LayerId     = hatchLayerId;
                            hatch.Associative = true;
                            hatch.AppendLoop(HatchLoopTypes.Outermost, new ObjectIdCollection()
                            {
                                finalCurveId
                            });
                            hatch.PatternScale = HatchScale;
                            hatch.SetHatchPattern(HatchPatternType.PreDefined, HatchPattern);
                            hatch.EvaluateHatch(true);
                        }
                    }
                    catch (System.Exception e)
                    {
                        MessageBox.Show(e.ToString(), "XCOM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    tr.Commit();
                }
        }
Пример #12
0
        public void CallCAD(SvgElementCollection _col, string lab, int count, AcadApplication cad)
        {
            int errid = 0;

            AcadEntity[] en = new AcadEntity[2];
            AcadHatch wt = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
            wt.color = ACAD_COLOR.acWhite;
            AcadHatch h;
            AcadHatch h2;
            AcadHatch h3;
            AcadHatch h4;
            AcadHatch h5;

            //h = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid",/* "JIS_LC_20",*/ true, 0);
            if (CadFullType == "1")
            {
                h = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
                h2 = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
                h3 = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
                h4 = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
                h5 = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
            }
            else
            {
                h = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);//JIS_LC_20 //JIS_LC_20
                h2 = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                h3 = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                h4 = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                h5 = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
            }

            if (CadFullType == "2")
            {
                h.PatternScale = 0.25;
                h.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
            }
            Color c_500 = ColorTranslator.FromHtml(str500kv);
            AcadAcCmColor color500 = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18"); //2006 -"AutoCAD.AcCmColor.16"
            color500.SetRGB(c_500.R, c_500.G, c_500.B);
            h.TrueColor = color500;

            if (CadFullType == "2")
            {
                h2.PatternScale = 0.25;
                h2.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
            }
            Color c_220 = ColorTranslator.FromHtml(str220kv);
            AcadAcCmColor color220 = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
            color220.SetRGB(c_220.R, c_220.G, c_220.B);
            h2.TrueColor = color220;

            if (CadFullType == "2")
            {
                h3.PatternScale = 0.25;
                h3.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
            }
            Color c_110 = ColorTranslator.FromHtml(str110kv);
            AcadAcCmColor color110 = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
            color110.SetRGB(c_110.R, c_110.G, c_110.B);
            h3.TrueColor = color110;

            if (CadFullType == "2")
            {
                h4.PatternScale = 0.25;
                h4.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
            }
            Color c_66 = ColorTranslator.FromHtml(str66kv);
            AcadAcCmColor color66 = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
            color66.SetRGB(c_66.R, c_66.G, c_66.B);
            h4.TrueColor = color66;

            if (CadFullType == "2")
            {
                h5.PatternScale = 0.25;
                h5.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
            }
            Color c_33 = ColorTranslator.FromHtml(str33kv);
            AcadAcCmColor color33 = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
            color33.SetRGB(c_33.R, c_33.G, c_33.B);
            h5.TrueColor = color33;

            for (int i = 0; i < _col.Count; i++)
            {
                SvgElement ele = (SvgElement)_col[i];
                f.SetText("共有" + count + "个图层。正在处理" + lab + "图层。\r\n 此图层共" + _col.Count + "个图元,正在处理第" + i + "个,请等待......");
                if (ele.Name == "rect")
                {
                    try
                    {
                        RectangleElement rect = ele as RectangleElement;
                        PointF[] points = new PointF[1];
                        points[0].X = rect.X;
                        points[0].Y = rect.Y;
                        rect.Transform.Matrix.TransformPoints(points);
                        double[] col = new double[15];
                        col[0] = points[0].X;
                        col[1] = -points[0].Y;
                        col[2] = 0;

                        col[3] = rect.X;
                        col[4] = -(rect.Y + rect.Height);
                        col[5] = 0;

                        col[6] = rect.X + rect.Width;
                        col[7] = -(rect.Y + rect.Height);
                        col[8] = 0;

                        col[9] = rect.X + rect.Width;
                        col[10] = -rect.Y;
                        col[11] = 0;

                        col[12] = rect.X;
                        col[13] = -rect.Y;
                        col[14] = 0;

                        AcadPolyline pl = cad.ActiveDocument.ModelSpace.AddPolyline(col);
                        string color_str = rect.GetAttribute("style");
                        int sub_i = color_str.IndexOf("stroke:");
                        if (sub_i == -1)
                        {
                            color_str = "#000000";
                        }
                        else
                        {
                            color_str = color_str.Substring(sub_i + 7, 7);
                           // color_str = color_str.Replace("000000", "FFFFFF");
                        }
                        Color c1 = ColorTranslator.FromHtml(color_str);
                        AcadAcCmColor color = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
                        color.SetRGB(c1.R, c1.G, c1.B);
                        pl.TrueColor = color;

                        pl.Layer = lab;
                        cad.Application.Update();
                    }
                    catch { }
                }
                if (ele.Name == "ellipse")
                {
                    //Ellips eli = ele as Ellips;

                    //DxfEllipse eli = new DxfEllipse(new Point3D(eli.RX, eli.RY, 0), new Vector3D(1, 1, 0), 1);
                    //model.Entities.Add(eli);
                }
                if (ele.Name == "polyline")
                {
                    try
                    {
                        Polyline p1 = ele as Polyline;
                        PointF[] points = p1.Points;
                        if (points.Length > 1)
                        {
                            p1.Transform.Matrix.TransformPoints(points);
                            double[] col = new double[points.Length * 3];
                            int k = 0;
                            for (int n = 0; n < points.Length; n++)
                            {
                                col[k] = points[n].X;
                                col[k + 1] = -points[n].Y;
                                col[k + 2] = 0;
                                k = k + 3;
                            }
                            string color_str = p1.GetAttribute("style");
                            int gh_line = color_str.IndexOf("stroke-dasharray:");
                            int sub_i = color_str.IndexOf("stroke:");
                            if (sub_i == -1)
                            {
                                //color_str = "#FFFFF";
                                color_str = "#000000";
                            }
                            else
                            {
                                color_str = color_str.Substring(sub_i + 7, 7);
                                //color_str = color_str.Replace("000000", "FFFFFF");
                            }
                            Color c1 = ColorTranslator.FromHtml(color_str);
                            AcadPolyline ple = cad.ActiveDocument.ModelSpace.AddPolyline(col);

                            Layer temp_l = tlVectorControl1.SVGDocument.GetLayerByID(ele.GetAttribute("layer"),false);
                            if (temp_l != null)
                            {
                                if (temp_l.Label.ToLower().Contains("500kv"))
                                {
                                    ple.ConstantWidth = w_500;
                                }
                                if (temp_l.Label.ToLower().Contains("220kv"))
                                {
                                    ple.ConstantWidth = w_220;
                                }
                                if (temp_l.Label.ToLower().Contains("110kv"))
                                {
                                    ple.ConstantWidth = w_110;
                                }
                                if (temp_l.Label.ToLower().Contains("66kv"))
                                {
                                    ple.ConstantWidth = w_66;
                                }
                                if (temp_l.Label.ToLower().Contains("35kv"))
                                {
                                    ple.ConstantWidth = w_35;
                                }
                            }
                            if (gh_line != -1)
                            {
                                ple.Linetype = "DASHEDX2";
                            }

                            ple.Layer = lab;

                            AcadAcCmColor color = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
                            color.SetRGB(c1.R, c1.G, c1.B);
                            ple.TrueColor = color;//ACAD_COLOR.acMagenta;

                            cad.Application.Update();
                        }
                    }
                    catch { }
                }
                if (ele.Name == "polygon")
                {
                    try
                    {
                        Polygon p1 = ele as Polygon;
                        PointF[] points = p1.Points;
                        if (points.Length < 2) return;
                        p1.Transform.Matrix.TransformPoints(points);

                        double[] col = new double[points.Length * 3 + 3];
                        int k = 0;
                        for (int n = 0; n < points.Length; n++)
                        {
                            col[k] = points[n].X;
                            col[k + 1] = -points[n].Y;
                            col[k + 2] = 0;
                            k = k + 3;
                        }
                        col[points.Length * 3 + 2] = 0;
                        col[points.Length * 3 + 1] = col[1];
                        col[points.Length * 3] = col[0];
                        AcadPolyline poly = cad.ActiveDocument.ModelSpace.AddPolyline(col);
                        string IsArea = p1.GetAttribute("IsArea");
                        string color_str = p1.GetAttribute("style");
                        int sub_i = color_str.IndexOf("stroke:");
                        int sub_fill = color_str.IndexOf("fill:#");

                        if (sub_i == -1 && sub_fill == -1)
                        {
                            //color_str = "#FFFFF";
                            color_str = "#000000";
                        }
                        else
                        {
                            if (IsArea == "1")
                            {

                                if (sub_fill == -1)
                                {
                                    color_str = color_str.Substring(sub_i + 7, 7);
                                   // color_str = color_str.Replace("000000", "FFFFFF");
                                }
                                else
                                {
                                    color_str = color_str.Substring(sub_fill + 5, 7);
                                    //color_str = color_str.Replace("000000", "FFFFFF");

                                }

                            }
                            else
                            {
                                color_str = color_str.Substring(sub_i + 7, 7);
                                //color_str = color_str.Replace("000000", "FFFFFF");
                            }
                        }
                        Color c1 = ColorTranslator.FromHtml(color_str);
                        AcadAcCmColor color = (AcadAcCmColor)cad.ActiveDocument.Application.GetInterfaceObject("AutoCAD.AcCmColor.18");
                        color.SetRGB(c1.R, c1.G, c1.B);
                        if (IsArea == "1")
                        {
                            AcadHatch solid = cad.ActiveDocument.ModelSpace.AddHatch(0, "solid", true, 0);
                            solid.TrueColor = color;
                            AcadEntity[] obj = new AcadEntity[1];
                            obj[0] = (AcadEntity)poly;
                            solid.AppendOuterLoop(obj);
                            solid.Evaluate();
                            solid.Layer = lab;
                        }
                        poly.TrueColor = color;
                        poly.Layer = lab;
                        cad.Application.Update();
                    }
                    catch { }
                }
                if (ele.Name == "text")
                {
                    try
                    {
                        ItopVector.Core.Figure.Text t1 = ele as ItopVector.Core.Figure.Text;
                        PointF[] points = new PointF[1];
                        points[0].X = t1.X;
                        points[0].Y = t1.Y;
                        t1.Transform.Matrix.TransformPoints(points);

                        double[] ins = new double[3];
                        ins[0] = points[0].X+offX;
                        ins[1] =- points[0].Y+offY;
                        ins[2] = 0;
                        AcadMText text = cad.ActiveDocument.ModelSpace.AddMText(ins, TextLength, t1.TextString);
                        text.Height = TextSize;
                        text.Layer = lab;
                        cad.Application.Update();
                    }
                    catch { }
                }
                if (ele.Name == "use")
                {
                    try
                    {
                        PointF[] cirp = new PointF[1];
                        Use u = ele as Use;
                        PointF[] points = new PointF[1];
                        points[0].X = u.X;
                        points[0].Y = u.Y;

                        XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/defs/symbol [@id='" + u.GraphId + "']");
                        XmlElement e = (XmlElement)list[0];
                        XmlNodeList sonlist = e.ChildNodes;
                        for (int k = 0; k < sonlist.Count; k++)
                        {
                            string str1 = sonlist[k].GetType().ToString();
                            if (str1 == "ItopVector.Core.Figure.Circle")
                            {
                                Circle cir = (Circle)sonlist[k];
                                cirp[0].X = cir.CX;
                                cirp[0].Y = cir.CY;
                                cir.Transform.Matrix.TransformPoints(cirp);
                                break;
                            }
                            if (str1 == "ItopVector.Core.Figure.RectangleElement")
                            {
                                RectangleElement cir = (RectangleElement)sonlist[k];
                                cirp[0].X = cir.X;
                                cirp[0].Y = cir.Y;
                                cir.Transform.Matrix.TransformPoints(cirp);
                                break;
                            }
                        }

                        PointF p = cirp[0];
                        points[0].X = points[0].X + p.X;
                        points[0].Y = points[0].Y + p.Y;

                        u.Transform.Matrix.TransformPoints(points);

                        if (u.GraphId.Contains("Substation500"))
                        {

                            double[] pnt = new double[3];
                            pnt[0] = points[0].X;
                            pnt[1] = -points[0].Y;
                            pnt[2] = 0;
                            AcadCircle cirz = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir1);
                            cirz.Layer = lab;
                            cirz.TrueColor = color500;
                            if (CadFullType == "2")
                            {
                                AcadEntity[] otw = new AcadEntity[1];
                                otw[0] = (AcadEntity)cirz;
                                wt.AppendOuterLoop(otw);
                                wt.Layer = lab;
                            }
                            AcadCircle cir = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir2);
                            cir.Layer = lab;
                            cir.TrueColor = color500;

                            AcadCircle cir1 = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir3);
                            cir1.TrueColor = color500;
                            cir1.Layer = lab;
                            if (CadFullType == "2")
                            {
                                AcadEntity[] ot = new AcadEntity[1];
                                ot[0] = (AcadEntity)cir1;
                                h.AppendOuterLoop(ot);

                                if (u.GraphId.Contains("gh"))
                                {
                                    cir.Linetype = "ACAD_ISO03W100";
                                    cir1.Linetype = "ACAD_ISO03W100";
                                }
                            }
                            if(CadFullType=="1"){
                                if (!u.GraphId.Contains("gh") && !u.GraphId.Contains("user"))
                                {
                                    AcadEntity[] ot = new AcadEntity[1];
                                    ot[0] = (AcadEntity)cir1;
                                    h.AppendOuterLoop(ot);
                                }
                            }

                        }
                        if (u.GraphId.Contains("Substation220"))
                        {

                            double[] pnt = new double[3];
                            pnt[0] = points[0].X;
                            pnt[1] = -points[0].Y;
                            pnt[2] = 0;
                            AcadCircle cir = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir2);
                            cir.TrueColor = color220;
                            cir.Layer = lab;

                            if (CadFullType == "2")
                            {
                                AcadEntity[] otw = new AcadEntity[1];
                                otw[0] = (AcadEntity)cir;
                                wt.AppendOuterLoop(otw);
                                wt.Layer = lab;
                            }
                            AcadCircle cir1 = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir3);
                            cir1.Layer = lab;
                            cir1.TrueColor = color220;

                            if (CadFullType == "2")
                            {
                                if (u.GraphId.Contains("gh"))
                                {
                                    cir.Linetype = "ACAD_ISO03W100";
                                    cir1.Linetype = "ACAD_ISO03W100";
                                }

                                AcadEntity[] ot = new AcadEntity[1];
                                ot[0] = (AcadEntity)cir1;
                                h2.AppendOuterLoop(ot);
                            }
                            if (CadFullType == "1")
                            {
                                if (!u.GraphId.Contains("gh") && !u.GraphId.Contains("user"))
                                {
                                    AcadEntity[] ot = new AcadEntity[1];
                                    ot[0] = (AcadEntity)cir1;
                                    h2.AppendOuterLoop(ot);
                                }
                                if (u.GraphId.Contains("gh-user"))
                                {
                                    double[] stat1 = new double[3];
                                    stat1[0] = pnt[0] - int_cir3 / 2 - int_cir3 / 10;
                                    stat1[1] = pnt[1] - int_cir3 / 2 - int_cir3 / 10;
                                    stat1[2] = 0;
                                    double[] end1 = new double[3];
                                    end1[0] = pnt[0] + int_cir3 / 2 + int_cir3 / 10;
                                    end1[1] = pnt[1] + int_cir3 / 2 + int_cir3 / 10;
                                    end1[2] = 0;
                                    AcadLine line1 = cad.ActiveDocument.ModelSpace.AddLine(stat1, end1);
                                    line1.Layer = lab;
                                    line1.TrueColor = color220;
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir3 / 2 - int_cir3 / 10;
                                    stat2[1] = pnt[1] + int_cir3 / 2 + int_cir3 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir3 / 2 + int_cir3 / 10;
                                    end2[1] = pnt[1] - int_cir3 / 2 - int_cir3 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color220;
                                }
                                if (u.GraphId.Contains("user"))
                                {
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir3 / 2 - int_cir3 / 10;
                                    stat2[1] = pnt[1] + int_cir3 / 2 + int_cir3 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir3 / 2 + int_cir3 / 10;
                                    end2[1] = pnt[1] - int_cir3 / 2 - int_cir3 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color220;
                                }
                            }
                        }
                        if (u.GraphId.Contains("Substation110"))
                        {

                            double[] pnt = new double[3];
                            pnt[0] = points[0].X;
                            pnt[1] = -points[0].Y;
                            pnt[2] = 0;
                            AcadCircle cir = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir3);
                            cir.Layer = lab;
                            cir.TrueColor = color110;
                            if (CadFullType == "2")
                            {
                                AcadEntity[] otw = new AcadEntity[1];
                                otw[0] = (AcadEntity)cir;
                                wt.AppendOuterLoop(otw);
                                wt.Layer = lab;
                            }
                            AcadCircle cir1 = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir4);
                            cir1.Layer = lab;
                            cir1.TrueColor = color110;

                            if (CadFullType == "2")
                            {
                                if (u.GraphId.Contains("gh"))
                                {
                                    cir.Linetype = "ACAD_ISO03W100";
                                    cir1.Linetype = "ACAD_ISO03W100";
                                }

                                AcadEntity[] ot = new AcadEntity[1];
                                ot[0] = (AcadEntity)cir1;
                                h3.AppendOuterLoop(ot);
                            }
                            if (CadFullType == "1")
                            {
                                if (!u.GraphId.Contains("gh") && !u.GraphId.Contains("user"))
                                {
                                    AcadEntity[] ot = new AcadEntity[1];
                                    ot[0] = (AcadEntity)cir1;
                                    h3.AppendOuterLoop(ot);
                                }
                                if (u.GraphId.Contains("gh-user"))
                                {
                                    double[] stat1 = new double[3];
                                    stat1[0] = pnt[0] - int_cir4 / 2 - int_cir4 / 10;
                                    stat1[1] = pnt[1] - int_cir4 / 2 - int_cir4 / 10;
                                    stat1[2] = 0;
                                    double[] end1 = new double[3];
                                    end1[0] = pnt[0] + int_cir4 / 2 + int_cir4 / 10;
                                    end1[1] = pnt[1] + int_cir4 / 2 + int_cir4 / 10;
                                    end1[2] = 0;
                                    AcadLine line1 = cad.ActiveDocument.ModelSpace.AddLine(stat1, end1);
                                    line1.Layer = lab;
                                    line1.TrueColor = color110;
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir4 / 2 - int_cir4 / 10;
                                    stat2[1] = pnt[1] + int_cir4 / 2 + int_cir4 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir4 / 2 + int_cir4 / 10;
                                    end2[1] = pnt[1] - int_cir4 / 2 - int_cir4 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color110;
                                }
                                if (u.GraphId.Contains("user"))
                                {
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir4 / 2 - int_cir4 / 10;
                                    stat2[1] = pnt[1] + int_cir4 / 2 + int_cir4 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir4 / 2 + int_cir4 / 10;
                                    end2[1] = pnt[1] - int_cir4 / 2 - int_cir4 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color110;
                                }
                            }
                        }
                        if (u.GraphId.Contains("Substation66"))
                        {

                            double[] pnt = new double[3];
                            pnt[0] = points[0].X;
                            pnt[1] = -points[0].Y;
                            pnt[2] = 0;

                            AcadCircle cir = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir4);
                            cir.Layer = lab;
                            cir.TrueColor = color66;
                            if (CadFullType == "2")
                            {
                                AcadEntity[] otw = new AcadEntity[1];
                                otw[0] = (AcadEntity)cir;
                                wt.AppendOuterLoop(otw);
                                wt.Layer = lab;
                            }
                            AcadCircle cir1 = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir5);
                            cir1.Layer = lab;
                            cir1.TrueColor = color66;

                            if (CadFullType == "2")
                            {
                                if (u.GraphId.Contains("gh"))
                                {
                                    cir.Linetype = "ACAD_ISO03W100";
                                    cir1.Linetype = "ACAD_ISO03W100";
                                }

                                AcadEntity[] ot = new AcadEntity[1];
                                ot[0] = (AcadEntity)cir1;
                                h4.AppendOuterLoop(ot);
                                h4.Evaluate();
                            }
                            if (CadFullType == "1")
                            {
                                if (!u.GraphId.Contains("gh") && !u.GraphId.Contains("user"))
                                {
                                    AcadEntity[] ot = new AcadEntity[1];
                                    ot[0] = (AcadEntity)cir1;
                                    h4.AppendOuterLoop(ot);
                                }
                                if (u.GraphId.Contains("gh-user"))
                                {
                                    double[] stat1 = new double[3];
                                    stat1[0] = pnt[0] - int_cir5 / 2 - int_cir5/10;
                                    stat1[1] = pnt[1] - int_cir5 / 2 - int_cir5 / 10;
                                    stat1[2] = 0;
                                    double[] end1 = new double[3];
                                    end1[0] = pnt[0] + int_cir5 / 2 + int_cir5 / 10;
                                    end1[1] = pnt[1] + int_cir5 / 2 + int_cir5 / 10;
                                    end1[2] = 0;
                                    AcadLine line1 = cad.ActiveDocument.ModelSpace.AddLine(stat1, end1);
                                    line1.Layer = lab;
                                    line1.TrueColor = color66;
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir5 / 2 - int_cir5 / 10;
                                    stat2[1] = pnt[1] + int_cir5 / 2 + int_cir5 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir5 / 2 + int_cir5 / 10;
                                    end2[1] = pnt[1] - int_cir5 / 2 - int_cir5 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color66;
                                }
                                if (u.GraphId.Contains("user"))
                                {
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir5 / 2 - int_cir5 / 10;
                                    stat2[1] = pnt[1] + int_cir5 / 2 + int_cir5 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir5 / 2 + int_cir5 / 10;
                                    end2[1] = pnt[1] - int_cir5 / 2 - int_cir5 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color66;
                                }
                            }
                        }
                        if (u.GraphId.Contains("Substation35"))
                        {

                            double[] pnt = new double[3];
                            pnt[0] = points[0].X;
                            pnt[1] = -points[0].Y;
                            pnt[2] = 0;

                            AcadCircle cir = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir4);
                            cir.Layer = lab;
                            cir.TrueColor = color33;

                            if (CadFullType == "2")
                            {
                                AcadEntity[] otw = new AcadEntity[1];
                                otw[0] = (AcadEntity)cir;
                                wt.AppendOuterLoop(otw);
                                wt.Layer = lab;
                            }
                            AcadCircle cir1 = cad.ActiveDocument.ModelSpace.AddCircle(pnt, int_cir5);
                            cir1.Layer = lab;
                            cir1.TrueColor = color33;

                            if (CadFullType == "2")
                            {
                                if (u.GraphId.Contains("gh"))
                                {
                                    cir.Linetype = "ACAD_ISO03W100";
                                    cir1.Linetype = "ACAD_ISO03W100";
                                }

                                AcadEntity[] ot = new AcadEntity[1];
                                ot[0] = (AcadEntity)cir1;
                                h5.AppendOuterLoop(ot);
                            }
                            if (CadFullType == "1")
                            {
                                if (!u.GraphId.Contains("gh") && !u.GraphId.Contains("user"))
                                {
                                    AcadEntity[] ot = new AcadEntity[1];
                                    ot[0] = (AcadEntity)cir1;
                                    h5.AppendOuterLoop(ot);
                                }
                                if (u.GraphId.Contains("gh-user"))
                                {
                                    double[] stat1 = new double[3];
                                    stat1[0] = pnt[0] - int_cir5 / 2 - int_cir5 / 10;
                                    stat1[1] = pnt[1] - int_cir5 / 2 - int_cir5 / 10;
                                    stat1[2] = 0;
                                    double[] end1 = new double[3];
                                    end1[0] = pnt[0] + int_cir5 / 2 + int_cir5 / 10;
                                    end1[1] = pnt[1] + int_cir5 / 2 + int_cir5 / 10;
                                    end1[2] = 0;
                                    AcadLine line1 = cad.ActiveDocument.ModelSpace.AddLine(stat1, end1);
                                    line1.Layer = lab;
                                    line1.TrueColor = color33;
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir5 / 2 - int_cir5 / 10;
                                    stat2[1] = pnt[1] + int_cir5 / 2 + int_cir5 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir5 / 2 + int_cir5 / 10;
                                    end2[1] = pnt[1] - int_cir5 / 2 - int_cir5 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color33;
                                }
                                if (u.GraphId.Contains("user"))
                                {
                                    double[] stat2 = new double[3];
                                    stat2[0] = pnt[0] - int_cir5 / 2 - int_cir5 / 10;
                                    stat2[1] = pnt[1] + int_cir5 / 2 + int_cir5 / 10;
                                    stat2[2] = 0;
                                    double[] end2 = new double[3];
                                    end2[0] = pnt[0] + int_cir5 / 2 + int_cir5 / 10;
                                    end2[1] = pnt[1] - int_cir5 / 2 - int_cir5 / 10;
                                    end2[2] = 0;
                                    AcadLine line2 = cad.ActiveDocument.ModelSpace.AddLine(stat2, end2);
                                    line2.Layer = lab;
                                    line2.TrueColor = color33;
                                }
                            }
                            //h3.Evaluate();
                        }
                        if (u.GraphId.Contains("Substation-hdc") )
                        {
                            double[] col = new double[15];
                            col[0] = points[0].X;
                            col[1] = -points[0].Y;
                            col[2] = 0;

                            col[3] = points[0].X;
                            col[4] = -(points[0].Y + 60);
                            col[5] = 0;

                            col[6] = points[0].X + 180;
                            col[7] = -(points[0].Y + 60);
                            col[8] = 0;

                            col[9] = points[0].X + 180;
                            col[10] = -points[0].Y;
                            col[11] = 0;

                            col[12] = points[0].X;
                            col[13] = -points[0].Y;
                            col[14] = 0;

                            AcadPolyline pl = cad.ActiveDocument.ModelSpace.AddPolyline(col);

                            if (u.GraphId.Contains("gh")) { }
                            else
                            {
                                AcadHatch solid = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0); //JIS_LC_20//JIS_LC_20
                                solid.PatternScale = 0.25;
                                solid.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
                                solid.color = ACAD_COLOR.acRed;
                                AcadEntity[] obj = new AcadEntity[1];
                                obj[0] = (AcadEntity)pl;
                                solid.AppendOuterLoop(obj);
                                solid.Evaluate();
                                solid.Layer = lab;
                            }
                            pl.Layer = lab;
                            pl.color = ACAD_COLOR.acRed;

                            double[] col2 = new double[15];
                            col2[0] = points[0].X;
                            col2[1] = -points[0].Y+60;
                            col2[2] = 0;

                            col2[3] = points[0].X;
                            col2[4] = -points[0].Y ;
                            col2[5] = 0;

                            col2[6] = points[0].X + 180;
                            col2[7] = -points[0].Y;
                            col2[8] = 0;

                            col2[9] = points[0].X + 180;
                            col2[10] = -points[0].Y+60;
                            col2[11] = 0;

                            col2[12] = points[0].X;
                            col2[13] = -points[0].Y+60;
                            col2[14] = 0;
                            AcadPolyline pl2 = cad.ActiveDocument.ModelSpace.AddPolyline(col2);
                            pl2.Layer = lab;
                            pl2.color = ACAD_COLOR.acRed;
                            //AcadEntity[] otw = new AcadEntity[1];
                            //otw[0] = (AcadEntity)pl2;
                            //wt.AppendOuterLoop(otw);
                            //wt.Layer = lab;
                        }
                        if ( u.GraphId.Contains("Substation-rdc"))
                        {
                            double[] col = new double[15];
                            col[0] = points[0].X;
                            col[1] = -points[0].Y;
                            col[2] = 0;

                            col[3] = points[0].X;
                            col[4] = -(points[0].Y + 120);
                            col[5] = 0;

                            col[6] = points[0].X + 90;
                            col[7] = -(points[0].Y + 120);
                            col[8] = 0;

                            col[9] = points[0].X + 90;
                            col[10] = -points[0].Y;
                            col[11] = 0;

                            col[12] = points[0].X;
                            col[13] = -points[0].Y;
                            col[14] = 0;

                            AcadPolyline pl = cad.ActiveDocument.ModelSpace.AddPolyline(col);
                            if (u.GraphId.Contains("gh")) { }
                            else
                            {
                                AcadHatch solid = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                                solid.PatternScale = 0.25;
                                solid.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
                                solid.color = ACAD_COLOR.acWhite;
                                AcadEntity[] obj = new AcadEntity[1];
                                obj[0] = (AcadEntity)pl;
                                solid.AppendOuterLoop(obj);
                                solid.Evaluate();
                                solid.Layer = lab;
                            }

                            pl.Layer = lab;

                            double[] col2 = new double[15];
                            col2[0] = points[0].X+90;
                            col2[1] = -points[0].Y;
                            col2[2] = 0;

                            col2[3] = points[0].X+90;
                            col2[4] = -(points[0].Y + 120);
                            col2[5] = 0;

                            col2[6] = points[0].X + 90+90;
                            col2[7] = -(points[0].Y + 120);
                            col2[8] = 0;

                            col2[9] = points[0].X + 90+90;
                            col2[10] = -points[0].Y;
                            col2[11] = 0;

                            col2[12] = points[0].X+90;
                            col2[13] = -points[0].Y;
                            col2[14] = 0;
                            AcadPolyline pl2 = cad.ActiveDocument.ModelSpace.AddPolyline(col2);
                            pl2.Layer = lab;
                            AcadEntity[] otw = new AcadEntity[1];
                            otw[0] = (AcadEntity)pl2;
                            wt.AppendOuterLoop(otw);
                            wt.Layer = lab;

                        }
                        if (u.GraphId.Contains("水电站"))
                        {

                            double[] col2 = new double[12];
                            col2[0] = points[0].X;
                            col2[1] = -points[0].Y;
                            col2[2] = 0;

                            col2[3] = points[0].X;
                            col2[4] = -points[0].Y + 120;
                            col2[5] = 0;

                            col2[6] = points[0].X + 180;
                            col2[7] = -(points[0].Y) + 120;
                            col2[8] = 0;

                            col2[9] = points[0].X;
                            col2[10] = -points[0].Y;
                            col2[11] = 0;

                            AcadPolyline pl = cad.ActiveDocument.ModelSpace.AddPolyline(col2);
                            AcadHatch solid = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                            solid.PatternScale = 0.25;
                            solid.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
                            solid.color = ACAD_COLOR.acWhite;
                            AcadEntity[] obj = new AcadEntity[1];
                            obj[0] = (AcadEntity)pl;
                            solid.AppendOuterLoop(obj);
                            solid.Evaluate();
                            solid.Layer = lab;
                            pl.Layer = lab;

                            double[] col = new double[12];
                            col[0] = points[0].X;
                            col[1] = -points[0].Y;
                            col[2] = 0;

                            col[3] = points[0].X + 180;
                            col[4] = -points[0].Y;
                            col[5] = 0;

                            col[6] = points[0].X + 180;
                            col[7] = -(points[0].Y) + 120;
                            col[8] = 0;

                            col[9] = points[0].X;
                            col[10] = -points[0].Y;
                            col[11] = 0;

                            AcadPolyline pl2 = cad.ActiveDocument.ModelSpace.AddPolyline(col);
                            pl2.Layer = lab;
                            AcadEntity[] otw = new AcadEntity[1];
                            otw[0] = (AcadEntity)pl2;
                            wt.AppendOuterLoop(otw);
                            wt.Layer = lab;
                        }
                        if (u.GraphId.Contains("gh-Substation-sdz"))
                        {

                            double[] col2 = new double[12];
                            col2[0] = points[0].X;
                            col2[1] = -points[0].Y;
                            col2[2] = 0;

                            col2[3] = points[0].X;
                            col2[4] = -points[0].Y + 120;
                            col2[5] = 0;

                            col2[6] = points[0].X + 180;
                            col2[7] = -(points[0].Y) + 120;
                            col2[8] = 0;

                            col2[9] = points[0].X;
                            col2[10] = -points[0].Y;
                            col2[11] = 0;
                            AcadPolyline pl = cad.ActiveDocument.ModelSpace.AddPolyline(col2);
                            pl.Layer = lab;

                            double[] col = new double[12];
                            col[0] = points[0].X;
                            col[1] = -points[0].Y;
                            col[2] = 0;

                            col[3] = points[0].X + 180;
                            col[4] = -points[0].Y;
                            col[5] = 0;

                            col[6] = points[0].X + 180;
                            col[7] = -(points[0].Y) + 120;
                            col[8] = 0;

                            col[9] = points[0].X;
                            col[10] = -points[0].Y;
                            col[11] = 0;

                            AcadPolyline pl2 = cad.ActiveDocument.ModelSpace.AddPolyline(col);
                            pl2.Layer = lab;
                            AcadEntity[] otw = new AcadEntity[1];
                            otw[0] = (AcadEntity)pl2;
                            wt.AppendOuterLoop(otw);
                            wt.Layer = lab;
                        }
                        if (u.GraphId.Contains("Substation-csxn"))
                        {
                            double[] col = new double[15];
                            col[0] = points[0].X;
                            col[1] = -points[0].Y;
                            col[2] = 0;

                            col[3] = points[0].X;
                            col[4] = -(points[0].Y + 120);
                            col[5] = 0;

                            col[6] = points[0].X + 180;
                            col[7] = -(points[0].Y + 120);
                            col[8] = 0;

                            col[9] = points[0].X + 180;
                            col[10] = -points[0].Y;
                            col[11] = 0;

                            col[12] = points[0].X;
                            col[13] = -points[0].Y;
                            col[14] = 0;

                            AcadPolyline pl = cad.ActiveDocument.ModelSpace.AddPolyline(col);
                            //AcadEntity[] otw = new AcadEntity[1];
                            //otw[0] = (AcadEntity)pl;
                            //wt.AppendOuterLoop(otw);
                            //wt.Layer = lab;

                            double[] col2 = new double[15];
                            col2[0] = points[0].X;
                            col2[1] = -points[0].Y-30;
                            col2[2] = 0;

                            col2[3] = points[0].X;
                            col2[4] = -(points[0].Y)- 120;
                            col2[5] = 0;

                            col2[6] = points[0].X + 90;
                            col2[7] = -(points[0].Y)- 120;
                            col2[8] = 0;

                            col2[9] = points[0].X + 90;
                            col2[10] = -points[0].Y-30;
                            col2[11] = 0;

                            col2[12] = points[0].X;
                            col2[13] = -points[0].Y-30;
                            col2[14] = 0;

                            AcadPolyline pl2 = cad.ActiveDocument.ModelSpace.AddPolyline(col2);
                            double[] col3 = new double[15];
                            col3[0] = points[0].X+90;
                            col3[1] = -points[0].Y-60;
                            col3[2] = 0;

                            col3[3] = points[0].X+90;
                            col3[4] = -(points[0].Y )- 120;
                            col3[5] = 0;

                            col3[6] = points[0].X + 180;
                            col3[7] = -(points[0].Y) - 120;
                            col3[8] = 0;

                            col3[9] = points[0].X + 180;
                            col3[10] = -points[0].Y-60;
                            col3[11] = 0;

                            col3[12] = points[0].X+90;
                            col3[13] = -points[0].Y-60;
                            col3[14] = 0;

                            AcadPolyline pl3 = cad.ActiveDocument.ModelSpace.AddPolyline(col3);
                            if (u.GraphId.Contains("gh")) { }
                            else
                            {
                                AcadHatch solid = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                                solid.PatternScale = 0.25;
                                solid.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
                                solid.color = ACAD_COLOR.acWhite;
                                AcadEntity[] obj = new AcadEntity[1];
                                obj[0] = (AcadEntity)pl2;
                                solid.AppendOuterLoop(obj);
                                solid.Evaluate();
                                solid.Layer = lab;
                                AcadHatch solid2 = cad.ActiveDocument.ModelSpace.AddHatch(0, "JIS_LC_20", true, 0);
                                solid2.PatternScale = 0.25;
                                solid2.Lineweight = ACAD_LWEIGHT.acLnWtByLwDefault;
                                solid2.color = ACAD_COLOR.acWhite;
                                AcadEntity[] obj2 = new AcadEntity[1];
                                obj2[0] = (AcadEntity)pl3;
                                solid2.AppendOuterLoop(obj2);
                                solid2.Evaluate();
                                solid2.Layer = lab;
                            }

                            pl.Layer = lab;
                            pl2.Layer = lab;
                            pl3.Layer = lab;

                        }
                    }
                    catch { }
                }

            }
            //wt.color = ACAD_COLOR.acWhite;

            try
            {
                wt.Evaluate();
                h.Evaluate();
                h.Layer = lab;
            }
            catch(Exception e2) { }

            try
            {
                h2.Evaluate();
                h2.Layer = lab;
            }
            catch(Exception e3) { }

            try
            {
                h3.Evaluate();
                h3.Layer = lab;
            }
            catch { }
            try
            {
                h4.Evaluate();
                h4.Layer = lab;
            }
            catch { }
            try
            {
                h5.Evaluate();
                h5.Layer = lab;
            }
            catch { }
            cad.Application.Update();
            //cad.ActiveDocument.SendCommand("Z e ");
        }
Пример #13
0
 /// <summary>
 /// 替换审核者、设计者、日期等属性
 /// </summary>
 /// <param name="entity"></param>
 public static void ReplaceProperty(AcadEntity entity, AcadBlocks blocks, Bussiness.Rules rules)
 {
     if (entity.ObjectName == "AcDbBlockReference")
     {
         var s = ((AcadBlockReference)entity);
         var name = blocks.Item(s.Name).Name;
         blocks.Item(s.Name).Name = rand.Next().ToString();
         if (s.HasAttributes)
         {
             AcadAttributeReference bb;
             object[] aa = (object[])s.GetAttributes();
             for (int i = 0; i < aa.Length; i++)
             {
                 bb = aa[i] as AcadAttributeReference;
                 if (bb != null)
                 {
                     if (bb.TagString != "---------" && bb.TagString != "------" && !bb.TagString.Contains("GEN-TITLE-MAT") && !bb.TagString.Contains("GEN-TITLE-DES") && bb.TagString != "01" && !bb.TagString.Contains("GEN-TITLE-SCA{6.14,1}"))
                     {
                         bb.TextString = "";
                     }
                     if (bb.TagString == "---------")
                     {
                         oldCode = bb.TextString;
                         oldCode = ReplaceStr(oldCode);
                         var startCode = oldCode.Substring(0, RegexCode());
                         var endCode = oldCode.Substring(RegexCode(), oldCode.Length - RegexCode());
                         Hashtable hash = rules.GetRules();
                         foreach (DictionaryEntry de in hash)
                         {
                             if (startCode == de.Key.ToString())
                             {
                                 startCode = de.Value.ToString();
                             }
                         }
                         newCode = startCode + "0" + Rand();
                         if (!string.IsNullOrEmpty(newCode)) bb.TextString = newCode;
                     }
                 }
             }
         }
     }
     else if (entity.ObjectName == "AcDbMText")
     {
         AcadMText mtext = entity as AcadMText;
         if (mtext != null)
         {
             if (mtext.TextString.Contains("FAX") || mtext.TextString.Contains("TEL") || mtext.TextString.Contains("TOMITA"))
             {
                 mtext.TextString = "";
             }
         }
     }
 }
Пример #14
0
 /// <summary>
 /// 替换装配图中的明细表中的编号
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="acAppComObj"></param>
 /// <param name="ds"></param>
 public static void ReplaceDrawingCode(AcadEntity entity, AcadApplication acAppComObj)
 {
     if (entity.ObjectName == "AcmPartRef")
     {
         AXDBLib.AcadObject obj = entity as AXDBLib.AcadObject;
         McadSymbolBBMgr symbb = (McadSymbolBBMgr)acAppComObj.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr");
         McadBOMMgr bommgr = (McadBOMMgr)symbb.BOMMgr;
         oldCode = bommgr.GetPartAttribute(obj, "DESCR", false);
         string newCode = getByNewCode(oldCode);
         if (!string.IsNullOrEmpty(newCode)) bommgr.SetPartAttribute(obj, "DESCR", newCode);
     }
 }
Пример #15
0
        public void DrawAxes()
        {
            if (!CheckLicense.Check())
            {
                return;
            }

            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var db  = doc.Database;

            // Reset parameters
            Alignment       = Bridge.AlignmentType.None;
            CenterlineId    = ObjectId.Null;
            StartPoint      = Point3d.Origin;
            StartCH         = 0;
            SelectionMethod = AxisSelectionMethod.Point;
            AxisDistance    = DefaultAxisDistance;
            LastAxisPoint   = Point3d.Origin;

            Prefix = "A";
            Suffix = "";
            Number = 1;

            FirstRun = true;

            // Pick alignment
            if (!GetAlignmentParameters())
            {
                return;
            }

            // Print axes
            while (true)
            {
                // Calculate axis insertion point and chainage
                if (GetAxisInsertionPoint(out Point3d axisPoint, out double axisDistanceFromStartPoint, out Vector3d axisDirection))
                {
                    // Axis name
                    if (!GetAxisName())
                    {
                        return;
                    }

                    if (DrawingType == AxisDrawingType.Line || !AcadEntity.BlockExists(db, BlockName))
                    {
                        DrawAxisLine(axisPoint, axisDirection, StartCH + axisDistanceFromStartPoint);
                    }
                    else
                    {
                        DrawAxisBlock(axisPoint, axisDirection, StartCH + axisDistanceFromStartPoint);
                    }

                    // Increment axis number
                    FirstRun      = false;
                    Number       += 1;
                    LastAxisPoint = axisPoint;
                }
                else
                {
                    break;
                }
            }
        }