Esempio n. 1
0
        getAlignmentLabelSetStyle(string name)
        {
            ObjectId idStyle = ObjectId.Null;
            AlignmentLabelSetStyleCollection styles = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    foreach (ObjectId id in styles)
                    {
                        AlignmentLabelSetStyle style = (AlignmentLabelSetStyle)tr.GetObject(id, OpenMode.ForRead);
                        if (style.Name == name)
                        {
                            idStyle = style.ObjectId;
                        }
                        break;
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 70", ex.Message));
            }
            return(idStyle);
        }
Esempio n. 2
0
        getAlignmentLabelSetStyles()
        {
            List <string> styleSets = new List <string>();
            AlignmentLabelSetStyleCollection styles = BaseObjs._civDoc.Styles.LabelSetStyles.AlignmentLabelSetStyles;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    foreach (ObjectId id in styles)
                    {
                        AlignmentLabelSetStyle style = (AlignmentLabelSetStyle)tr.GetObject(id, OpenMode.ForRead);
                        styleSets.Add(style.Name);
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Align_Style.cs: line: 70", ex.Message));
            }
            return(styleSets);
        }
Esempio n. 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);
        }