Changing Section View Group Label styles

Changing Section View Group Label styles

odoshi
Collaborator Collaborator
338 Views
2 Replies
Message 1 of 3

Changing Section View Group Label styles

odoshi
Collaborator
Collaborator

Looking for a way in to change labels assigned to a section - similar to this part of the Civil 3D UI.

 

section_label_set.png

 

Is there a way in through the API?

 

Thanks,

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
0 Likes
Accepted solutions (1)
339 Views
2 Replies
Replies (2)
Message 2 of 3

essam-salah
Collaborator
Collaborator
Accepted solution

Hi @odoshi 

check this:

Autodesk.AutoCAD.EditorInput.Editor editor => Application.DocumentManager.MdiActiveDocument.Editor;

        [CommandMethod("cie_SetSectionViewGroupLabelSet")]
        public void GetCogoFromBlocks()
        {
            #region curr doc
            var adoc = Application.DocumentManager.MdiActiveDocument;
            var db = adoc.Database;
            var cdoc = cApp.CivilApplication.ActiveDocument;
            #endregion

            // select section view
            var psr = editor.GetSelection(new SelectionFilter(new[] { new TypedValue(0, "AECC_GRAPH_SECTION_VIEW") }));
            if (psr.Status != PromptStatus.OK)
            {
                editor.WriteMessage($"\n---------- No Section View Found ------------------");
                return;
            }

            using (var tr = db.TransactionManager.StartTransaction())
            {
                // open selected sec view
                var secView = (SectionView)psr.Value.GetObjectIds()[0].GetObject(OpenMode.ForRead);
                // get sec view grouop
                SectionViewGroup secViewGroup = secView.GetSectionViewGroup();
                // get section source to set label for
                var sampleLineGroup = (SampleLineGroup)secViewGroup.SampleLineGroupId.GetObject(OpenMode.ForRead);
                var secSources = sampleLineGroup.GetSectionSources();
                var reqSecSource = secSources.Where(s => s.SourceName.Equals("NGL")).First(); // change NGL according to your file

                // apply section view group label
                var labelSetStyleId = cdoc.Styles.LabelSetStyles.SectionLabelSetStyles["Standard_2"]; // change Standard_2 according to your file
                secViewGroup.ImportLabelSetForSectionsInGroup(reqSecSource, labelSetStyleId);

                tr.Commit();
            }
        }

 

sec view label set.png

0 Likes
Message 3 of 3

odoshi
Collaborator
Collaborator

Yea! This is what I needed:

 

secViewGroup.ImportLabelSetForSectionsInGroup(reqSecSource, labelSetStyleId);

Thanks,

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
0 Likes