Beispiel #1
0
        getPntLabelStyle(string name)
        {
            switch (name)
            {
            case "BOT":
                name = "BOT";
                break;

            case "CP":
                name = "CP";
                break;

            case "CPNT-JOIN":
            case "CPNT-MISC":
            case "CPNT-ON":
            case "CPNT-ST":
            case "CPNT-TRANS":
                name = "CPNT";
                break;

            case "SPNT":
                name = "SPNT";
                break;

            case "UTL-MISC":
            case "UTL-SD":
            case "UTL-SEW":
            case "UTL-WAT":
                name = "UTL";
                break;

            case "EXIST":
                name = "EXIST";
                break;
            }
            LabelStyle ls = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    Layer.manageLayers(name);
                    Layer.manageLayers(string.Format("{0}-LABEL", name));
                    if (name == "SPNT")
                    {
                        Layer.manageLayer(string.Format("{0}-LABEL", name), layerOff: false, layerFrozen: false);
                    }
                    else
                    {
                        Layer.manageLayer(string.Format("{0}-LABEL", name), layerOff: false, layerFrozen: true);
                    }

                    LabelStyleCollection labelStyles = BaseObjs._civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles;
                    if (labelStyles.Contains(name))
                    {
                        ls = (LabelStyle)tr.GetObject(labelStyles[name], OpenMode.ForRead);
                        if (!ls.Properties.Label.Layer.Value.Contains("-LABEL"))
                        {
                            ls.UpgradeOpen();
                            ls.Properties.Label.Layer.Value = string.Format("{0}-LABEL", name);
                        }
                    }
                    else
                    {
                        TextStyleTableRecord tstr = Txt.getTextStyleTableRecord("L100");
                        if (tstr == null)
                        {
                            tstr = Txt.addTextStyleTableRecord("L100");
                        }
                        else
                        {
                            tstr.UpgradeOpen();
                            tstr.FileName = "ROMANS";
                            tstr.XScale   = 0.8;
                        }

                        CivilDocument civDoc = BaseObjs._civDoc;
                        ObjectId      id     = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles.Add(name);
                        ls = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite);
                        ls.Properties.DraggedStateComponents.DisplayType.Value = Autodesk.Civil.LabelContentDisplayType.StackedText;
                        ls.Properties.Label.Layer.Value = string.Format("{0}-LABEL", name);

                        removeAllComponents(id);

                        addLocationZcomponent(ls);
                        addDescriptionComponent(ls);
                        addPointNumberComponent(ls);
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 172", ex.Message));
            }
            return(ls.ObjectId);
        }