Example #1
0
        public DrawParameters(
            [NotNull] Database db,
            [CanBeNull] LayerInfo layer = null,
            [CanBeNull] Color color     = null,
            LineWeight?lineWeight       = null,
            [CanBeNull] string lineType = null,
            double?lineTypeScale        = null)
        {
            this.db = db;

            // Сохранение текущих свойств чертежа
            oldLayer      = db.Clayer;
            oldColor      = db.Cecolor;
            oldLineWeight = db.Celweight;
            oldLineType   = db.Celtype;
            oldLineScale  = db.Celtscale;

            Layer         = layer;
            Color         = color;
            LineWeight    = lineWeight;
            LineType      = lineType;
            LineTypeScale = lineTypeScale;

            // установка новых свойств чертежу
            Setup();
        }
Example #2
0
 modifyLayer(ObjectId idLayer, short colorIndex, LineWeight weight, string nameLineType = null)
 {
     try
     {
         using (BaseObjs._acadDoc.LockDocument())
         {
             using (Transaction tr = BaseObjs.startTransactionDb())
             {
                 LayerTableRecord Ltr = (LayerTableRecord)tr.GetObject(idLayer, OpenMode.ForWrite);
                 Ltr.Color      = Color.FromColorIndex(ColorMethod.ByBlock, colorIndex);
                 Ltr.LineWeight = weight;
                 if (nameLineType != null)
                 {
                     LinetypeTable LTT = Base_Tools45.LineType.getLineTypeTable();
                     if (LTT.Has(nameLineType) == false)
                     {
                         BaseObjs._db.LoadLineTypeFile(nameLineType, "acad.lin");
                     }
                     Ltr.LinetypeObjectId = LTT[nameLineType];
                 }
                 tr.Commit();
             }
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(ex.Message + " Layer.cs: line: 346");
     }
 }
Example #3
0
        /// <summary>
        /// Создает новый слой на четртеже по имени и задает толщину линии для слоя
        /// </summary>
        /// <param name="layerName"></param>
        /// <param name="lineWeight"></param>
        public void CreateNewLayer(string layerName, LineWeight lineWeight)
        {
            // Open the Layer table for read
            LayerTable layerTable;

            layerTable = _transaction.GetObject(_dataBase.LayerTableId,
                                                OpenMode.ForRead) as LayerTable;

            // создаем только если слоя еще нет
            if (layerTable.Has(layerName) == false)
            {
                // создаем новый слой и задаем ему параметры
                using (LayerTableRecord newLayer = new LayerTableRecord())
                {
                    newLayer.Name       = layerName;
                    newLayer.LineWeight = lineWeight;

                    // Upgrade the Layer table for write
                    layerTable.UpgradeOpen();

                    // Append the new layer to the Layer table and the transaction
                    layerTable.Add(newLayer);
                    _transaction.AddNewlyCreatedDBObject(newLayer, true);
                }
            }
        }
Example #4
0
        public static Hatch SetCellHatch(
            [NotNull] this Cell cell,
            int colorIndex         = 0,
            LineWeight lineWeight  = LineWeight.LineWeight015,
            double patternScale    = 1,
            string standartPattern = "LINE",
            double patternAngleRad = 0)
        {
            var table = cell.ParentTable;

            table.RecomputeTableBlock(true);
            var btr     = (BlockTableRecord)table.OwnerId.GetObject(OpenMode.ForWrite);
            var cellExt = OffsetExtToMarginCell(cell.GetExtents().ToExtents3d(), cell);

            using var cellPl = cellExt.GetPolyline();
            var h = cellPl.GetPoints().CreateHatch();

            h.PatternAngle = patternAngleRad;
            h.PatternScale = patternScale;
            h.SetHatchPattern(HatchPatternType.PreDefined, standartPattern);
            h.ColorIndex = colorIndex;
            h.LineWeight = lineWeight;
            h.Linetype   = SymbolUtilityServices.LinetypeContinuousName;
            var t = btr.Database.TransactionManager.TopTransaction;

            btr.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);
            h.EvaluateHatch(true);
            return(h);
        }
Example #5
0
        public override void XmlOut(Filer.XmlFiler filer)
        {
            base.XmlOut(filer);

            filer.Write("Color", Color);
            filer.Write("LineWeight", LineWeight.ToString());
            filer.Write("Layer", LayerId);
        }
