<?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: How to create customized schedule including the nested family Instances in Revit. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004570#M3195</link>
    <description>&lt;P&gt;you had error in cration of famiy you need to make families nested in order to get them in&lt;/P&gt;&lt;PRE&gt;GetSubComponentIds()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarryTookMyCoffe_0-1725616875383.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1406340iEE3018FD4DFC38ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarryTookMyCoffe_0-1725616875383.png" alt="MarryTookMyCoffe_0-1725616875383.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can see in revit lookup that when I set inner family as nested list have elements&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2024 10:01:54 GMT</pubDate>
    <dc:creator>MarryTookMyCoffe</dc:creator>
    <dc:date>2024-09-06T10:01:54Z</dc:date>
    <item>
      <title>How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004236#M3193</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;I've placed only one instance (a family of generic Models category) in my Revit project. Basically, this family is a window assembly made of some other families hence this Family has some nested families (all are of generic model category) in it.&lt;/P&gt;&lt;P&gt;Now&amp;nbsp;using Revit API I want to create a customizes schedule in which I can display count of all the individual nested families (instances). I've attached the family as well. Though I tried but didn't succeed. Can you suggest something?&lt;BR /&gt;&lt;BR /&gt;Thanks for your valuable time!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 05:52:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004236#M3193</guid>
      <dc:creator>theknownsilhouette</dc:creator>
      <dc:date>2024-09-06T05:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004390#M3194</link>
      <description>&lt;P&gt;I've tried below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;class ScheduleCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;
                        FamilyInstance assemblyInstance = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WhereElementIsNotElementType().Cast&amp;lt;FamilyInstance&amp;gt;().FirstOrDefault(x =&amp;gt; x.Symbol.FamilyName.Equals("Sample Window Family"));

            if (assemblyInstance is FamilyInstance)
            {
                Dictionary&amp;lt;string, int&amp;gt; nestedFamilies = GetNestedFamilyNamesAndCounts(doc, assemblyInstance);

                string resultMsg = "The Family '" + assemblyInstance.Name + "' containsthe following families:\n";

                foreach (var item in nestedFamilies)
                {
                    resultMsg += $"- {item.Key}: {item.Value} instance(s)\n";
                }
                TaskDialog.Show("Nested Family Details", resultMsg);
            }
            return Result.Succeeded;
        }




        private Dictionary&amp;lt;string, int&amp;gt; GetNestedFamilyNamesAndCounts(Document doc, FamilyInstance assemblyInstance)
        {
            Dictionary&amp;lt;string, int&amp;gt; nestedFamilyCounts = new Dictionary&amp;lt;string, int&amp;gt;();

            ICollection&amp;lt;ElementId&amp;gt; nestedComponentIds = assemblyInstance.GetSubComponentIds();
            foreach (var nestedComponentId in nestedComponentIds)
            {
                FamilyInstance familyInstance = doc.GetElement(nestedComponentId) as FamilyInstance;

                if (familyInstance != null)
                {
                    string nestedFamilyName = familyInstance.Symbol.Name;
                    if (nestedFamilyCounts.ContainsKey(nestedFamilyName))
                    {
                        nestedFamilyCounts[nestedFamilyName]++;
                    }
                    else
                    {
                        nestedFamilyCounts[nestedFamilyName] = 1;
                    }
                }
            }
            return nestedFamilyCounts;
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It didn't work as&amp;nbsp;&amp;nbsp;the below line of code&amp;nbsp;returned null.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;ICollection&amp;lt;ElementId&amp;gt; nestedComponentIds = assemblyInstance.GetSubComponentIds(); &lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also I've tried this code as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Document doc = commandData.Application.ActiveUIDocument.Document;
           
            FilteredElementCollector familyCollector = new FilteredElementCollector(doc)
                .OfClass(typeof(FamilyInstance));

            foreach (FamilyInstance familyInstance in familyCollector)
            {
                if (familyInstance.Symbol.FamilyName == "Sample Window Family")
                {
                    Dictionary&amp;lt;string, int&amp;gt; nestedFamilies = GetVisibleNestedFamilyNamesAndCounts(doc, familyInstance);

                   
                    string resultMessage = "The family '" + familyInstance.Name + "' contains the following visible nested families:\n";
                    foreach (var family in nestedFamilies)
                    {
                        resultMessage += $"- {family.Key}: {family.Value} instance(s)\n";
                    }

                    TaskDialog.Show("Visible Nested Family Count", resultMessage);
                }
            }



 private Dictionary&amp;lt;string, int&amp;gt; GetVisibleNestedFamilyNamesAndCounts(Document doc, FamilyInstance parentFamilyInstance)
        {
            Dictionary&amp;lt;string, int&amp;gt; nestedFamilyCounts = new Dictionary&amp;lt;string, int&amp;gt;();

            FilteredElementCollector collector = new FilteredElementCollector(doc)
                .OfClass(typeof(FamilyInstance));

            foreach (FamilyInstance instance in collector)
            {if (instance.Host != null &amp;amp;&amp;amp; instance.Host.Id == parentFamilyInstance.Id)
                {
                    if (IsFamilyInstanceVisible(instance))
                    {
                        string nestedFamilyName = instance.Symbol.FamilyName;

                        if (nestedFamilyCounts.ContainsKey(nestedFamilyName))
                        {
                            nestedFamilyCounts[nestedFamilyName]++;
                        }
                        else
                        {
                            nestedFamilyCounts[nestedFamilyName] = 1;
                        }
                    }
                }
            }

            return nestedFamilyCounts;
        }

 private bool IsFamilyInstanceVisible(FamilyInstance instance)
        {
            
            Parameter visibilityParam = instance.get_Parameter(BuiltInParameter.IS_VISIBLE_PARAM);
            if (visibilityParam != null &amp;amp;&amp;amp; visibilityParam.AsInteger() == 0)
            {
                return false; 
            }
            return true; 
        }

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This approach didn't work as the collector didn't collect the nested familyInstances actually.&lt;BR /&gt;&lt;BR /&gt;I'd appreciate any potential suggestions that will help to achieve the goal.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 08:11:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004390#M3194</guid>
      <dc:creator>theknownsilhouette</dc:creator>
      <dc:date>2024-09-06T08:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004570#M3195</link>
      <description>&lt;P&gt;you had error in cration of famiy you need to make families nested in order to get them in&lt;/P&gt;&lt;PRE&gt;GetSubComponentIds()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarryTookMyCoffe_0-1725616875383.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1406340iEE3018FD4DFC38ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarryTookMyCoffe_0-1725616875383.png" alt="MarryTookMyCoffe_0-1725616875383.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can see in revit lookup that when I set inner family as nested list have elements&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 10:01:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13004570#M3195</guid>
      <dc:creator>MarryTookMyCoffe</dc:creator>
      <dc:date>2024-09-06T10:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13008443#M3196</link>
      <description>&lt;P&gt;Sorry &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3894260"&gt;@MarryTookMyCoffe&lt;/a&gt;,&amp;nbsp; I didn't get it. This is a family (rfa) which already has instances of other families (rfa files).&lt;BR /&gt;Are you saying that somehow, I need to make these families (or define these families) as a nested family using the API?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 05:52:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13008443#M3196</guid>
      <dc:creator>theknownsilhouette</dc:creator>
      <dc:date>2024-09-09T05:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13008474#M3197</link>
      <description>&lt;P&gt;Can you achieve the desired result manually in the end user interface? What do you do there in order to achieve that? If it is not possible in the UI, the API will not be able to help you either. It just wraps and reproduces the UI functionality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 06:18:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13008474#M3197</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-09-09T06:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13008741#M3198</link>
      <description>&lt;P&gt;Yes &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;If I check the option "shared" as below, I can see the particular nested instance in the project schedule.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="theknownsilhouette_0-1725872402601.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1406931i076E20CE7756B975/image-size/medium?v=v2&amp;amp;px=400" role="button" title="theknownsilhouette_0-1725872402601.png" alt="theknownsilhouette_0-1725872402601.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In this particular context, we can use "IFamilyOptions" interface to check if a family is shared or not but I'm not getting how to make a family "shared" using the API? If I can make the family shared and load it back to the project, it can be done.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 09:15:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13008741#M3198</guid>
      <dc:creator>theknownsilhouette</dc:creator>
      <dc:date>2024-09-09T09:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13009272#M3199</link>
      <description>&lt;P&gt;Below line worked for me:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;bool a = NestedFamily.get_Parameter(BuiltInParameter.FAMILY_SHARED).Set(1);&lt;/LI-CODE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;complete code can be referred below.&lt;/P&gt;&lt;LI-CODE lang="general"&gt; UIApplication uiApp = commandData.Application;
            UIDocument uiDoc = uiApp.ActiveUIDocument;
            Document doc = commandData.Application.ActiveUIDocument.Document;
            string FolderLocation = Path.GetDirectoryName(doc.PathName);

            
            FamilyInstance assemblyInstance = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WhereElementIsNotElementType().Cast&amp;lt;FamilyInstance&amp;gt;().FirstOrDefault(x =&amp;gt; x.Symbol.FamilyName.Equals("Sample Window Family"));

            Family placedFamily = assemblyInstance.Symbol.Family;
            Document familyDoc = doc.EditFamily(placedFamily);

            IEnumerable&amp;lt;FamilyInstance&amp;gt; nestedFamilies = new FilteredElementCollector(familyDoc).OfClass(typeof(FamilyInstance)).Cast&amp;lt;FamilyInstance&amp;gt;();


            familyLoadOption famLoadOptions = new familyLoadOption();
            foreach (var item in nestedFamilies)
            {
                Transaction nestedTrans = new Transaction(familyDoc, "make Shared");
                nestedTrans.Start();
                Family NestedFamily = item.Symbol.Family;
                Document nestedFamilyDoc = doc.EditFamily(NestedFamily);
                
                bool a = NestedFamily.get_Parameter(BuiltInParameter.FAMILY_SHARED).Set(1);
                nestedFamilyDoc.LoadFamily(doc, famLoadOptions);
                nestedTrans.Commit();
            }



            Transaction Trans = new Transaction(familyDoc, "make current Shared");
            Trans.Start();
            familyDoc.LoadFamily(doc, famLoadOptions);
            Trans.Commit();
            return Result.Succeeded;&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;My schedule before this implementation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="theknownsilhouette_0-1725889414113.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1407032i8CE7FC92D6B1ADD5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="theknownsilhouette_0-1725889414113.png" alt="theknownsilhouette_0-1725889414113.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My schedule after making the families shared:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="theknownsilhouette_1-1725889497165.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1407034iAB62DEC6C8709268/image-size/medium?v=v2&amp;amp;px=400" role="button" title="theknownsilhouette_1-1725889497165.png" alt="theknownsilhouette_1-1725889497165.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 13:45:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13009272#M3199</guid>
      <dc:creator>theknownsilhouette</dc:creator>
      <dc:date>2024-09-09T13:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13018939#M3200</link>
      <description>&lt;P&gt;I see you made it, good job&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:11:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13018939#M3200</guid>
      <dc:creator>MarryTookMyCoffe</dc:creator>
      <dc:date>2024-09-13T12:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create customized schedule including the nested family Instances in Revit.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13018944#M3201</link>
      <description>&lt;P&gt;I had revit in difrent language so I didn't know that they call it shared in english UI&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:12:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-create-customized-schedule-including-the-nested-family/m-p/13018944#M3201</guid>
      <dc:creator>MarryTookMyCoffe</dc:creator>
      <dc:date>2024-09-13T12:12:36Z</dc:date>
    </item>
  </channel>
</rss>

