<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Label Depth to Invert in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11851672#M3885</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12329146"&gt;@sneha.sadaphal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code that&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;posted works as intended. Are you able to post your drawing or an example drawing with the style in it? It seems to me that the issue is either in the data or in the style because the code inserts the band style onto the profile view as expected and it is visible when the command ends.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2023 19:44:00 GMT</pubDate>
    <dc:creator>hippe013</dc:creator>
    <dc:date>2023-03-27T19:44:00Z</dc:date>
    <item>
      <title>Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11842114#M3877</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am creating depth to invert band by selecting the profile&amp;nbsp;&lt;/P&gt;&lt;P&gt;but when I run the command first time then the label is not getting created. but running it second time then it is getting creating.&lt;BR /&gt;don't have any idea why this is happening.&lt;/P&gt;&lt;P&gt;here is image for depth to invert band label which is placed after executing the command second time.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snehasadaphal_0-1679575540177.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1192478i333AD769FE6AC92D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snehasadaphal_0-1679575540177.png" alt="snehasadaphal_0-1679575540177.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;here is code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="snehasadaphal_1-1679575576152.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1192479iCCD69452FA72E82B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snehasadaphal_1-1679575576152.png" alt="snehasadaphal_1-1679575576152.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is any one having the solution for this?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 12:47:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11842114#M3877</guid>
      <dc:creator>sneha.sadaphal</dc:creator>
      <dc:date>2023-03-23T12:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11842397#M3878</link>
      <description>More code is needed, preferably as actual code not a screenshot. Something that can easily be run &amp;amp; tested is best.</description>
      <pubDate>Thu, 23 Mar 2023 14:18:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11842397#M3878</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2023-03-23T14:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11843760#M3879</link>
      <description>&lt;P&gt;Try&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;editor.Regen();&lt;/LI-CODE&gt;&lt;P&gt;and see if it works.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 00:03:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11843760#M3879</guid>
      <dc:creator>varshaauti27</dc:creator>
      <dc:date>2023-03-24T00:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11844171#M3880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;Please find attached detail code for inserting depth to invert band&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 06:12:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11844171#M3880</guid>
      <dc:creator>sneha.sadaphal</dc:creator>
      <dc:date>2023-03-24T06:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11844189#M3881</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10367768"&gt;@varshaauti27&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class=""&gt;I tried with editor.regen(). but it is still showing empty band.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 06:32:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11844189#M3881</guid>
      <dc:creator>sneha.sadaphal</dc:creator>
      <dc:date>2023-03-24T06:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11845481#M3882</link>
      <description>&lt;P&gt;In my experience, sometimes ed.Regen() does not work as expected where using sendStringToExecute does work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;aDoc.SendStringToExecute("REGEN ", True, False, False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(vb.net)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, that this should be placed AFTER you commit your transaction.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 16:00:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11845481#M3882</guid>
      <dc:creator>hippe013</dc:creator>
      <dc:date>2023-03-24T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11845677#M3883</link>
      <description>&lt;P&gt;Thanks for the code&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12329146"&gt;@sneha.sadaphal&lt;/a&gt;&amp;nbsp;It still needed some additional code to run so I moved things around to how I would do it. I agree with&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1633394"&gt;@hippe013&lt;/a&gt;&amp;nbsp;that a regen needs to be done after the transaction is committed. However, rather than calling for a full editor regen, I use the internal RegenEntity method. Here is my updated code which functions as expected.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;        [CommandMethod("InsertDepthToInvertBand")]
        public static void InsertDTIInvertBand()
        {
            CivilDocument civDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            ProfileView profileView = null;
            #region For Inserting Band
            //Insert bandstyle with chainage values by comparing created profile and existing profile
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    var entOpts = new PromptEntityOptions("\nSelect ProfileView:");
                    entOpts.SetRejectMessage("..not a ProfileView, try again.");
                    entOpts.AddAllowedClass(typeof(ProfileView), true);
                    var entRes = ed.GetEntity(entOpts);
                    if (entRes.Status != PromptStatus.OK) return;
                    var pvId = entRes.ObjectId;
                    profileView = (ProfileView)pvId.GetObject(OpenMode.ForWrite);
                    var collection = profileView.Bands.GetBottomBandItems();
                    BandStyleCollection bandStyleCollection = civDoc.Styles.BandStyles.ProfileViewProfileDataBandStyles;
                    if (!bandStyleCollection.Contains("Depth To Invert"))
                        return;
                    var bandStyle = (BandStyle)bandStyleCollection["Depth To Invert"].GetObject(OpenMode.ForRead);
  
                    entOpts.Message = "\nSelect Surface Profile:";
                    entOpts.SetRejectMessage("..not a Profile, try again.");
                    entOpts.AddAllowedClass(typeof(Profile), true);
                    entRes = ed.GetEntity(entOpts);
                    if (entRes.Status != PromptStatus.OK) return;
                    var prof1id = entRes.ObjectId;
                    var prof1 = (Profile) prof1id.GetObject(OpenMode.ForRead);
                    
                    entOpts.Message = "\nSelect Created Profile:";
                    entRes = ed.GetEntity(entOpts);
                    if (entRes.Status != PromptStatus.OK) return;
                    var prof2id = entRes.ObjectId;

                    double startstation = prof1.StartingStation;
                    double endstation = prof1.EndingStation;

                    collection.Add(bandStyle.Id);
                    collection.Last().Gap = 0.0;
                    collection.Last().ShowLabels = true;
                    collection.Last().MajorInterval = 100;
                    collection.Last().MinorInterval = 10;

                    //Thread.Sleep(2000);
                    collection.Last().Profile1Id = prof1id;
                    collection.Last().Profile2Id = prof2id;
                    profileView.Bands.SetBottomBandItems(collection);
                    tr.Commit();
                    Autodesk.AutoCAD.Internal.Utils.RegenEntity(pvId);
                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
            }
            #endregion
        }
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 17:41:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11845677#M3883</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2023-03-24T17:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11850018#M3884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;I tried using your code but still it is placing empty band.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 09:58:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11850018#M3884</guid>
      <dc:creator>sneha.sadaphal</dc:creator>
      <dc:date>2023-03-27T09:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11851672#M3885</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12329146"&gt;@sneha.sadaphal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code that&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;posted works as intended. Are you able to post your drawing or an example drawing with the style in it? It seems to me that the issue is either in the data or in the style because the code inserts the band style onto the profile view as expected and it is visible when the command ends.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 19:44:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11851672#M3885</guid>
      <dc:creator>hippe013</dc:creator>
      <dc:date>2023-03-27T19:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11852444#M3886</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1633394"&gt;@hippe013&lt;/a&gt;&amp;nbsp;Please see attached latest code and drawing.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 05:51:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11852444#M3886</guid>
      <dc:creator>sneha.sadaphal</dc:creator>
      <dc:date>2023-03-28T05:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11853587#M3887</link>
      <description>&lt;P&gt;It does not appear that your drawing has a band style that is called 'Depth To Invert'. So what happens in your code when the drawing does not contain the style 'Depth To Invert'? Nothing. Nothing happens. The user is not given any feedback. I would suggest implementing a function along the lines of GetOrCreateDepthToInvertStyle or at the very least provide the user with some feedback if the style does not exist.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also suggest that you look into PromptEntityOptions. That way you can get rid of your while loops and if statements for when you select an entity. See example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;(vb.net)&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim opt As New PromptEntityOptions(vbCrLf &amp;amp; "Select Profile View:")