Example #6
0
 private static void SetRowHeader([NotNull] Row row, LineWeight lw)
 {
     SetCell(row.Borders.Bottom, lw, true);
     SetCell(row.Borders.Horizontal, lw, true);
     SetCell(row.Borders.Left, lw, true);
     SetCell(row.Borders.Right, lw, true);
     SetCell(row.Borders.Top, lw, true);
     SetCell(row.Borders.Vertical, lw, true);
 }
Example #7
0
 private static void setRowHeader(Row row, LineWeight lw)
 {
     setCell(row.Borders.Bottom, lw, true);
     setCell(row.Borders.Horizontal, lw, true);
     setCell(row.Borders.Left, lw, true);
     setCell(row.Borders.Right, lw, true);
     setCell(row.Borders.Top, lw, true);
     setCell(row.Borders.Vertical, lw, true);
 }
Example #8
0
 public static Hatch CreateAssociativeHatch(
     [NotNull] Curve loop,
     [NotNull] BlockTableRecord cs,
     [NotNull] Transaction t,
     string pattern           = "SOLID",
     [CanBeNull] string layer = null,
     LineWeight lw            = LineWeight.LineWeight015)
 {
     return(CreateAssociativeHatch(loop, cs, t, 1, pattern, layer, lw));
 }
Example #9
0
        /// <summary>
        /// 反射光线粗细设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLineWeight_Click(object sender, EventArgs e)
        {
            LineWeightDialog lwd = new LineWeightDialog();

            lwd.ShowDialog();
            lw = lwd.LineWeight;
            ed.WriteMessage(lwd.LineWeight.ToString());

            this.Refresh();
        }
Example #10
0
        public static LayerTableRecord CreateLayer(string name, Color color, LineWeight weight)
        {
            LayerTableRecord layer = new LayerTableRecord
            {
                Name       = name,
                Color      = color,
                LineWeight = weight
            };

            return(layer);
        }
Example #11
0
        private static LayerInfo GetLayerInfo(string name, Color color, LineWeight lw, string lt, bool isPlottable = true)
        {
            var layInfo = new LayerInfo(name)
            {
                Color      = color,
                LineWeight = lw,
                LineType   = lt,
                IsPlotable = isPlottable
            };

            layInfo.CheckLayerState();
            return(layInfo);
        }
Example #12
0
        public static void Polyline(Layers.LayerInfo layer = null, Color color=null, LineWeight? lineWeight = null,
                                        string lineType = null, double? lineTypeScale = null)
        {
            // Обертка запуска команды рисования полилинии с заданными свойствами.
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            // Вызов команды рисования полилинии
            using (new DrawParameters(db, layer, color, lineWeight, lineType, lineTypeScale))
            {
                doc.Editor.Command("_PLINE");
            }
        }
Example #13
0
 public EntityInfo(Entity ent)
 {
     ClassName = ent.GetRXClass().Name;
     Id        = ent.Id;
     if (ent.Bounds.HasValue)
     {
         Extents = ent.Bounds.Value;
     }
     ClassId    = ent.ClassID;
     Color      = ent.Color.ColorValue;
     Layer      = ent.Layer;
     Linetype   = ent.Linetype;
     Lineweight = ent.LineWeight;
 }
Example #14
0
        public static void SetBorders(this Table table, LineWeight lw)
        {
            if (table.Rows.Count < 2) return;

            var rowTitle = table.Rows[0];
            setRowTitle(rowTitle);

            var rowHead = table.Rows[1];
            setRowHeader(rowHead, lw);

            foreach (var row in table.Rows.Skip(2))
            {
                setRowData(row, lw);
            }
        }
Example #15
0
        public override bool Read(string name, out LineWeight value)
        {
            XmlNode node = _curXmlNode.SelectSingleNode(name);

            if (node == null)
            {
                value = LineWeight.ByLineWeightDefault;
                return(false);
            }

            //
            value = (LineWeight)Enum.Parse(
                typeof(LineWeight), node.InnerText, true);
            return(true);
        }
