Beispiel #1
0
        private void removeComponents(ObjectId styleId, IEnumerable <string> componentNames)
        {
            using (Transaction tr = Active.Database.TransactionManager.StartTransaction())
            {
                LabelStyle style = styleId.GetObject(OpenMode.ForWrite)
                                   as LabelStyle;
                foreach (string name in componentNames)
                {
                    style.RemoveComponent(name);
                }

                tr.Commit();
            }
        }
Beispiel #2
0
 removeComponents(ObjectId idStyle, IEnumerable <string> nameComponents)
 {
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             LabelStyle style = (LabelStyle)idStyle.GetObject(OpenMode.ForWrite);
             foreach (string name in nameComponents)
             {
                 style.RemoveComponent(name);
             }
             tr.Commit();
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 368", ex.Message));
     }
 }
Beispiel #3
0
        createAlignLabelSetStyle(string name)
        {
            AlignmentLabelSetStyle alignLabelSetStyle = null;
            ObjectId idStyle = ObjectId.Null;
            ObjectId idItem  = ObjectId.Null;

            try
            {
                idStyle = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles[name];
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 112", ex.Message));
            }
            if (idStyle == ObjectId.Null)
            {
                idStyle = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles.Add(name);
            }

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    alignLabelSetStyle             = (AlignmentLabelSetStyle)tr.GetObject(idStyle, OpenMode.ForWrite);
                    alignLabelSetStyle.Description = "Program Generated";

                    idItem = BaseObjs._civDoc.Styles.LabelStyles.AlignmentLabelStyles.MajorStationLabelStyles.Add("Parallel with line Tick");
                    LabelStyle labelStyle = (LabelStyle)tr.GetObject(idItem, OpenMode.ForWrite);
                    try
                    {
                        labelStyle.RemoveComponent("New Tick");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 129", ex.Message));
                    }

                    try
                    {
                        ObjectId id = labelStyle.AddComponent("Tick", LabelStyleComponentType.Tick);
                        LabelStyleTickComponent cmpnnt = (LabelStyleTickComponent)tr.GetObject(id, OpenMode.ForWrite);
                        cmpnnt.Tick.Lineweight.Value      = LineWeight.LineWeight060;
                        cmpnnt.Tick.AlignWithObject.Value = true;
                        cmpnnt.Tick.RotationAngle.Value   = 0.0;
                        cmpnnt.General.Visible.Value      = true;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 141", ex.Message));
                    }
                    try
                    {
                        labelStyle.RemoveComponent("New Block");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 147", ex.Message));
                    }

                    try
                    {
                        labelStyle.RemoveComponent("New Line");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 154", ex.Message));
                    }

                    try
                    {
                        ObjectId id = labelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                        LabelStyleLineComponent cmpnnt = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                        cmpnnt.Line.Color.Value             = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 127, 0);
                        cmpnnt.Line.Angle.Value             = 2.094;
                        cmpnnt.Line.StartPointXOffset.Value = 0.005;
                        cmpnnt.Line.StartPointYOffset.Value = -0.005;
                        cmpnnt.General.Visible.Value        = true;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 167", ex.Message));
                    }

                    try
                    {
                        labelStyle.RemoveComponent("New Text");
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 174", ex.Message));
                    }

                    try
                    {
                        ObjectId id = labelStyle.AddComponent("Text", LabelStyleComponentType.Text);
                        LabelStyleTextComponent cmpnnt = (LabelStyleTextComponent)tr.GetObject(id, OpenMode.ForWrite);

                        cmpnnt.Text.XOffset.Value    = 60;
                        cmpnnt.Text.YOffset.Value    = -0.25 - cmpnnt.Text.Height.Value;
                        cmpnnt.Text.Color.Value      = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 255, 0);
                        cmpnnt.Text.Contents.Value   = "STA=<[Station Value(Uft|FS|P2|RN|AP|Sn|TP|B2|EN|W0|OF)]>";
                        cmpnnt.General.Visible.Value = true;
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 188", ex.Message));
                    }

                    alignLabelSetStyle.Add(labelStyle.ObjectId);

                    AlignmentLabelSetItem stationStyleMajor = alignLabelSetStyle[alignLabelSetStyle.Count - 1];
                    stationStyleMajor.Increment = 20;

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 200", ex.Message));
            }
            return(idStyle);
        }