Exemplo n.º 1
0
        getPntLabelStyle(string name)
        {
            LabelStyle LS = null;
            ObjectId   id = ObjectId.Null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    LabelStyleCollection labelStyles = BaseObjs._civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles;
                    if (labelStyles.Contains(name))
                    {
                        LS = (LabelStyle)tr.GetObject(labelStyles[name], OpenMode.ForRead);
                        return(LS.ObjectId);
                    }
                    else
                    {
                        Base_Tools45.Layer.manageLayers(name);

                        TextStyleTableRecord TStr = Base_Tools45.Txt.getTextStyleTableRecord("L100");
                        if (TStr == null)
                        {
                            TStr = Base_Tools45.Txt.addTextStyleTableRecord("L100");
                        }

                        TStr.FileName = "ROMANS";
                        TStr.XScale   = 0.8;

                        CivilDocument civDoc = CivilApplication.ActiveDocument;

                        id = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles.Add(name);

                        LS = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite);

                        LS.AddComponent("PointNumber", LabelStyleComponentType.Text);
                        ObjectIdCollection      ids   = LS.GetComponents(LabelStyleComponentType.Text);
                        LabelStyleTextComponent lstc1 = (LabelStyleTextComponent)tr.GetObject(ids[0], OpenMode.ForWrite);
                        lstc1.General.Visible.Value = true;

                        LS.Properties.DraggedStateComponents.DisplayType.Value = Autodesk.Civil.LabelContentDisplayType.StackedText;

                        tr.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Pnts.cs: line: 133", ex.Message));
            }
            return(id);
        }
Exemplo n.º 2
0
        upgradePntLabelStyle(string nameLabelStyle, string nameFontFile = "Romans.shx", double xscale = 0.8)
        {
            LabelStyle ls = null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    LabelStyleCollection labelStyles = BaseObjs._civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles;
                    if (labelStyles.Contains(nameLabelStyle))
                    {
                        labelStyles.Remove(nameLabelStyle);
                    }

                    //Layer.manageLayers(name);

                    TextStyleTableRecord TStr = Txt.getTextStyleTableRecord("L100");
                    if (TStr == null)
                    {
                        TStr = Txt.addTextStyleTableRecord("L100");
                    }

                    TStr.FileName = nameFontFile;
                    TStr.XScale   = xscale;

                    CivilDocument civDoc = BaseObjs._civDoc;

                    ObjectId id = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles.Add(nameLabelStyle);

                    ls = (LabelStyle)tr.GetObject(id, OpenMode.ForWrite);
                    ls.Properties.DraggedStateComponents.DisplayType.Value = Autodesk.Civil.LabelContentDisplayType.StackedText;

                    addLocationZcomponent(ls);
                    addPointNumberComponent(ls);
                    addDescriptionComponent(ls);

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Pnt_Style.cs: line: 254", ex.Message));
            }
            return(ls.ObjectId);
        }
Exemplo n.º 3
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);
        }