Example #16
0
        /// <summary>
        /// Создание ассоциативной штриховки по полилинии
        /// Полилиния должна быть в базе чертежа
        /// </summary>
        public static Hatch?CreateAssociativeHatch(
            [NotNull] Curve loop,
            [NotNull] BlockTableRecord cs,
            [NotNull] Transaction t,
            double scale,
            string pattern           = "SOLID",
            [CanBeNull] string layer = null,
            LineWeight lw            = LineWeight.LineWeight015)
        {
            var h = new Hatch();

            if (layer != null)
            {
                Layers.LayerExt.CheckLayerState(layer);
                h.Layer = layer;
            }

            h.LineWeight   = lw;
            h.Linetype     = SymbolUtilityServices.LinetypeContinuousName;
            h.PatternScale = scale;
            h.SetHatchPattern(HatchPatternType.PreDefined, pattern);
            cs.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);
            h.Associative = true;
            h.HatchStyle  = HatchStyle.Normal;

            // добавление контура полилинии в гштриховку
            var ids = new ObjectIdCollection {
                loop.Id
            };

            try
            {
                h.AppendLoop(HatchLoopTypes.Default, ids);
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex, $"CreateAssociativeHatch");
                h.Erase();
                return(null);
            }

            h.EvaluateHatch(true);
            var orders = (DrawOrderTable)cs.DrawOrderTableId.GetObject(OpenMode.ForWrite);

            orders.MoveToBottom(new ObjectIdCollection(new[] { h.Id }));
            return(h);
        }
Example #17
0
        /// <summary>
        /// Создает полилинию с указанной толщиной линии
        /// </summary>
        /// <param name="beginX"></param>
        /// <param name="beginY"></param>
        /// <param name="endX"></param>
        /// <param name="endY"></param>
        /// <param name="lineWeight"></param>
        public void MakePolyline(int beginX, int beginY, int endX, int endY, LineWeight lineWeight)
        {
            // Create a lightweight polyline
            using (Polyline acPoly = new Polyline())
            {
                acPoly.AddVertexAt(0, new Point2d(beginX, beginY), 0, 0, 0);
                acPoly.AddVertexAt(1, new Point2d(endX, endY), 0, 0, 0);

                // устанавливаем толщину линии
                acPoly.LineWeight = lineWeight;

                // Add the new object to the block table record and the transaction
                _model.AppendEntity(acPoly);
                _transaction.AddNewlyCreatedDBObject(acPoly, true);

                // Close the polyline
                acPoly.Closed = true;
            }
        }
Example #18
0
        public DrawParameters(Database db, LayerInfo layer = null, Color color = null, 
                            LineWeight? lineWeight = null, string lineType = null, double? lineTypeScale = null)
        {
            this.db = db;
            // Сохранение текущих свойств чертежа
            oldLayer = db.Clayer;
            oldColor = db.Cecolor;
            oldLineWeight = db.Celweight;
            oldLineType = db.Celtype;
            oldLineScale = db.Celtscale;

            Layer = layer;
            Color = color;
            LineWeight = lineWeight;
            LineType = lineType;
            LineTypeScale = lineTypeScale;
            // установка новых свойств чертежу
            Setup();
        }
Example #19
0
        public static void SetBorders([NotNull] this Table table, LineWeight lw)
        {
            if (table.Rows.Count < 2)
            {
                return;
            }

            var rowTitle = table.Rows[0];

            SetRowTitle(rowTitle);

            var rowHead = table.Rows[1];

            SetRowHeader(rowHead, lw);

            foreach (var row in table.Rows.Skip(2))
            {
                SetRowData(row, lw);
            }
        }
Example #20
0
        /// <summary>
        /// Создает квадрат с указанной толщиной линии
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="lineWeight"></param>
        public void MakeBox(int width, int height, LineWeight lineWeight)
        {
            // Create a lightweight polyline
            using (Polyline acPoly = new Polyline())
            {
                acPoly.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0);
                acPoly.AddVertexAt(1, new Point2d(width, 0), 0, 0, 0);
                acPoly.AddVertexAt(2, new Point2d(width, height), 0, 0, 0);
                acPoly.AddVertexAt(3, new Point2d(0, height), 0, 0, 0);

                acPoly.LineWeight = lineWeight;

                // Add the new object to the block table record and the transaction
                _model.AppendEntity(acPoly);
                _transaction.AddNewlyCreatedDBObject(acPoly, true);

                // Close the polyline
                acPoly.Closed = true;
            }
        }
        private static double GetLineWeight(LineWeight lineWeight)
        {
            switch (lineWeight.Type) {
                case LineWeightType.Thick:
                    return 0.0007;

                case LineWeightType.Thin:
                    return 0.0003;

                case LineWeightType.Numeric:
                    return lineWeight.Thickness;

                case LineWeightType.ThickMissingThick:
                case LineWeightType.ThickThinThick:
                    return 0.0001;

                default:
                    throw new NotSupportedException("Unhandled Line Thickness");
            }
        }
