<?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 Loading families with nested elements in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6919605#M59896</link>
    <description>&lt;P&gt;I am trying to load families into a document with a macro. It appears that if I attempt to load a family with a nested family inside it, and that nested family is already loaded into the project, it will fail. Has anyone else noticed this? Is there a way around it? Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2017 18:40:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-03-03T18:40:36Z</dc:date>
    <item>
      <title>Loading families with nested elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6919605#M59896</link>
      <description>&lt;P&gt;I am trying to load families into a document with a macro. It appears that if I attempt to load a family with a nested family inside it, and that nested family is already loaded into the project, it will fail. Has anyone else noticed this? Is there a way around it? Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 18:40:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6919605#M59896</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-03T18:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Loading families with nested elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6922899#M59897</link>
      <description>&lt;P&gt;did you try to load it manually with the UI?&lt;BR /&gt;I load lots of families and I never had problem with it. Almost all my families are nested, some even with 12 layers. If families are already loaded it should&amp;nbsp; make actualisation.&lt;BR /&gt;What kid error appear?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 08:13:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6922899#M59897</guid>
      <dc:creator>MarryTookMyCoffe</dc:creator>
      <dc:date>2017-03-06T08:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Loading families with nested elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6922992#M59898</link>
      <description>&lt;P&gt;Hi @Anonymous,&lt;/P&gt;
&lt;P&gt;If the family in document is shared, and the nested family is not (or vice-versa), then the load will fail (as it would if you did it manually).&lt;/P&gt;
&lt;P&gt;That's probably where &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3894260"&gt;@MarryTookMyCoffe&lt;/a&gt;&amp;nbsp;is coming from.&lt;/P&gt;
&lt;P&gt;Otherwise, show us code. Are you implementing IFamilyLoadOptions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 09:09:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6922992#M59898</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-03-06T09:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Loading families with nested elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6925120#M59899</link>
      <description>&lt;P&gt;The family (in this example) is a table with a support. The supports&amp;nbsp;are nested in the family. There are several different families to load which are variations of this table (round, handicap accessible, etc.). The table support nested in the family is shared, but the table family itself is not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've found by attempting to load manually that if the dialog box "Shared Family Already Exists" pops up when loading, that also seems to be the place where the script fails. Conversely, if I load tables manually and that dialog does not pop up, then the script works as well. The minute I have a family where that dialog would occur, the script fails, which leads me to believe that it is the source of the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I manually unload the support family in the script before attempting to load the tables, it also works. I would rather not hard code in families to remove for obvious reasons. If there is a way to check what families exist in a family and then unload them, that would be preferred, but I can't figure out how to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is below. It is checking a specific parameter 'portfolio' in the types to see if it contains a specified value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void LoadFamilies(string dirpath)&lt;BR /&gt;{&lt;BR /&gt;Document doc = this.Document;&lt;BR /&gt;&lt;BR /&gt;// this is the portfolio name&lt;BR /&gt;String portfolio_name = @"Origin Classic-Core";&lt;BR /&gt;// we want anything that is for all templates too&lt;BR /&gt;String all_templates = "&amp;lt;All Templates&amp;gt;";&lt;BR /&gt;&lt;BR /&gt;string[] files = Directory.GetFiles(dirpath, "*.rfa");&lt;BR /&gt;&lt;BR /&gt;// step through the list and load the families one by one&lt;BR /&gt;foreach (string familyfile in files) {&lt;BR /&gt;Family fam = null;&lt;BR /&gt;&lt;BR /&gt;Transaction trans = new Transaction(doc, "Checking Family for Types");&lt;BR /&gt;trans.Start();&lt;BR /&gt;doc.LoadFamily(familyfile, out fam); // load the family and its types&lt;BR /&gt;&lt;BR /&gt;// use ids to get all the types for the family&lt;BR /&gt;ISet&amp;lt;ElementId&amp;gt; symbolIds = fam.GetFamilySymbolIds();&lt;BR /&gt;&lt;BR /&gt;// family types to load&lt;BR /&gt;List&amp;lt;String&amp;gt; typesToLoad = new List&amp;lt;String&amp;gt;();&lt;/P&gt;&lt;P&gt;// iterate through the types and check for Portfolio parameter.&lt;BR /&gt;foreach (ElementId id in symbolIds) {&lt;BR /&gt;bool hasPortfolio = false;&lt;BR /&gt;// retrieve the type symbol&lt;BR /&gt;Element symbol = doc.GetElement(id);&lt;BR /&gt;// check for 'Portfolio' value&lt;BR /&gt;foreach (Parameter para in symbol.Parameters) {&lt;BR /&gt;switch (para.Definition.Name) {&lt;BR /&gt;case "Portfolio":&lt;BR /&gt;string defValue = GetParameterInformation(para, doc);&lt;BR /&gt;if ( (defValue.Equals(portfolio_name)) || (defValue.Equals(all_templates)) ) {&lt;BR /&gt;typesToLoad.Add(symbol.Name);&lt;BR /&gt;} //if&lt;BR /&gt;hasPortfolio = true;&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;} //foreach&lt;BR /&gt;if (hasPortfolio == false) {&lt;BR /&gt;typesToLoad.Add(symbol.Name);&lt;BR /&gt;}&lt;BR /&gt;} //foreach&lt;BR /&gt;trans.RollBack(); // don't load the entire family!&lt;BR /&gt;&lt;BR /&gt;// Now load only family types we want for this portfolio&lt;BR /&gt;// if there is a 'Portfolio' parameter and some items match our criteria, i.e. the list has elements in it&lt;BR /&gt;using (Transaction transNew = new Transaction(doc)) {&lt;BR /&gt;transNew.Start("Load Types");&lt;BR /&gt;if ( (typesToLoad != null) &amp;amp;&amp;amp; (typesToLoad.Any()) ) {&lt;BR /&gt;foreach (String symbol in typesToLoad) {&lt;BR /&gt;doc.LoadFamilySymbol(familyfile, symbol);&lt;BR /&gt;} //foreach&lt;BR /&gt;} //if&lt;BR /&gt;transNew.Commit();&lt;BR /&gt;}&lt;BR /&gt;} //iterate through list of families in directory&lt;BR /&gt;} //LoadFamilies&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:56:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6925120#M59899</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-06T22:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Loading families with nested elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6926143#M59900</link>
      <description>&lt;P&gt;Hi @Anonymous,&lt;/P&gt;
&lt;P&gt;You are best to either have one copy of each family, and have them shared if necessary.&lt;/P&gt;
&lt;P&gt;If you have a shared and a non-shared family legacy issue, then I suggest renaming one of them (in a standard way), so that the loading clash doesn't happen.&lt;/P&gt;
&lt;P&gt;There's no easier workaround (that I can think of).&lt;/P&gt;
&lt;P&gt;You can check if a loaded family is shared by checking the value of the Family_Shared builtinparameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 11:12:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/loading-families-with-nested-elements/m-p/6926143#M59900</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-03-07T11:12:22Z</dc:date>
    </item>
  </channel>
</rss>

