<?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: Dynamically add Entities to an Aligment in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307853#M12268</link>
    <description>This is a common omission when learning the AutoCAD (not just C3D) API. If you don't Commit, then the Transaction is Disposed/Aborted, thus acting like Undo inside your code. I can't recall how many times I did this when I first started, but it was more than just a few... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Thu, 17 Aug 2017 13:23:02 GMT</pubDate>
    <dc:creator>Jeff_M</dc:creator>
    <dc:date>2017-08-17T13:23:02Z</dc:date>
    <item>
      <title>Dynamically add Entities to an Aligment</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7306933#M12265</link>
      <description>&lt;P&gt;I am dynamically creating alignments in Civil 3D based on some self-defined objects. These objects contain all the information needed to create an alignment as well as the respective entities such as lines, arcs, and spirals.&lt;/P&gt;&lt;P&gt;In a first step I create my alignment (This alignment perfectly shows in Civil 3D):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var civilDatabase = Application.DocumentManager.MdiActiveDocument.Database;
var civilDocument = CivilApplication.ActiveDocument;

var civilAlignmentId = Alignment.Create("My Aligment (1)", "", "C-ROAD", "Proposed", "All Labels");&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I open the transaction manager and pass my priorly created alignment ID to get the actual alignment:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using (Transaction civilTransactionManager = civilDatabase.TransactionManager.StartTransaction())
{&lt;BR /&gt;   var civilAlignment = (Alignment)civilTransactionManager.GetObject(civilAlignmentId, OpenMode.ForWrite); &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following steps, I want to add the entities to the alignment. Because this did not work, I tried using the example from&amp;nbsp;&lt;A title="Defining an Alignment Path Using Entities" href="https://knowledge.autodesk.com/support/autocad-civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/Civil3D-DevGuide/files/GUID-EC4774B6-C7E9-453E-9382-2A3EE3B2A575-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/support/autocad-civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/Civil3D-DevGuide/files/GUID-EC4774B6-C7E9-453E-9382-2A3EE3B2A575-htm.html&lt;/A&gt; to just create one simple entity looking like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Int32 previousEntityId = &lt;SPAN&gt;0&lt;/SPAN&gt;;
Point3d startPoint = &lt;SPAN&gt;new&lt;/SPAN&gt; Point3d(&lt;SPAN&gt;8800.7906&lt;/SPAN&gt;, &lt;SPAN&gt;13098.1946&lt;/SPAN&gt;, &lt;SPAN&gt;0.0000&lt;/SPAN&gt;);
Point3d middlePoint = &lt;SPAN&gt;new&lt;/SPAN&gt; Point3d(&lt;SPAN&gt;8841.9624&lt;/SPAN&gt;, &lt;SPAN&gt;13108.6382&lt;/SPAN&gt;, &lt;SPAN&gt;0.0000&lt;/SPAN&gt;);
Point3d endPoint = &lt;SPAN&gt;new&lt;/SPAN&gt; Point3d(&lt;SPAN&gt;8874.2664&lt;/SPAN&gt;, &lt;SPAN&gt;13089.3333&lt;/SPAN&gt;, &lt;SPAN&gt;0.0000&lt;/SPAN&gt;);
AlignmentArc retVal = myAlignment.Entities.AddFixedCurve(previousEntityId, startPoint, middlePoint, endPoint);&lt;/PRE&gt;&lt;P&gt;However, this is when I am failing. The arc never shows in Civil 3D. I also tried the same with a line, but it does not show either. Am I missing a step here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Felix&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 06:49:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7306933#M12265</guid>
      <dc:creator>f.rampf</dc:creator>
      <dc:date>2017-08-17T06:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically add Entities to an Aligment</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307780#M12266</link>
      <description>Are you committing the transaction?</description>
      <pubDate>Thu, 17 Aug 2017 13:02:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307780#M12266</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2017-08-17T13:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically add Entities to an Aligment</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307825#M12267</link>
      <description>&lt;P&gt;I did not do that... After adding the following line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;civilTransactionManager.Commit();&lt;/PRE&gt;&lt;P&gt;Everything works fine and the Line shows in Civil 3D. Thank you very much, Jeff, you are my life saver! And please apologize for my lack of knowledge of the .net civil 3d API and this fairly obvious question resulting from that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felix&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:15:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307825#M12267</guid>
      <dc:creator>f.rampf</dc:creator>
      <dc:date>2017-08-17T13:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically add Entities to an Aligment</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307853#M12268</link>
      <description>This is a common omission when learning the AutoCAD (not just C3D) API. If you don't Commit, then the Transaction is Disposed/Aborted, thus acting like Undo inside your code. I can't recall how many times I did this when I first started, but it was more than just a few... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:23:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/dynamically-add-entities-to-an-aligment/m-p/7307853#M12268</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2017-08-17T13:23:02Z</dc:date>
    </item>
  </channel>
</rss>

