<?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: Create a Pipe Network, unable to add parts in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11010863#M6238</link>
    <description>&lt;P&gt;no. I haven't&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2022 09:26:10 GMT</pubDate>
    <dc:creator>John_van_Rijn</dc:creator>
    <dc:date>2022-03-17T09:26:10Z</dc:date>
    <item>
      <title>Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10603174#M6230</link>
      <description>&lt;P&gt;I am attempting to get or create a pipe network and add some pipes to it. If the Network has already been created in C3D everything works as expected. However, if the Network does not exist and I create it in code, no parts can be added to it, in code or even manually in C3D. Comparing the code created Network with one created in C3D I see zero differences in the properties.&lt;/P&gt;
&lt;P&gt;I have a few Extension methods I use to get the existing Networks and to create the Network if needed. It all works up until I try to add a part to a created Network. Any ideas on how to get this to function properly? I currently will be forcing the user to create a Network in C3D prior to running the tool.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;        ///&amp;lt;summary&amp;gt;
        ///Returns Dictionary of ObjectIds &amp;amp; names of all pipe networks in the document.
        ///&amp;lt;/summary&amp;gt;
        public static Dictionary&amp;lt;ObjectId, string&amp;gt; GetPipeNetworkNames(this CivilDocument civDoc)
        {
            Dictionary&amp;lt;ObjectId, string&amp;gt; dict = new Dictionary&amp;lt;ObjectId, string&amp;gt;();
            using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
            {
                foreach (ObjectId objId in civDoc.GetPipeNetworkIds())
                {
                    Network net = (Network)objId.GetObject(OpenMode.ForRead);
                    dict.Add(objId, net.Name);
                }
                tr.Commit();
            }
            return dict;
        }

        public static ObjectId GetOrCreatePipeNetwork(this CivilDocument civDoc, string name)
        {
            ObjectId retval = ObjectId.Null;
            foreach (var pair in civDoc.GetPipeNetworkNames())
            {
                if (pair.Value == name)
                {
                    retval = pair.Key;
                    return retval;

                }
            }
            retval = Network.Create(civDoc, ref name);
            return retval;
        }

//and this is a snip where I get/create the Network
                var ntwrkId = civdoc.GetOrCreatePipeNetwork("Test");
                var ntwrk = (Network)ntwrkId.GetObject(OpenMode.ForWrite);
                //make sure the Network has a PartsList assigned
                try { var tmp = ntwrk.PartsListId; }
                catch
                { ntwrk.PartsListId = civdoc.Styles.PartsListSet[0]; }
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 15:02:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10603174#M6230</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-09-06T15:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10603185#M6231</link>
      <description>I should add that I have tried wrapping the creation in a separate Transaction to insure the Network is database resident prior to adding the parts.</description>
      <pubDate>Mon, 06 Sep 2021 15:06:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10603185#M6231</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-09-06T15:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10604466#M6232</link>
      <description>&lt;P&gt;I was unable to reproduce your problem. I took your code and used it to create a new network with 1 structure in it and it worked. I tried it in one of the built in templates, as well as my own template. The code worked in the following versions of Civil 3D:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2019.3.1&lt;/P&gt;&lt;P&gt;2020.6&lt;BR /&gt;2021.3&lt;BR /&gt;2022.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code I used to create the network and structure. I copied your extension methods into an extension class so the code would be the same as yours (as much as possible).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (Transaction tr = Self.Db.TransactionManager.StartTransaction())
            {
                // Create the network
                var ntwrkId = Self.CivDoc.GetOrCreatePipeNetwork("Test"); // Self is just a static class I use to store convenient references to the Editor, CivilDocument, Database, etc. Self.CivDoc is the current CivilDocuement
                var ntwrk = (Network)ntwrkId.GetObject(OpenMode.ForWrite);

                // Make sure the Network has a PartsList assigned
                try { var tmp = ntwrk.PartsListId; }
                catch
                { ntwrk.PartsListId = Self.CivDoc.Styles.PartsListSet[0]; }

                // Create a structure at 0,0,0
                var psc = PartSizeContainer.GetPartSizeContainers(ntwrk.PartsListName, DomainType.Structure)[0]; //GetPartSizeContainers is a helper function for getting a list of all the part sizes in a partslist
                ObjectId newStId = ObjectId.Null;
                ntwrk.AddStructure(psc.FamilyId, psc.PartSizeId, Point3d.Origin, 0, ref newStId, false);
                var st = (Structure)newStId.GetObject(OpenMode.ForWrite);

                tr.Commit();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that in the above code I made comments for 2 functions (GetPartSizeContainers and&amp;nbsp;Self.CivDoc), which are just some helper classes/methods that I use and should not affect anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not know why it would not be working for you, I can only guess at a possible drawing corruption or maybe the parts list does not properly match the pipe catalog set.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 06:32:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10604466#M6232</guid>
      <dc:creator>Kyle-L</dc:creator>
      <dc:date>2021-09-07T06:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10605970#M6233</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3053721"&gt;@Kyle-L&lt;/a&gt;&amp;nbsp;thanks for checking this. I had tested in 2 different drawings (using C3D 2020) before posting. I'm fairly certain that the same partslist I was using is the same as the one used to manually create a network, but I will have to go back and verify that. It's good to know that I should be able to get this to work.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 16:24:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10605970#M6233</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-09-07T16:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10606077#M6234</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3053721"&gt;@Kyle-L&lt;/a&gt;, thanks again! Sure enough, the PartList I used in both drawings I tested was the culprit.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 17:10:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10606077#M6234</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-09-07T17:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10606085#M6235</link>
      <description>&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt; I am glad you found the cause!</description>
      <pubDate>Tue, 07 Sep 2021 17:13:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/10606085#M6235</guid>
      <dc:creator>Kyle-L</dc:creator>
      <dc:date>2021-09-07T17:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11005777#M6236</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good solution,&amp;nbsp;&lt;BR /&gt;Having the same issue (c3d 2022) with my dynamo script/creation, and I want to use your solution.&lt;BR /&gt;How do you use this note into the dynamo script? or other?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 09:57:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11005777#M6236</guid>
      <dc:creator>John_van_Rijn</dc:creator>
      <dc:date>2022-03-15T09:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11010007#M6237</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried to use&amp;nbsp;&lt;SPAN&gt;nodes toolkit&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 21:57:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11010007#M6237</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2022-03-16T21:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11010863#M6238</link>
      <description>&lt;P&gt;no. I haven't&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 09:26:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11010863#M6238</guid>
      <dc:creator>John_van_Rijn</dc:creator>
      <dc:date>2022-03-17T09:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11013055#M6239</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3053721"&gt;@Kyle-L&lt;/a&gt;, thanks again! Sure enough, the PartList I used in both drawings I tested was the culprit.&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Care to elaborate more? I haven't face with this situation in the past, but I afraid I will. So it would be good if we can know more details about this..&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 03:27:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11013055#M6239</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2022-03-18T03:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Pipe Network, unable to add parts</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11013104#M6240</link>
      <description>&lt;P&gt;A partslist refers to various parts in your pipe catalog, it basically tells C3D which parts to use from your catalog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have a partslist in your drawing that refers to a pipe catalog other than the one that you have set then when you try to create a pipe the partslist fails to find the pipe in the set catalog thus the pipe is not created.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 04:21:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/create-a-pipe-network-unable-to-add-parts/m-p/11013104#M6240</guid>
      <dc:creator>Kyle-L</dc:creator>
      <dc:date>2022-03-18T04:21:44Z</dc:date>
    </item>
  </channel>
</rss>