opt.SetRejectMessage(vbCrLf &amp;amp; "Selected entity must be a ProfileView. Try again.")
opt.AddAllowedClass(GetType(ProfileView), True)

Dim result As PromptEntityResult = ed.GetEntity(opt)

If result.Status &amp;lt;&amp;gt; PromptStatus.OK Then Exit Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way the object selected is guaranteed to be of the type that you specify in AddAllowedClass.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my opinion your code needs to be refactored. You are opening objects for write when you are only reading it. It appears that you are creating additional profiles when you code is supposed to be just simply adding a band to a profile view. I suggest rewriting your code and only perform the action that you originally intended. It is difficult f&lt;SPAN&gt;or those trying to help as it is like trying to hit a moving target.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 13:52:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11853587#M3887</guid>
      <dc:creator>hippe013</dc:creator>
      <dc:date>2023-03-28T13:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Label Depth to Invert</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11854020#M3888</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1633394"&gt;@hippe013&lt;/a&gt;&amp;nbsp;for your suggestions. I will try to rewrite my code accordingly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 16:33:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/label-depth-to-invert/m-p/11854020#M3888</guid>
      <dc:creator>sneha.sadaphal</dc:creator>
      <dc:date>2023-03-28T16:33:12Z</dc:date>
    </item>
  </channel>
</rss>

