<?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: Get elements which are part of a selected assembly in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5697281#M71784</link>
    <description>Dear, I think you can &lt;BR /&gt;- get the id and then get element from document, &lt;BR /&gt;- and cast the element to AssemblyInstance &lt;BR /&gt;- then use AssemblyInstance.GetMemberIds() to get all its parts.&lt;BR /&gt;</description>
    <pubDate>Mon, 29 Jun 2015 08:37:07 GMT</pubDate>
    <dc:creator>Aaron.Lu</dc:creator>
    <dc:date>2015-06-29T08:37:07Z</dc:date>
    <item>
      <title>Get elements which are part of a selected assembly</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5693249#M71783</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying&amp;nbsp;to get a list of all elements that are not selected, so that I can hide them in a view, however I am running into a problem with elements that are part of assemblies. I am currently getting a list of all elements inside a view, and excluding those elements which are selected with this:&lt;/P&gt;&lt;PRE&gt;ICollection&amp;lt;ElementId&amp;gt; selection = data.Application.ActiveUIDocument.Selection.GetElementIds();
ICollection&amp;lt;ElementId&amp;gt; toHide = new List&amp;lt;ElementId&amp;gt;();
FilteredElementCollector collector
    = new FilteredElementCollector(doc, view.Id)
    .WhereElementIsNotElementType()
    .Excluding(selection);&lt;/PRE&gt;&lt;P&gt;I am then hiding each element in toHide, however the .Selection does not contain elements which are part of a selected assembly, so even if an assembly is selected, the elements inside it get hidden.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if there is any way to get either a list of selected assemblies and the elements inside them, or even just a list of all elements which are part of assemblies. If there is no way of knowing that an element is part of a assembly which is selected, then I would be fine excluding all elements which are part of an assembly. In this case, how could I check to see that an element is part of an assembly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great, thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2015 14:05:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5693249#M71783</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-25T14:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get elements which are part of a selected assembly</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5697281#M71784</link>
      <description>Dear, I think you can &lt;BR /&gt;- get the id and then get element from document, &lt;BR /&gt;- and cast the element to AssemblyInstance &lt;BR /&gt;- then use AssemblyInstance.GetMemberIds() to get all its parts.&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jun 2015 08:37:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5697281#M71784</guid>
      <dc:creator>Aaron.Lu</dc:creator>
      <dc:date>2015-06-29T08:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Get elements which are part of a selected assembly</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5697805#M71785</link>
      <description>&lt;P&gt;This worked great, thanks for the help.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2015 15:03:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/5697805#M71785</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-29T15:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get elements which are part of a selected assembly</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/8857913#M71786</link>
      <description>&lt;P&gt;Do you guys have an example of the code? I'm trying to achieve the same thing. I'm having issue with my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public StringBuilder SB(List&amp;lt;AssemblyInstance&amp;gt; assemblies)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;StringBuilder sb = new StringBuilder();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach (AssemblyInstance ai in assemblies)&lt;BR /&gt;//sb.Append(ai.Name + "" + ai.Id + "\n");&lt;BR /&gt;sb.Append(ai.Name + "" + ai.GetMemberIds());&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 14:25:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-elements-which-are-part-of-a-selected-assembly/m-p/8857913#M71786</guid>
      <dc:creator>Jes_Gonzalez</dc:creator>
      <dc:date>2019-06-18T14:25:37Z</dc:date>
    </item>
  </channel>
</rss>

