コード例 #1
0
ファイル: Pnt_Style.cs プロジェクト: 15831944/EM
        addLeaderComponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("LDR", LabelStyleComponentType.Line);
            LabelStyleLineComponent lineComp = (LabelStyleLineComponent)id.GetObject(OpenMode.ForWrite);

            lineComp.General.StartAnchorPoint.Value = AnchorPointType.MiddleCenter;
        }
コード例 #2
0
        private void addLeaderComponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("Leader",
                                             LabelStyleComponentType.Line);
            LabelStyleLineComponent component = id.GetObject(OpenMode.ForWrite)
                                                as LabelStyleLineComponent;

            component.General.StartAnchorPoint.Value = AnchorPointType.MiddleCenter;
        }
コード例 #3
0
ファイル: Pnt_Style.cs プロジェクト: 15831944/EM
        addPointNumberComponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("PN", LabelStyleComponentType.Text);
            LabelStyleTextComponent textComp = (LabelStyleTextComponent)id.GetObject(OpenMode.ForWrite);

            textComp.Text.Attachment.Value         = LabelTextAttachmentType.BottomLeft;
            textComp.Text.Contents.Value           = _pointNumber;
            textComp.General.AnchorComponent.Value = "Z";
            textComp.General.AnchorLocation.Value  = AnchorPointType.TopLeft;
        }
コード例 #4
0
ファイル: Pnt_Style.cs プロジェクト: 15831944/EM
        addLocationZcomponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("Z", LabelStyleComponentType.Text);
            LabelStyleTextComponent textComp = (LabelStyleTextComponent)id.GetObject(OpenMode.ForWrite);

            textComp.Text.Attachment.Value = LabelTextAttachmentType.MiddleLeft;
            textComp.Text.Contents.Value   = _elevation;
            //textComp.General.AnchorComponent.Value =                              ******defaults to <Feature> when value is unassigned*************
            textComp.General.AnchorLocation.Value = AnchorPointType.MiddleRight;
        }
コード例 #5
0
        private void addPointNumberComponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("PN", LabelStyleComponentType.Text);
            LabelStyleTextComponent component = id.GetObject(OpenMode.ForWrite)
                                                as LabelStyleTextComponent;

            component.Text.Attachment.Value = LabelTextAttachmentType.MiddleLeft;
            //component.Text.Contents.Value = _pointNumber;
            component.General.AnchorComponent.Value = "Leader";
            component.General.AnchorLocation.Value  = AnchorPointType.End;
        }
コード例 #6
0
ファイル: Pnt_Style.cs プロジェクト: 15831944/EM
        addLocationXYcomponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("XY", LabelStyleComponentType.Text);
            LabelStyleTextComponent textComp = (LabelStyleTextComponent)id.GetObject(OpenMode.ForWrite);

            textComp.Text.Attachment.Value = LabelTextAttachmentType.TopLeft;
            string value = string.Format("(X={0}, Y={1}, Z={2})", _easting, _northing, _elevation);

            textComp.Text.Contents.Value           = value;
            textComp.General.AnchorComponent.Value = "DESC";
            textComp.General.AnchorLocation.Value  = AnchorPointType.BottomLeft;
        }
コード例 #7
0
        private void addLocationComponent(LabelStyle style)
        {
            ObjectId id = style.AddComponent("Location",
                                             LabelStyleComponentType.Text);
            LabelStyleTextComponent component = id.GetObject(OpenMode.ForWrite)
                                                as LabelStyleTextComponent;

            component.Text.Attachment.Value = LabelTextAttachmentType.TopLeft;
            //string value = String.Format("({0}, {1}, {2})", _northing, _easting, _elevation);
            //component.Text.Contents.Value = value;
            component.General.AnchorComponent.Value = "PN";
            component.General.AnchorLocation.Value  = AnchorPointType.BottomLeft;
        }
コード例 #8
0
ファイル: CgPnts.cs プロジェクト: 15831944/EM
        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);
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: Align_Style.cs プロジェクト: 15831944/EM
        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);
        }