示例#1
0
        getProfileLabelSetStyles()
        {
            List <string> s       = new List <string>();
            ObjectId      idStyle = ObjectId.Null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    ProfileLabelSetStyleCollection styles = BaseObjs._civDoc.Styles.LabelSetStyles.ProfileLabelSetStyles;
                    foreach (ObjectId id in styles)
                    {
                        ProfileLabelSetStyle style = (ProfileLabelSetStyle)tr.GetObject(id, OpenMode.ForRead);
                        s.Add(style.Name);
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 230", ex.Message));
            }
            return(s);
        }
示例#2
0
        CreateProfileLabelSetStyle(string name)
        {
            CivilDocument        civDoc = CivilApplication.ActiveDocument;
            ObjectIdCollection   ids    = null;
            ObjectId             id     = ObjectId.Null;
            ProfileLabelSetStyle oProfileLabelSetStyle = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    ObjectIdCollection idStyles = new ObjectIdCollection();

                    id = civDoc.Styles.LabelSetStyles.ProfileLabelSetStyles.Add(name);
                    oProfileLabelSetStyle = (ProfileLabelSetStyle)tr.GetObject(id, OpenMode.ForWrite);

                    try
                    {
                        ObjectId idGradeBreakLabelStyle = civDoc.Styles.LabelStyles.ProfileLabelStyles.GradeBreakLabelStyles.Add(name);
                        idStyles.Add(idGradeBreakLabelStyle);
                        LabelStyle oGradeBreakLabelStyle = (LabelStyle)tr.GetObject(idGradeBreakLabelStyle, OpenMode.ForWrite);

                        ids = oGradeBreakLabelStyle.GetComponents(LabelStyleComponentType.Line);
                        if (ids.Count != 0)
                        {
                            foreach (ObjectId idLS in ids)
                            {
                                var lc = (LabelStyleLineComponent)tr.GetObject(idLS, OpenMode.ForWrite);
                                lc.General.Visible.Value = false;
                            }
                        }
                        else
                        {
                            id = oGradeBreakLabelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                            var lc = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                            lc.General.Visible.Value = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 45", ex.Message));
                    }

                    try
                    {
                        ObjectId idCurveLabelStyle = civDoc.Styles.LabelStyles.ProfileLabelStyles.CurveLabelStyles.Add(name);
                        //idStyles.Add(idCurveLabelStyle);
                        LabelStyle oCurveLabelStyle = (LabelStyle)tr.GetObject(idCurveLabelStyle, OpenMode.ForWrite);

                        ids = oCurveLabelStyle.GetComponents(LabelStyleComponentType.Line);
                        if (ids.Count != 0)
                        {
                            foreach (ObjectId idLS in ids)
                            {
                                var lc = (LabelStyleLineComponent)tr.GetObject(idLS, OpenMode.ForWrite);
                                lc.General.Visible.Value = false;
                            }
                        }
                        else
                        {
                            id = oCurveLabelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                            var lc = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                            lc.General.Visible.Value = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 66", ex.Message));
                    }

                    try
                    {
                        ObjectId idHorizontalGeometryPointLabelStyle = civDoc.Styles.LabelStyles.ProfileLabelStyles.HorizontalGeometryPointLabelStyles.Add(name);
                        idStyles.Add(idHorizontalGeometryPointLabelStyle);
                        LabelStyle oHorizontalGeometryPointLabelStyle = (LabelStyle)tr.GetObject(idHorizontalGeometryPointLabelStyle, OpenMode.ForWrite);
                        ids = oHorizontalGeometryPointLabelStyle.GetComponents(LabelStyleComponentType.Line);
                        if (ids.Count != 0)
                        {
                            foreach (ObjectId idLS in ids)
                            {
                                var lc = (LabelStyleLineComponent)tr.GetObject(idLS, OpenMode.ForWrite);
                                lc.General.Visible.Value = false;
                            }
                        }
                        else
                        {
                            id = oHorizontalGeometryPointLabelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                            var lc = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                            lc.General.Visible.Value = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 86", ex.Message));
                    }

                    try
                    {
                        ObjectId idLineLabelStyle = civDoc.Styles.LabelStyles.ProfileLabelStyles.LineLabelStyles.Add(name);
                        idStyles.Add(idLineLabelStyle);
                        LabelStyle oLineLabelStyle = (LabelStyle)tr.GetObject(idLineLabelStyle, OpenMode.ForWrite);
                        ids = oLineLabelStyle.GetComponents(LabelStyleComponentType.Line);
                        if (ids.Count != 0)
                        {
                            foreach (ObjectId idLS in ids)
                            {
                                var lc = (LabelStyleLineComponent)tr.GetObject(idLS, OpenMode.ForWrite);
                                lc.General.Visible.Value = false;
                            }
                        }
                        else
                        {
                            id = oLineLabelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                            var lc = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                            lc.General.Visible.Value = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 106", ex.Message));
                    }

                    try
                    {
                        ObjectId idMinorStationLabelStyle = civDoc.Styles.LabelStyles.ProfileLabelStyles.MinorStationLabelStyles.Add(name);
                        //idStyles.Add(idMinorStationLabelStyle);
                        LabelStyle oMinorStationLabelStyle = (LabelStyle)tr.GetObject(idMinorStationLabelStyle, OpenMode.ForWrite);
                        ids = oMinorStationLabelStyle.GetComponents(LabelStyleComponentType.Line);
                        if (ids.Count != 0)
                        {
                            foreach (ObjectId idLS in ids)
                            {
                                var lc = (LabelStyleLineComponent)tr.GetObject(idLS, OpenMode.ForWrite);
                                lc.General.Visible.Value = false;
                            }
                        }
                        else
                        {
                            id = oMinorStationLabelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                            var lc = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                            lc.General.Visible.Value = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 126", ex.Message));
                    }

                    try
                    {
                        ObjectId idMajorStationLabelStyle = civDoc.Styles.LabelStyles.ProfileLabelStyles.MajorStationLabelStyles.Add(name);
                        idStyles.Add(idMajorStationLabelStyle);
                        LabelStyle oMajorStationLabelStyle = (LabelStyle)tr.GetObject(idMajorStationLabelStyle, OpenMode.ForWrite);
                        ids = oMajorStationLabelStyle.GetComponents(LabelStyleComponentType.Line);
                        if (ids.Count != 0)
                        {
                            foreach (ObjectId idLS in ids)
                            {
                                var lc = (LabelStyleLineComponent)tr.GetObject(idLS, OpenMode.ForWrite);
                                lc.General.Visible.Value = false;
                            }
                        }
                        else
                        {
                            id = oMajorStationLabelStyle.AddComponent("Line", LabelStyleComponentType.Line);
                            var lc = (LabelStyleLineComponent)tr.GetObject(id, OpenMode.ForWrite);
                            lc.General.Visible.Value = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 146", ex.Message));
                    }

                    foreach (ObjectId idStyle in idStyles)
                    {
                        oProfileLabelSetStyle.Add(idStyle);
                    }

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Prof_Style.cs: line: 156", ex.Message));
            }
            return(oProfileLabelSetStyle.ObjectId);
        }