<?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 Update ColorFillScheme Entry (Revit 2022) in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10577242#M24116</link>
    <description>&lt;P&gt;Hi everyone! I’m trying to update a ColorSchemeEntry. I’ve grabbed the scheme, and the entry, and I’ve changed the color, but running scheme.UpdateEntry(entry) in a transaction doesn’t seem to do anything. I understand color schemes are updated asynchronously, so is there some way to entice Revit to update? (I've read over the api docs remarks, they're slightly confusing: &lt;A href="https://www.revitapidocs.com/2022/c405eb5b-14fa-0fea-a750-dcd9925a90b0.htm" target="_blank" rel="noopener"&gt;ColorFillScheme Class on revitapidocs&lt;/A&gt;&amp;nbsp;).&lt;BR /&gt;&lt;BR /&gt;Code below shows where the magic (should) happen. I’ve tested before and after the "entry.Color = DB.Color" line and the color is definitely being changed, it’s just not being updated in the scheme. I'm not getting any errors, the transaction commits, but the scheme doesn't seem to update. &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;scheme.CanUpdateEntry(entry) passes as well, so I’m allowed to update the entry… any ideas are welcome and appreciated! Oh yeah, this forum post got me where I am now, it was very helpful! Thanks sofia! &lt;A href="https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/td-p/10432787" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/td-p/10432787&lt;/A&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;LI-CODE lang="general"&gt;with DB.Transaction(doc, 'Update {} Color'.format(entry_name)) as t:
        t.Start()
        entry.Color = DB.Color(color.red, color.green, color.blue)
        if scheme.CanUpdateEntry(entry):
            scheme.UpdateEntry(entry)
        t.Commit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Aug 2021 02:14:52 GMT</pubDate>
    <dc:creator>sdcartmell</dc:creator>
    <dc:date>2021-08-27T02:14:52Z</dc:date>
    <item>
      <title>Update ColorFillScheme Entry (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10577242#M24116</link>
      <description>&lt;P&gt;Hi everyone! I’m trying to update a ColorSchemeEntry. I’ve grabbed the scheme, and the entry, and I’ve changed the color, but running scheme.UpdateEntry(entry) in a transaction doesn’t seem to do anything. I understand color schemes are updated asynchronously, so is there some way to entice Revit to update? (I've read over the api docs remarks, they're slightly confusing: &lt;A href="https://www.revitapidocs.com/2022/c405eb5b-14fa-0fea-a750-dcd9925a90b0.htm" target="_blank" rel="noopener"&gt;ColorFillScheme Class on revitapidocs&lt;/A&gt;&amp;nbsp;).&lt;BR /&gt;&lt;BR /&gt;Code below shows where the magic (should) happen. I’ve tested before and after the "entry.Color = DB.Color" line and the color is definitely being changed, it’s just not being updated in the scheme. I'm not getting any errors, the transaction commits, but the scheme doesn't seem to update. &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;scheme.CanUpdateEntry(entry) passes as well, so I’m allowed to update the entry… any ideas are welcome and appreciated! Oh yeah, this forum post got me where I am now, it was very helpful! Thanks sofia! &lt;A href="https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/td-p/10432787" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/td-p/10432787&lt;/A&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;LI-CODE lang="general"&gt;with DB.Transaction(doc, 'Update {} Color'.format(entry_name)) as t:
        t.Start()
        entry.Color = DB.Color(color.red, color.green, color.blue)
        if scheme.CanUpdateEntry(entry):
            scheme.UpdateEntry(entry)
        t.Commit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 02:14:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10577242#M24116</guid>
      <dc:creator>sdcartmell</dc:creator>
      <dc:date>2021-08-27T02:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Update ColorFillScheme Entry (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10577757#M24117</link>
      <description>&lt;P&gt;Some Revit database modifications do not take effect until the command has terminated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the worst case, some modification are ignored until Revit itself 'touches' the modified object in some way or other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you found any possibility to interact with the colour scheme in the UI that triggers Revit to realise that it has been updated?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If nothing else helps, I would suggest creating a complete minimal self-contained reproducible case for the development team to analyse:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 07:53:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10577757#M24117</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-08-27T07:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Update ColorFillScheme Entry (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10606444#M24118</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for getting back to me and sorry for my delayed reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am investigating options set the color scheme to a view in the background or to place a color scheme legend on a view before or after making the entry color change to get revit to recognize the change. I might also try deleting the old entry and creating a new entry with the new color, though that seems like an extreme workaround.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't yet tried to create a minimal self-contained reproducible case as described on your website because of the dependencies I am using my script, but if I continue to hit a wall I will attempt to make a simplified macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you or anyone else is interested in looking into this, here's the script workflow:&lt;BR /&gt;&lt;BR /&gt;List Color Schemes for user&lt;BR /&gt;&amp;gt; User selects scheme&lt;/P&gt;&lt;P&gt;List Entries of selected Scheme for user&lt;/P&gt;&lt;P&gt;&amp;gt; User selects Entry to update&lt;/P&gt;&lt;P&gt;List set of company-vetted colors&lt;/P&gt;&lt;P&gt;&amp;gt; User selects new color for entry&lt;/P&gt;&lt;P&gt;Apply new color to entry and update entry in scheme&lt;/P&gt;&lt;P&gt;Repeat or Exit&lt;BR /&gt;&lt;BR /&gt;Obviously a simplified version could just grab the first scheme and the first entry and then set the selected entry to black solid fill or something easily noticeable to demonstrate a change in the entry.&lt;BR /&gt;&lt;BR /&gt;Thanks for your time.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 20:12:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10606444#M24118</guid>
      <dc:creator>sdcartmell</dc:creator>
      <dc:date>2021-09-07T20:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Update ColorFillScheme Entry (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10608250#M24119</link>
      <description>&lt;P&gt;I got it after tinkering. I totally avoided UpdateEntry as it didn't seem to actually do anything. Here's the workflow (new stuff in &lt;STRONG&gt;bold&lt;/STRONG&gt; )&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;List Color Schemes for user&lt;BR /&gt;&amp;gt; User selects scheme&lt;/P&gt;&lt;P&gt;List Entries of selected Scheme for user&lt;/P&gt;&lt;P&gt;&amp;gt; User selects Entry to update&lt;/P&gt;&lt;P&gt;List set of company-vetted colors&lt;/P&gt;&lt;P&gt;&amp;gt; User selects new color for entry&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Behind the scenes:&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Collect info from old entry&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Collect rooms (or spaces) that have parameter associated with entry&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Clear content from Parameter in Rooms (or spaces) to free up entry so it can be removed&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Remove Entry&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Create New Entry with existing info and new color&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;Set content of Parameter in Rooms (or spaces) to associate them with Entry&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the python code of that Behind the Scenes bit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with revit.TransactionGroup('Update {} Color'.format(entry_name)):
    #get info from entry
    sname  = selected.GetStringValue()
    stype  = selected.StorageType
    fpatId = selected.FillPatternId 
            
    #get rooms that have this entry
    rooms = get_dept_match_rooms(entry_name, get_rooms())
            
    #clear param to 'free up' entry for deletion
    #transaction, exit on failure
    delete_department(entry_name, rooms) 
            
    #remove entry
    if scheme.CanRemoveEntry(selected):
        #transaction, exit on failure
        remove_entry(scheme, selected) 
            
    #make new entry with new color (or other info)
    #transaction, exit on failure
    make_entry(scheme, stype, fpatId, color, sname) 
            
    #set those rooms back to have correct dept
    set_room_dept(rooms, entry_name) #transaction&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 14:06:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10608250#M24119</guid>
      <dc:creator>sdcartmell</dc:creator>
      <dc:date>2021-09-08T14:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update ColorFillScheme Entry (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10657972#M24120</link>
      <description>&lt;P&gt;Here is a method that you can use without needing to delete and add, but the entry can't be in use. So you would have to remove it still from Rooms, but I think that is just the name, the color I don't think would do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how to update the color:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;scheme = UnwrapElement(IN[0])

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
entries = scheme.GetEntries()
update = []
for entry in entries:
    clr = Color(125,125,125)
    entry.Color = clr
    scheme.UpdateEntry(entry)
TransactionManager.Instance.TransactionTaskDone()

OUT = scheme&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#My input here in a single ColorFillScheme
scheme = UnwrapElement(IN[0])
#Get all Entries from Scheme
entires = scheme.GetEntries()
#Empty List to store upated entries
update = []
#Loop each entry (Test Case here so all of them)
for entry in entries:
    #I am trying to update the name, but othe props would be same
    name = entry.GetStringValue()
    name += " TEST"
    #Set the New Value on the entity
    entry.SetStringValue(name)
    #The SetEntries() method takes a List of Entries so that why we use this
    update.append(entry)
TransactionManager.Instance.TransactionTaskDone()
#This will update values of the entries including the name or color values.
OUT = scheme.SetEntries(update)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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="spage_0-1633008442165.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/971782iACD0EFECCE1511A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="spage_0-1633008442165.png" alt="spage_0-1633008442165.png" /&gt;&lt;/span&gt;&lt;/P&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="spage_1-1633008477915.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/971783iE5CB2893B6603300/image-size/medium?v=v2&amp;amp;px=400" role="button" title="spage_1-1633008477915.png" alt="spage_1-1633008477915.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 13:42:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/10657972#M24120</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2021-09-30T13:42:20Z</dc:date>
    </item>
    <item>
      <title>Betreff: Update ColorFillScheme Entry (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/11348183#M24121</link>
      <description>&lt;P&gt;I came across this post after struggling to modify&amp;nbsp;&lt;SPAN&gt;ColorFillScheme elements. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It does seem possible to update entities, even if they are in use.&amp;nbsp; As spage posted - you can use the SetEntries method. The trick is to collect all entities (even if they aren't modified) in a list and use this in the argument (i.e. - colorscheme.SetEntries( colorscheme.GetEntries()) doesn't do anything). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;UpdateEntry either throws an error or doesn't change anything.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's some example code and the results:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (Transaction trans = new Transaction(doc, "tmp"))&lt;BR /&gt;{&lt;BR /&gt;trans.Start();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var list = new List&amp;lt;ColorFillSchemeEntry&amp;gt;();&lt;/P&gt;&lt;P&gt;foreach (var e in colorscheme.GetEntries())&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;var val = e.GetStringValue();&lt;/P&gt;&lt;P&gt;if (val == "A")&lt;BR /&gt;{&lt;BR /&gt;e.Color = new Color(255, 0, 0);&lt;BR /&gt;e.FillPatternId = patternid;&lt;BR /&gt;}&lt;BR /&gt;else if (val == "B")&lt;BR /&gt;{&lt;BR /&gt;e.IsVisible = false;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;list.Add(e);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;colorscheme.SetEntries(list);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;trans.Commit();&lt;/P&gt;&lt;P&gt;}&lt;/P&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="Unbenannt.PNG" style="width: 831px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1101878iD783C750D4EE94A9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt.PNG" alt="Unbenannt.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unbenannt1.PNG" style="width: 812px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1101880i053F67E12024D049/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unbenannt1.PNG" alt="Unbenannt1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 08:36:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/update-colorfillscheme-entry-revit-2022/m-p/11348183#M24121</guid>
      <dc:creator>cig_ad</dc:creator>
      <dc:date>2022-08-09T08:36:43Z</dc:date>
    </item>
  </channel>
</rss>

