<?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: Override in view doesn't work on nested families (with revit api) in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12858706#M4507</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12921432"&gt;@PieterL_TM&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Uhm, never looked into that. Seems the manual override in the UI applies it to all the nested elements of the selected object, same with Groups, override the group and all items in the group get the override, but a new element added afterwards to the group doesn't get the override.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you need to check the selection for elements with (shared) nested components and add those nested components to the selection to be overwritten.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For familyinstances check &lt;A href="https://www.revitapidocs.com/2022/be37702c-1dcd-bc14-aa35-45f06f20210a.htm" target="_blank" rel="noopener"&gt;GetSubComponentIds&amp;nbsp; &lt;/A&gt;and for groups check all&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2022/09acaa13-d13a-776b-6019-fd5840dad996.htm" target="_blank" rel="noopener"&gt;GetMemberIds&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And then there's still Curtainwalls and maybe other elements. So a generic method might be &lt;A href="https://www.revitapidocs.com/2022/56e875d3-014b-a996-69c3-e6ed9b885f5c.htm" target="_blank" rel="noopener"&gt;GetDependentElements&lt;/A&gt; (Will return more than needed!, like Sketchline/plane etc, so those should be filtered out first.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2024 19:01:19 GMT</pubDate>
    <dc:creator>TripleM-Dev.net</dc:creator>
    <dc:date>2024-06-24T19:01:19Z</dc:date>
    <item>
      <title>Override in view doesn't work on nested families (with revit api)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12858032#M4506</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a python (test)script to override elements in view. It works on most elements, but not on doors and windows (which are wall-based families consisting of multiple nested families). If I select the nested families it does work.&lt;BR /&gt;&lt;BR /&gt;This is the result I'm getting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PieterL_TM_0-1719234749528.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1379297iE1603780E8300C98/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PieterL_TM_0-1719234749528.png" alt="PieterL_TM_0-1719234749528.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-

from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import *

uidoc = __revit__.ActiveUIDocument
doc = uidoc.Document
active_view = doc.ActiveView

selection = uidoc.Selection.GetElementIds()

all_patterns = FilteredElementCollector(doc).OfClass(FillPatternElement).ToElements()
solid_pattern = None
for pat in all_patterns:
    if pat.GetFillPattern().IsSolidFill:
        solid_pattern = pat
        break

ovs = OverrideGraphicSettings()
ovs.SetCutForegroundPatternColor(Color(255,165,0))
ovs.SetCutForegroundPatternId(solid_pattern.Id)
ovs.SetSurfaceForegroundPatternColor(Color(255,165,0))
ovs.SetSurfaceForegroundPatternId(solid_pattern.Id)

t = Transaction(doc, "set overrides")
t.Start()
for id in selection:
    active_view.SetElementOverrides(id, ovs)
t.Commit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Overriding it manually (not through a script) does work as expected&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 13:17:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12858032#M4506</guid>
      <dc:creator>PieterL_TM</dc:creator>
      <dc:date>2024-06-24T13:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Override in view doesn't work on nested families (with revit api)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12858706#M4507</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12921432"&gt;@PieterL_TM&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Uhm, never looked into that. Seems the manual override in the UI applies it to all the nested elements of the selected object, same with Groups, override the group and all items in the group get the override, but a new element added afterwards to the group doesn't get the override.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you need to check the selection for elements with (shared) nested components and add those nested components to the selection to be overwritten.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For familyinstances check &lt;A href="https://www.revitapidocs.com/2022/be37702c-1dcd-bc14-aa35-45f06f20210a.htm" target="_blank" rel="noopener"&gt;GetSubComponentIds&amp;nbsp; &lt;/A&gt;and for groups check all&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2022/09acaa13-d13a-776b-6019-fd5840dad996.htm" target="_blank" rel="noopener"&gt;GetMemberIds&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And then there's still Curtainwalls and maybe other elements. So a generic method might be &lt;A href="https://www.revitapidocs.com/2022/56e875d3-014b-a996-69c3-e6ed9b885f5c.htm" target="_blank" rel="noopener"&gt;GetDependentElements&lt;/A&gt; (Will return more than needed!, like Sketchline/plane etc, so those should be filtered out first.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 19:01:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12858706#M4507</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2024-06-24T19:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Override in view doesn't work on nested families (with revit api)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12859473#M4508</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3633270"&gt;@TripleM-Dev.net&lt;/a&gt;&amp;nbsp;Thanks!&lt;BR /&gt;That works, somehow it still seems counterintuitive. But like you said, if you override all the subcomponents, the UI shows as expected.&lt;/P&gt;&lt;P&gt;For anyone facing the same issue, I added this to my code (feel free to give me tips as I never truly learned how to code):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;selection = list(uidoc.Selection.GetElementIds())
for e_id in selection:
    e = doc.GetElement(e_id)
    if isinstance(e, FamilyInstance):
        subcomponents = e.GetSubComponentIds()
        selection.extend(subcomponents)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 06:44:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/override-in-view-doesn-t-work-on-nested-families-with-revit-api/m-p/12859473#M4508</guid>
      <dc:creator>PieterL_TM</dc:creator>
      <dc:date>2024-06-25T06:44:31Z</dc:date>
    </item>
  </channel>
</rss>

