<?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: Do I have to append TIN Surface to the database? in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487251#M4820</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6591997"&gt;@hosneyalaa&lt;/a&gt;. I will end the transaction, but that still doesn't solve the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also btw, since the transaction is in using-statement, I don't think I necessarily need to close it but I'm not sure. It sounds like a good idea to commit the transaction manually.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 07:59:46 GMT</pubDate>
    <dc:creator>heyimsp12</dc:creator>
    <dc:date>2022-10-17T07:59:46Z</dc:date>
    <item>
      <title>Do I have to append TIN Surface to the database?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487127#M4818</link>
      <description>&lt;P&gt;I'm trying to create a TIN Surface in the below function and later I want to extrude it into a solid of depth 2 meters.&amp;nbsp;&lt;BR /&gt;While debugging the code, I have noticed that my code runs fine butt I still can't see new surfaces being created on C3D Document. Do I have to append the surface to the Model Space and then also add it to the transaction? If yes, i tried doing that as well but then I am getting error - Object already in database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; //Create TIN Surface and define its Breaklines and Boundaries.
        public ObjectId CreateTinSurface(Polyline2d boundary, bool ExtrudeSolid = false, double DepthOfSolid = 2.0)
        {
            var surfaceId = new ObjectId(); //Placeholder for surfaceId.
            
            using (var db = Application.DocumentManager.MdiActiveDocument.Database)
            using (var trans = db.TransactionManager.StartTransaction())
            using (var blockTable = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead))
            using (var modelSpace = (BlockTableRecord)trans.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead))
            {
                try
                {
                    //Create an empty TIN surface
                    surfaceId = TinSurface.Create(db, "TempVisSurface_"+boundary.BlockName.Trim().ToString());

                    //Open the TIN surface
                    TinSurface surface = (TinSurface)trans.GetObject(surfaceId, OpenMode.ForWrite);

                    //Surface Breaklines Definition
                    //BoundarySet will also serve as a BreaklinesSet here, since the surface is empty anyways.
                    ObjectIdCollection breaklineSet = new ObjectIdCollection();
                    breaklineSet.Add(boundary.ObjectId);
                    surface.BreaklinesDefinition.AddStandardBreaklines(breaklineSet, 1.0, 1.0, 1.0, 0);
                   
                    ////Surface Boundary Definition
                    ObjectIdCollection boundaryIdSet = new ObjectIdCollection();
                    boundaryIdSet.Add(boundary.ObjectId);
                    surface.BoundariesDefinition.AddBoundaries(boundaryIdSet, 1.0, Autodesk.Civil.SurfaceBoundaryType.Outer, true); 
                    
                    //Conditionally also convert the surface into solid with given depth
                    //Ideally, Solid will be created with depth 2m.
                    if (ExtrudeSolid == true)
                        surface.CreateSolidsAtDepth(DepthOfSolid, surface.Layer, 0);

                    //***My question is: do i need to run the below code??
                    //modelSpace.AppendEntity(surface);
                    //trans.AddNewlyCreatedDBObject(surface, true);
                    //***End of question
                }
                catch (Exception ex)
                {
                    Application.ShowAlertDialog("Error creating TIN Surface.\n" + ex.Message);
                }
            }
            return surfaceId;
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 06:41:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487127#M4818</guid>
      <dc:creator>heyimsp12</dc:creator>
      <dc:date>2022-10-17T06:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Do I have to append TIN Surface to the database?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487205#M4819</link>
      <description>&lt;P&gt;HI &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12075085"&gt;@heyimsp12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Think&lt;/P&gt;&lt;P&gt;YOU Forgot this to the code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;trans.Commit();&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 07:33:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487205#M4819</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2022-10-17T07:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Do I have to append TIN Surface to the database?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487251#M4820</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6591997"&gt;@hosneyalaa&lt;/a&gt;. I will end the transaction, but that still doesn't solve the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also btw, since the transaction is in using-statement, I don't think I necessarily need to close it but I'm not sure. It sounds like a good idea to commit the transaction manually.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 07:59:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487251#M4820</guid>
      <dc:creator>heyimsp12</dc:creator>
      <dc:date>2022-10-17T07:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Do I have to append TIN Surface to the database?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487991#M4821</link>
      <description>&lt;P&gt;C3D handles adding the Surface to the database.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12075085"&gt;@heyimsp12&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6591997"&gt;@hosneyalaa&lt;/a&gt;. I will end the transaction, but that still doesn't solve the problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also btw, since the transaction is in using-statement, I don't think I necessarily need to close it but I'm not sure. It sounds like a good idea to commit the transaction manually.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you don't Commit the transaction, it is disposed when exiting the Using statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you will need to Rebuild the Surface prior to creating the solids.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 14:28:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/do-i-have-to-append-tin-surface-to-the-database/m-p/11487991#M4821</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2022-10-17T14:28:46Z</dc:date>
    </item>
  </channel>
</rss>

