Esempio n. 1
0
 /// <summary>
 /// Установка свойств для однострочного текста
 /// </summary>
 /// <param name="dbText">Однострочный текст</param>
 /// <param name="textStyle">имя текстового стиля</param>
 /// <param name="height">Высота текста (с учетом масштаба блока)</param>
 /// <param name="horizontalMode">Выравнивание по горизонтали</param>
 /// <param name="verticalMode">Выравнивание по вертикали</param>
 /// <param name="attachmentPoint">Привязка к точке вставки</param>
 public static void SetPropertiesToDbText(
     this DBText dbText,
     string textStyle,
     double height,
     TextHorizontalMode?horizontalMode = null,
     TextVerticalMode?verticalMode     = null,
     AttachmentPoint?attachmentPoint   = null)
 {
     dbText.Height = height;
     if (horizontalMode.HasValue)
     {
         dbText.HorizontalMode = horizontalMode.Value;
     }
     if (verticalMode.HasValue)
     {
         dbText.VerticalMode = verticalMode.Value;
     }
     if (attachmentPoint.HasValue)
     {
         dbText.Justify = attachmentPoint.Value;
     }
     dbText.Color       = Color.FromColorIndex(ColorMethod.ByBlock, 0);
     dbText.Linetype    = "ByBlock";
     dbText.LineWeight  = LineWeight.ByBlock;
     dbText.TextStyleId = AcadUtils.GetTextStyleIdByName(textStyle);
 }
Esempio n. 2
0
        /// <summary>
        /// save layers to xml
        /// </summary>
        /// <param name="layerTableRecord">Instance of <see cref="LayerTableRecord"/></param>
        /// <returns></returns>
        public static XElement SetLayerXml(LayerTableRecord layerTableRecord)
        {
            if (layerTableRecord == null)
            {
                return(new XElement("LayerTableRecord"));
            }

            using (AcadUtils.Document.LockDocument())
            {
                var layerTableRecordXml = new XElement("LayerTableRecord");
                layerTableRecordXml.SetAttributeValue("Name", layerTableRecord.Name);                                            // string
                layerTableRecordXml.SetAttributeValue("IsFrozen", layerTableRecord.IsFrozen);                                    // bool
                layerTableRecordXml.SetAttributeValue("IsHidden", layerTableRecord.IsHidden);                                    // bool
                layerTableRecordXml.SetAttributeValue("Description", layerTableRecord.Description);                              // string
                layerTableRecordXml.SetAttributeValue("IsLocked", layerTableRecord.IsLocked);                                    // bool
                layerTableRecordXml.SetAttributeValue("IsOff", layerTableRecord.IsOff);                                          // bool
                layerTableRecordXml.SetAttributeValue("IsPlottable", layerTableRecord.IsPlottable);                              // bool
                layerTableRecordXml.SetAttributeValue("Color", layerTableRecord.Color.ColorIndex);                               // color
                layerTableRecordXml.SetAttributeValue("Linetype", AcadUtils.GetLineTypeName(layerTableRecord.LinetypeObjectId)); // ObjectId
                layerTableRecordXml.SetAttributeValue("LineWeight", layerTableRecord.LineWeight);                                // LineWeight
                layerTableRecordXml.SetAttributeValue("ViewportVisibilityDefault", layerTableRecord.ViewportVisibilityDefault);  // bool

                return(layerTableRecordXml);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Установка свойств для однострочного текста
 /// </summary>
 /// <param name="dbText">Однострочный текст</param>
 /// <param name="textStyle">имя текстового стиля</param>
 /// <param name="height">Высота текста (с учетом масштаба блока)</param>
 public static void SetProperties(this DBText dbText, string textStyle, double height)
 {
     dbText.Height      = height;
     dbText.Color       = Color.FromColorIndex(ColorMethod.ByBlock, 0);
     dbText.Linetype    = "ByBlock";
     dbText.LineWeight  = LineWeight.ByBlock;
     dbText.TextStyleId = AcadUtils.GetTextStyleIdByName(textStyle);
 }
Esempio n. 4
0
        // get layers from xml
        private static LayerTableRecord GetLayerFromXml(XElement layerXElement)
        {
            var layerTblR = new LayerTableRecord();
            var nameAttr  = layerXElement?.Attribute("Name");

            // string
            if (nameAttr != null)
            {
                layerTblR.Name        = nameAttr.Value;
                layerTblR.Description = layerXElement.Attribute("Description")?.Value;

                // bool
                layerTblR.IsFrozen    = bool.TryParse(layerXElement.Attribute("IsFrozen")?.Value, out var b) && b;
                layerTblR.IsHidden    = bool.TryParse(layerXElement.Attribute("IsHidden")?.Value, out b) && b;
                layerTblR.IsLocked    = bool.TryParse(layerXElement.Attribute("IsLocked")?.Value, out b) && b;
                layerTblR.IsOff       = bool.TryParse(layerXElement.Attribute("IsOff")?.Value, out b) && b;
                layerTblR.IsPlottable = bool.TryParse(layerXElement.Attribute("IsPlottable")?.Value, out b) && b;
                layerTblR.ViewportVisibilityDefault =
                    bool.TryParse(layerXElement.Attribute("ViewportVisibilityDefault")?.Value, out b) && b;

                // color
                layerTblR.Color = Color.FromColorIndex(
                    ColorMethod.ByAci,
                    short.TryParse(layerXElement.Attribute("Color")?.Value, out var sh) ? sh : short.Parse("7"));

                // linetype
                layerTblR.LinetypeObjectId = AcadUtils.GetLineTypeObjectId(layerXElement.Attribute("Linetype")?.Value);

                // LineWeight
                layerTblR.LineWeight = Enum.TryParse(layerXElement.Attribute("LineWeight")?.Value, out LineWeight lw) ? lw : LineWeight.ByLineWeightDefault;

                return(layerTblR);
            }

            return(null);
        }