<?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 Get subcomponents from familyinstance in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6400111#M64764</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get the subcomponents from the 3 familyinstances in the file attached?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the GetSubcomponents method but it returns 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Øyvind Knappskog Olsen&lt;/P&gt;&lt;P&gt;Norconsult Informasjonssystemer AS&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 12:27:48 GMT</pubDate>
    <dc:creator>oyvind.knappskog.olsen</dc:creator>
    <dc:date>2016-06-23T12:27:48Z</dc:date>
    <item>
      <title>Get subcomponents from familyinstance</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6400111#M64764</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get the subcomponents from the 3 familyinstances in the file attached?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the GetSubcomponents method but it returns 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Øyvind Knappskog Olsen&lt;/P&gt;&lt;P&gt;Norconsult Informasjonssystemer AS&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 12:27:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6400111#M64764</guid>
      <dc:creator>oyvind.knappskog.olsen</dc:creator>
      <dc:date>2016-06-23T12:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get subcomponents from familyinstance</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6403647#M64765</link>
      <description>Dear Øyvind Knappskog Olsen, &lt;BR /&gt;Per our investigation, these three elements are AssemblyInstance but not FamilyInstance, so you can use AssemblyInstance.GetMemeberIds() to retrieve the sub components.</description>
      <pubDate>Sat, 25 Jun 2016 02:11:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6403647#M64765</guid>
      <dc:creator>JimJia</dc:creator>
      <dc:date>2016-06-25T02:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get subcomponents from familyinstance</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6403759#M64766</link>
      <description>&lt;P&gt;Thanks to &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1149164"&gt;@JimJia﻿&lt;/a&gt;. I've prepared a sample code to do the job:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#region Namespaces

using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.IO;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Plumbing;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.UI.Events;

//using Autodesk.Revit.Collections;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;
using System.Diagnostics;

#endregion

namespace RevitAddinCS2
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class ExtCmd : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;

        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }

        #endregion

        #region IExternalCommand Members

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            FilteredElementCollector collectorAssemblyInstance = new FilteredElementCollector(CachedDoc);

            collectorAssemblyInstance.OfClass(typeof(AssemblyInstance));

            List&amp;lt;AssemblyInstance&amp;gt; AssemblyInstances = collectorAssemblyInstance.Cast&amp;lt;AssemblyInstance&amp;gt;().ToList();

            StringBuilder sb = new StringBuilder();

            foreach (AssemblyInstance ai in AssemblyInstances)
            {
                sb.AppendLine(string.Format("Assembly {0} contains:", ai.Name));
                sb.AppendLine(string.Format("======================"));

                List&amp;lt;ElementId&amp;gt; members = ai.GetMemberIds().ToList();

                foreach(ElementId id in members)
                {
                    sb.AppendLine(string.Format("\tElement with Id: {0}", id.ToString()));
                }
            }

            TaskDialog.Show("Revit", sb.ToString());
            return Result.Succeeded;
        }

        #endregion
    }
}&lt;/PRE&gt;
&lt;P&gt;If this code satisfies your need pleas mark this reply as an answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2016 07:15:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6403759#M64766</guid>
      <dc:creator>Mustafa.Salaheldin</dc:creator>
      <dc:date>2016-06-25T07:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get subcomponents from familyinstance</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6430872#M64767</link>
      <description>Dear Øyvind Knappskog Olsen, &lt;BR /&gt;&lt;BR /&gt;Did you get chance to verify this case? do you think we can close this now?</description>
      <pubDate>Tue, 12 Jul 2016 09:11:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-subcomponents-from-familyinstance/m-p/6430872#M64767</guid>
      <dc:creator>JimJia</dc:creator>
      <dc:date>2016-07-12T09:11:14Z</dc:date>
    </item>
  </channel>
</rss>