Example #22
0
        public LineFormat(IStreamReader reader, GraphRecordNumber id, ushort length)
            : base(reader, id, length)
        {
            // assert that the correct record type is instantiated
            Debug.Assert(this.Id == ID);

            // initialize class members from stream
            this.rgb = new RGBColor(reader.ReadInt32(), RGBColor.ByteOrder.RedFirst);
            this.lns = (LineStyle)reader.ReadInt16();
            this.we  = (LineWeight)reader.ReadInt16();
            ushort flags = reader.ReadUInt16();

            this.fAuto = Utils.BitmaskToBool(flags, 0x1);
            // 0x2 is reserved
            this.fAxisOn = Utils.BitmaskToBool(flags, 0x4);
            this.fAutoCo = Utils.BitmaskToBool(flags, 0x8);
            this.icv     = reader.ReadUInt16();

            // assert that the correct number of bytes has been read from the stream
            Debug.Assert(this.Offset + this.Length == this.Reader.BaseStream.Position);
        }
Example #23
0
        private static double GetLineWeight(LineWeight lineWeight)
        {
            switch (lineWeight.Type)
            {
            case LineWeightType.Thick:
                return(0.0007);

            case LineWeightType.Thin:
                return(0.0003);

            case LineWeightType.Numeric:
                return(lineWeight.Thickness);

            case LineWeightType.ThickMissingThick:
            case LineWeightType.ThickThinThick:
                return(0.0001);

            default:
                throw new NotSupportedException("Unhandled Line Thickness");
            }
        }
        /// <summary>
        /// 修改图层的线宽
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="LayerName">图层名</param>
        /// <param name="lineWeight">线宽</param>
        /// <returns>bool</returns>
        public static bool ChangleLineWeight(this Database db, string LayerName, LineWeight lineWeight)
        {
            bool isOk = true;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //打开层表
                LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead);
                //判断指定的图形名是否存在
                if (lt.Has(LayerName))
                {
                    LayerTableRecord ltr = (LayerTableRecord)lt[LayerName].GetObject(OpenMode.ForWrite);
                    ltr.LineWeight = lineWeight;
                    trans.Commit();
                }
                else
                {
                    isOk = false;
                }
            }
            return(isOk);
        }
Example #25
0
        /// <summary>
        /// Создание ассоциативной штриховки по полилинии
        /// Полилиния должна быть в базе чертежа
        /// </summary>        
        public static Hatch CreateAssociativeHatch(Curve loop, BlockTableRecord cs, Transaction t,
            string pattern = "SOLID", string layer = null, LineWeight lw = LineWeight.LineWeight015)
        {
            var h = new Hatch();
            h.SetDatabaseDefaults();
            if (layer != null)
            {
                Layers.LayerExt.CheckLayerState(layer);
                h.Layer = layer;
            }
            h.LineWeight = lw;
            h.Linetype = SymbolUtilityServices.LinetypeContinuousName;
            h.SetHatchPattern(HatchPatternType.PreDefined, pattern);
            cs.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);
            h.Associative = true;
            h.HatchStyle = HatchStyle.Normal;

            // добавление контура полилинии в гштриховку
            var ids = new ObjectIdCollection();
            ids.Add(loop.Id);
            try
            {
                h.AppendLoop(HatchLoopTypes.Default, ids);
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex, $"CreateAssociativeHatch");
                h.Erase();
                return null;
            }
            h.EvaluateHatch(true);

            var orders = cs.DrawOrderTableId.GetObject(OpenMode.ForWrite) as DrawOrderTable;
            orders.MoveToBottom(new ObjectIdCollection(new[] { h.Id }));

            return h;
        }
Example #26
0
 private static void SetCell([NotNull] CellBorder cell, LineWeight lw, bool visible)
 {
     cell.LineWeight = lw;
     cell.IsVisible  = visible;
 }
