LabelStyleTextComponent not updated in the UI

LabelStyleTextComponent not updated in the UI

soonhui
Advisor Advisor
252 Views
3 Replies
Message 1 of 4

LabelStyleTextComponent not updated in the UI

soonhui
Advisor
Advisor

I'm pretty sure this is a bug in Civil 3D: I found that when I update the content value in LabelStyleTextComponent , the UI is not immediately updated as it should.

 

You can use the attached drawing, and the following code to test.

 

    [CommandMethod(nameof(ProfileBandStyleReadOnly))]
    public static void ProfileBandStyleReadOnly()
    {
        Document aDoc = Application.DocumentManager.MdiActiveDocument;
        Editor ed = aDoc.Editor;
        Database db = aDoc.Database;

        using var tr = db.TransactionManager.StartTransaction();
        
        var profileDataId = CivilApplication.ActiveDocument.Styles.BandStyles.ProfileViewProfileDataBandStyles["Vertical Elevations and Stations"];
        var profileData = tr.GetObject(profileDataId, OpenMode.ForWrite) as ProfileDataBandStyle;
        var titleText = tr.GetObject(profileData.TitleTextLabelStyleId, OpenMode.ForWrite) as LabelStyle;
        var allComponents = titleText.GetComponents(LabelStyleComponentType.Text);
        
        var res = tr.GetObject(allComponents[0], OpenMode.ForWrite) as LabelStyleTextComponent;

        var theText = res.Text;

        var theHeight = theText.Height;
        var theContent = theText.Contents;
        theContent.Value = @"station\PABC (m) \PDEC";
       
        tr.Commit();


    }

 

To update it, you will have to click Apply on the Label Style Composer, as shown below, then it will be automatically updated.

 

applythenapply.png

 

 

Note, similar cases:

 

  1. https://forums.autodesk.com/t5/civil-3d-customization-forum/some-contentstringformatted-doesn-t-upda...
  2. https://forums.autodesk.com/t5/civil-3d-customization-forum/edit-the-text-component-editor-value-via...

 

 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Accepted solutions (1)
253 Views
3 Replies
Replies (3)
Message 2 of 4

michal_hcz
Enthusiast
Enthusiast
Accepted solution

hi,

Autodesk.AutoCAD.Internal.Utils.FlushGraphics(); did not help but ed.Regen(); works fine. Not the best solution but at least somenting 🙂

 

M.

Message 3 of 4

soonhui
Advisor
Advisor

@michal_hcz , are you sure that you can reproduce the problem?

 

Because just now I ran the code as it is, suddenly the problem is no longer reproducible. 

 

Similar problems in other linked post are, however, still reproducible. 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 4 of 4

michal_hcz
Enthusiast
Enthusiast

Yes, the prohlem is still here.
Latest C3D 2026, your DWG.

After your command:

michal_hcz_0-1770196248057.png


After ec.Regen():

michal_hcz_1-1770196278617.png

 

 

M.

0 Likes