<?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: Creating a pipe or flex pipe by loading a family in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9317695#M36668</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Notice that &amp;lt;Duct&amp;gt;, &amp;lt;Pipe&amp;gt; as well as &amp;lt;FlexDuct&amp;gt; and &amp;lt;FlexPipe&amp;gt; are all "Built In" elements.&lt;/P&gt;&lt;P&gt;They are very basic types of elements in Revit DB. They have their own "types", such as &amp;lt;DuctType&amp;gt; or &amp;lt;PipeType&amp;gt;. Their *Family* are all built-in. For example, &amp;lt;Duct&amp;gt; has only 3 families: Rectangle, Round, Oval; &amp;lt;Pipe&amp;gt; has only 1 family: Pipe Types.(don't understand why Autodesk gave such a confusing name to this family.....).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also lots of elements with the type &amp;lt;FamilyInstance&amp;gt;. The class &amp;lt;FamilySymbol&amp;gt; is a "type" of a &amp;lt;FamilyInstance&amp;gt; element. &amp;lt;FamilyInstance&amp;gt; elements have their own "type" &amp;lt;FamilySymbol&amp;gt;. And &amp;lt;FamilySymbol&amp;gt; have their own family &amp;lt;Family&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, for Revit DB "built in" elements, such as a &amp;lt;Pipe&amp;gt; element, it is of a "type" &amp;lt;PipeType&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 2 parallel world in Revit API world, one is *Built-In* elements, another is &amp;lt;FamilyInstance&amp;gt; elements.&lt;/P&gt;&lt;P&gt;All I can tell is that "&lt;STRONG&gt;Loading a family&lt;/STRONG&gt; &lt;U&gt;has nothing to do&lt;/U&gt; with &lt;STRONG&gt;creating a Pipe&lt;/STRONG&gt;". &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Feb 2020 04:18:01 GMT</pubDate>
    <dc:creator>jlpgy</dc:creator>
    <dc:date>2020-02-14T04:18:01Z</dc:date>
    <item>
      <title>Creating a pipe or flex pipe by loading a family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9317335#M36667</link>
      <description>&lt;P&gt;I'm completely new to the Revit API and am having trouble simply loading a family and using it to create a pipe or flex pipe. I'm sure there is something simple I am missing, and I've had success with things like doors and tables, however I'm completely baffled with creating even a simple pipe that goes from A to B beyond just the default pipe option (I've included the code I used to make a default flex pipe and default pipe - my only success). I have not been successful in finding example code online (I have scoured The Building Coder and have not found enough pieces to put this together). If someone can give me a basis to work from I would be so grateful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working FlexPipe:&lt;/P&gt;&lt;PRE&gt;private static void CreateFlexPipe(Document newDoc, Wall wall)
        {

            FilteredElementCollector collector = new FilteredElementCollector(newDoc);
            collector.OfClass(typeof(FlexPipeType));
            ElementId pipeTypeId = collector.FirstElementId();

            FilteredElementCollector sysCollector = new FilteredElementCollector(newDoc);
            sysCollector.OfClass(typeof(PipingSystemType));
            ElementId pipeSysTypeId = sysCollector.FirstElementId();

            Level levelId = newDoc.GetElement(wall.LevelId) as Level;

            FlexPipe pipe = null;
            if (pipeTypeId != ElementId.InvalidElementId &amp;amp;&amp;amp; pipeSysTypeId != ElementId.InvalidElementId)
            {
                List&amp;lt;XYZ&amp;gt; points = new List&amp;lt;XYZ&amp;gt;();
                points.Add(new XYZ(0, 0, 0));
                points.Add(new XYZ(10, 10, 0));
                points.Add(new XYZ(10, 0, 0));

                pipe = FlexPipe.Create(newDoc, pipeSysTypeId, pipeTypeId, levelId.Id, points);
            }
        }&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Working Pipe:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;private static void CreatePipe(Document newDoc, Wall wall)
        {

            FilteredElementCollector collector = new FilteredElementCollector(newDoc);
            collector.OfClass(typeof(PipeType));
            ElementId pipeTypeId = collector.FirstElementId();

            FilteredElementCollector sysCollector = new FilteredElementCollector(newDoc);
            sysCollector.OfClass(typeof(PipingSystemType));
            ElementId pipeSysTypeId = sysCollector.FirstElementId();

            Level levelId = newDoc.GetElement(wall.LevelId) as Level;

            Pipe pipe1 = null;

            if (pipeTypeId != ElementId.InvalidElementId &amp;amp;&amp;amp; pipeSysTypeId != ElementId.InvalidElementId)
            {
                XYZ p1 = new XYZ(0, 0, 0);
                XYZ p2 = new XYZ(10, 10, 0);

                pipe1 = Pipe.Create(newDoc, pipeSysTypeId, pipeTypeId, levelId.Id, p1, p2);

            }

        }&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Also here is where I am at with trying to load a family:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;private static void TestLoadFamily(Document newDoc)
        {
            string filename = @"C:\ProgramData\Autodesk\RVT 2020\Libraries\US Metric\Pipe\Actual Pipe\JONATHAN39S_METRIC_PIPE_HORIZONTAL_30MM_PIPE_THICK_2825.rfa";

            FilteredElementCollector levelCollector = new FilteredElementCollector(newDoc);
            levelCollector.OfClass(typeof(Level));
            ElementId someLevelId = levelCollector.FirstElementId();

            FilteredElementCollector sysCollector = new FilteredElementCollector(newDoc);
            sysCollector.OfClass(typeof(PipingSystemType));
            ElementId pipeSysTypeId = sysCollector.FirstElementId();

            using (Transaction familyTrans = new Transaction(newDoc, "Use a Family"))
            {
                familyTrans.Start();

                Family family = null;
                if (!newDoc.LoadFamily(filename, out family))
                {
                    throw new Exception("Unable to load " + filename);
                }

                ISet&amp;lt;ElementId&amp;gt; familySymbolIds = family.GetFamilySymbolIds();

                int count = 0;
                foreach (ElementId id in familySymbolIds)
                {
                    if (count == 0)
                    {
                        FamilySymbol pipeSymbol = family.Document.GetElement(id) as FamilySymbol;
                        if (!pipeSymbol.IsActive)
                        {
                            pipeSymbol.Activate();
                            newDoc.Regenerate();
                        }
                        Pipe pipe = null;
                        XYZ p1 = new XYZ(0, 0, 0);
                        XYZ p2 = new XYZ(10, 10, 0);

                        pipe = Pipe.Create(newDoc, pipeSysTypeId, pipeSymbol.Id, someLevelId, p1, p2);
                    }
                    count++;
                }
                familyTrans.Commit();
            }
        }&lt;/PRE&gt;&lt;P&gt;This errors with: "The pipe type pipeTypeId is not valid pipe type."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Note: I am using the DesignAutomationHandler and build within another project.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 22:33:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9317335#M36667</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-13T22:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a pipe or flex pipe by loading a family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9317695#M36668</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Notice that &amp;lt;Duct&amp;gt;, &amp;lt;Pipe&amp;gt; as well as &amp;lt;FlexDuct&amp;gt; and &amp;lt;FlexPipe&amp;gt; are all "Built In" elements.&lt;/P&gt;&lt;P&gt;They are very basic types of elements in Revit DB. They have their own "types", such as &amp;lt;DuctType&amp;gt; or &amp;lt;PipeType&amp;gt;. Their *Family* are all built-in. For example, &amp;lt;Duct&amp;gt; has only 3 families: Rectangle, Round, Oval; &amp;lt;Pipe&amp;gt; has only 1 family: Pipe Types.(don't understand why Autodesk gave such a confusing name to this family.....).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also lots of elements with the type &amp;lt;FamilyInstance&amp;gt;. The class &amp;lt;FamilySymbol&amp;gt; is a "type" of a &amp;lt;FamilyInstance&amp;gt; element. &amp;lt;FamilyInstance&amp;gt; elements have their own "type" &amp;lt;FamilySymbol&amp;gt;. And &amp;lt;FamilySymbol&amp;gt; have their own family &amp;lt;Family&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, for Revit DB "built in" elements, such as a &amp;lt;Pipe&amp;gt; element, it is of a "type" &amp;lt;PipeType&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 2 parallel world in Revit API world, one is *Built-In* elements, another is &amp;lt;FamilyInstance&amp;gt; elements.&lt;/P&gt;&lt;P&gt;All I can tell is that "&lt;STRONG&gt;Loading a family&lt;/STRONG&gt; &lt;U&gt;has nothing to do&lt;/U&gt; with &lt;STRONG&gt;creating a Pipe&lt;/STRONG&gt;". &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 04:18:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9317695#M36668</guid>
      <dc:creator>jlpgy</dc:creator>
      <dc:date>2020-02-14T04:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a pipe or flex pipe by loading a family</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9318753#M36669</link>
      <description>&lt;P&gt;Thank you! The language helps immensely! I think I can do better searching now that I know what I'm looking for.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 14:21:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-a-pipe-or-flex-pipe-by-loading-a-family/m-p/9318753#M36669</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-14T14:21:48Z</dc:date>
    </item>
  </channel>
</rss>