Example #27
0
 /// <summary>
 /// 通过图层id  设置图层的各种属性
 /// </summary>
 /// <param name="ltrId"> 指定要设置的图层id</param>
 /// <param name="coloIndex">要设置的颜色值</param>
 /// <param name="isLocked"> 指定图层是否锁定 </param>
 /// <param name="LineWeight"> 指定图层线宽 </param>
 public static void setLayerProperties(this ObjectId ltrId, short coloIndex = 4, bool isLocked = false, LineWeight lineWeight = LineWeight.LineWeight050)
 {
     ltrId.QOpenForWrite <LayerTableRecord>(ltr => {
         ltr.Color      = Color.FromColorIndex(ColorMethod.ByAci, coloIndex);
         ltr.IsLocked   = isLocked;
         ltr.LineWeight = lineWeight;
     });
 }
 void ChangeLineWeight(LineWeight lw)
 {
     acCurDb.Celweight = lw;           //Автодеск, блять, почему такие имена переменных
 }
Example #29
0
        static public void MatchPropReverse()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            PromptSelectionResult psres = ed.SelectImplied();

            // if there is no selected obj prior this command
            if (psres.Status == PromptStatus.Error)
            {
                // Select objects
                PromptSelectionOptions psopt = new PromptSelectionOptions();
                psopt.MessageForAdding   = "\nSelect objects : ";
                psopt.AllowDuplicates    = false;
                psopt.AllowSubSelections = false;
                psres = ed.GetSelection(psopt);
            }
            // if there is an obj selected prior this command
            else
            {
                ed.SetImpliedSelection(new ObjectId[0]);
            }

            // if the user has not cancelled this operation
            if (psres.Status == PromptStatus.OK)
            {
                using (Transaction tx = db.TransactionManager.StartTransaction())
                {
                    //BlockTable bt = tx.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                    //BlockTableRecord btrec = tx.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite) as BlockTableRecord;

                    LayerTable       laytab    = tx.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
                    LayerTableRecord laytabrec = null;

                    DBObjectCollection dbocoll = new DBObjectCollection();
                    //ObjectId[] oids = psres.Value.GetObjectIds();
                    SelectionSet selset = psres.Value;

                    foreach (SelectedObject selobj in selset)
                    {
                        if (selobj == null)
                        {
                            ed.WriteMessage("\nNull obj detected > ID : " + selobj.ObjectId);
                        }

                        Entity ent = tx.GetObject(selobj.ObjectId, OpenMode.ForWrite) as Entity;

                        dbocoll.Add(ent);
                        //ed.WriteMessage("\nObjId original : " + selobj.ObjectId);
                    }

                    // Select donor obj v2
                    PromptEntityResult per_d = ed.GetEntity("\nSelect source object : ");
                    if (per_d.Status != PromptStatus.OK)
                    {
                        return;
                    }
                    Entity en_d = tx.GetObject(per_d.ObjectId, OpenMode.ForRead) as Entity;


                    // Get donor obj properties
                    string     en_lyr = en_d.Layer;
                    int        en_clr = en_d.ColorIndex;
                    string     en_lt  = en_d.Linetype;
                    LineWeight en_lw  = en_d.LineWeight;
                    ed.WriteMessage("\nDonor layer/color/linetype/lineweight is : " + en_lyr + en_clr + "/" + en_lt + "/" + en_lw + "/n");

                    // Casting properties to selection set
                    foreach (Entity en in dbocoll)
                    {
                        en.Layer      = en_lyr;
                        en.ColorIndex = en_clr;
                        en.Linetype   = en_lt;
                        en.LineWeight = en_lw;
                    }
                    ed.Regen();
                    tx.Commit();
                }
            }
        }
        public static ObjectId CreateLayer(this Database database, string layName, short colorIndex, string description, bool layerIsLocked = false, bool isPlottable = true, bool isHidden = false, LineWeight lineWeight = LineWeight.ByLineWeightDefault)
        {
            using (var transAction = database.TransactionManager.StartOpenCloseTransaction())
            {
                // Get the layer table from the drawing
                using (var layerTable = (LayerTable)transAction.GetObject(database.LayerTableId, OpenMode.ForRead))
                {
                    //make sure name is valid according to the SymbolUtilityService
                    SymbolUtilityServices.ValidateSymbolName(layName, false);

                    if (layerTable.Has(layName))
                    {
                        //we return the object-id of the layer, we have the layer already... (so you could say it has been created)
                        return(layerTable[layName]);
                    }

                    ObjectId id;
                    //create the layer
                    using (var newLayerTableRecord = new LayerTableRecord())

                    {
                        // Add the new layer to the layer table
                        layerTable.UpgradeOpen();

                        id = layerTable.Add(newLayerTableRecord);

                        transAction.AddNewlyCreatedDBObject(newLayerTableRecord, true);
                        // ... and set its properties
                        newLayerTableRecord.Name        = layName;
                        newLayerTableRecord.Color       = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, colorIndex);
                        newLayerTableRecord.Description = description;
                        newLayerTableRecord.IsLocked    = layerIsLocked;
                        newLayerTableRecord.IsHidden    = isHidden;
                        newLayerTableRecord.IsPlottable = isPlottable;
                        newLayerTableRecord.LineWeight  = lineWeight;
                        transAction.Commit();
                    }
                    return(id);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LineWeightWrapper"/> class.
 /// </summary>
 /// <param name="displayName">Отображаемое имя</param>
 /// <param name="lineWeight">Соответствующий <see cref="Autodesk.AutoCAD.DatabaseServices.LineWeight"/></param>
 internal LineWeightWrapper(string displayName, LineWeight lineWeight)
 {
     DisplayName = displayName;
     LineWeight  = lineWeight;
 }
        public void Poly3DFromCorridorFeatureLines()
        {
            Document adoc = Application.DocumentManager.MdiActiveDocument;

            if (adoc == null)
            {
                return;
            }

            Database db = adoc.Database;

            Editor ed = adoc.Editor;

            try
            {
                //Указать объект корридора
                PromptEntityOptions peo1 = new PromptEntityOptions("\nУкажите корридор");
                peo1.SetRejectMessage("\nМожно выбрать только корридор");
                peo1.AddAllowedClass(typeof(Corridor), true);
                PromptEntityResult per1 = ed.GetEntity(peo1);

                if (per1.Status == PromptStatus.OK)
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        Corridor corridor = tr.GetObject(per1.ObjectId, OpenMode.ForWrite) as Corridor;

                        BaselineCollection baselines = corridor.Baselines;

                        foreach (Baseline bLine in baselines)
                        {
                            BaselineFeatureLines featureLines = bLine.MainBaselineFeatureLines;

                            FeatureLineCollectionMap featureLineCollMap = featureLines.FeatureLineCollectionMap;

                            foreach (FeatureLineCollection featureLineColl in featureLineCollMap)
                            {
                                foreach (CorridorFeatureLine corrFeatureLine in featureLineColl)
                                {
                                    string codeName = corrFeatureLine.CodeName;
                                    //Сразу чертит все полилинии
                                    ObjectIdCollection polyColl = corrFeatureLine.ExportAsPolyline3dCollection();

                                    if (!String.IsNullOrEmpty(codeName))
                                    {
                                        //Все 3d полилинии переносятся в слой, который называется так же как код линии
                                        short      colorIndex = 3;
                                        LineWeight lineWeight = LineWeight.ByLayer;
                                        string     layerName  = codeName;
                                        if (codeName.Equals("КПЧ"))
                                        {
                                            colorIndex = 30;
                                            lineWeight = LineWeight.LineWeight030;
                                        }
                                        else if (codeName.Equals("ОТК") || codeName.Equals("Hinge") || codeName.Equals("Daylight") ||
                                                 codeName.Equals("Отсчет") || codeName.Equals("Выход на поверхность"))
                                        {
                                            colorIndex = 50;
                                            lineWeight = LineWeight.LineWeight030;
                                            layerName  = "ОТК";
                                        }


                                        ObjectId layerId = Utils.CreateLayerIfNotExists(layerName, db, tr, null,
                                                                                        Color.FromColorIndex(ColorMethod.ByAci, colorIndex), lineWeight);
                                        foreach (ObjectId polyId in polyColl)
                                        {
                                            Polyline3d polyline = tr.GetObject(polyId, OpenMode.ForWrite) as Polyline3d;
                                            if (polyline != null)
                                            {
                                                polyline.LayerId = layerId;
                                            }
                                        }
                                    }
                                }
                            }
                        }


                        tr.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                //Utils.ErrorToCommandLine(ed, "Ошибка при построении полилиний по линиям корридора", ex);
                CommonException(ex, "Ошибка при построении полилиний по линиям корридора");
            }
        }
        /// <summary>
        /// 新建图层
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="layername">图层名</param>
        /// <param name="colorIndex">颜色索引</param>
        /// <param name="linetype">线型</param>
        /// <param name="lineWeight">线宽</param>
        /// <param name="isprint">是否打印</param>
        /// <param name="zs">注释</param>
        /// <returns></returns>
        public static ObjectId AddLayer(this Database db, string layername, short colorIndex, string linetype, LineWeight lineWeight, bool isprint, string zs)
        {
            //打开层表
            LayerTable lt = (LayerTable)db.LayerTableId.GetObject(OpenMode.ForRead);

            if (!lt.Has(layername))
            {
                LayerTableRecord ltr = new LayerTableRecord
                {
                    Name  = layername,
                    Color = Color.FromColorIndex(ColorMethod.ByAci, colorIndex)
                };//定义一个新的层表记录
                LinetypeTable ltt = (LinetypeTable)db.LinetypeTableId.GetObject(OpenMode.ForRead);
                if (ltt.Has(linetype))
                {
                    ltr.LinetypeObjectId = ltt[linetype];
                }
                else
                {
                    db.LoadLineTypeFile(linetype, "acadiso.lin");
                    ltr.LinetypeObjectId = ltt[linetype];
                }
                ltr.LineWeight  = lineWeight;
                ltr.IsPlottable = isprint;
                ltr.Description = zs;
                lt.UpgradeOpen();
                lt.Add(ltr);
                db.TransactionManager.AddNewlyCreatedDBObject(ltr, true);
                lt.DowngradeOpen();
            }
            return(lt[layername]);
        }
Example #34
0
 private static void setCell(CellBorder cell, LineWeight lw, bool visible)
 {
     //cell.Overrides = GridProperties.Visibility | GridProperties.LineWeight;
     cell.LineWeight = lw;
     cell.IsVisible = visible;
 }
Example #35
0
        private void CreateTableStyle(string tableStyleName, string textStyleName, LineWeight lineWeight, out ObjectId tsObjID)
        {
            using (Transaction tr = m_db.TransactionManager.StartTransaction())
            {
                tsObjID = ObjectId.Null;
                DBDictionary dbDic = tr.GetObject(m_db.TableStyleDictionaryId, OpenMode.ForRead) as DBDictionary;
                if (dbDic.Contains(tableStyleName))
                {
                    tsObjID = dbDic.GetAt(tableStyleName);
                }
                else
                {
                    TableStyle newTs = new TableStyle();
                    TextStyleTable test = tr.GetObject(m_db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                    //if (test.Has(textStyleName))
                        //newTs.SetTextStyle(m_db.TextStyleTableId, textStyleName);
                    newTs.SetGridLineWeight(lineWeight, (int)GridLineType.AllGridLines, (int)GridLineType.AllGridLines);
                    tsObjID = newTs.PostTableStyleToDatabase(m_db, tableStyleName);
                    tr.AddNewlyCreatedDBObject(newTs, true);
                }

                tr.Commit();
            }
        }
Example #36
0
 public override bool Write(string name, LineWeight value)
 {
     return(_Write(name, value));
 }
Example #37
0
        /// <summary>
        /// Создать слой если еще нет
        /// </summary>
        /// <param name="layerName"></param>
        /// <param name="db"></param>
        /// <param name="tr"></param>
        /// <param name="layerSample">образец для создания слоя если еще нет</param>
        /// <param name="color"></param>
        /// <param name="lineWeight"></param>
        /// <returns></returns>
        public static ObjectId CreateLayerIfNotExists(string layerName, Database db, Transaction tr,
                                                      LayerTableRecord layerSample = null, Color color = null, /*short colorIndex = -1,*/ LineWeight lineWeight = LineWeight.ByLayer)
        {
            LayerTable lt      = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
            ObjectId   layerId = ObjectId.Null;

            if (!lt.Has(layerName))
            {
                lt.UpgradeOpen();
                LayerTableRecord ltrNew = null;
                if (layerSample != null)
                {
                    ltrNew = (LayerTableRecord)layerSample.Clone();
                }
                else
                {
                    ltrNew = new LayerTableRecord();
                    if (color != null /*colorIndex != -1*/)
                    {
                        //Color color = Color.FromColorIndex(ColorMethod.ByAci, colorIndex);
                        ltrNew.Color = color;
                    }
                    if (lineWeight != LineWeight.ByLayer)
                    {
                        ltrNew.LineWeight = lineWeight;
                    }
                }

                ltrNew.Name = layerName;
                layerId     = lt.Add(ltrNew);
                tr.AddNewlyCreatedDBObject(ltrNew, true);
            }
            else
            {
                layerId = lt[layerName];
            }

            return(layerId);
        }
Example #38
0
 public int CompareTo(Shape other)
 {
     return(LineWeight.CompareTo(other.LineWeight));
 }