<?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: Creating Color Schemes through the API (Revit 2022) in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13636508#M25069</link>
    <description>&lt;P&gt;Hi Sofia,&lt;BR /&gt;&lt;BR /&gt;Hopefully not too late for an answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;One issue with the above code is the storage type assignment on the area scheme entry.&lt;BR /&gt;There is some autodesk sample code provided&lt;A href="https://help.autodesk.com/view/RVT/2023/ITA/?guid=Revit_API_Revit_API_Developers_Guide_Revit_Geometric_Elements_Annotation_Elements_Color_Fill_html" target="_blank" rel="noopener"&gt; here&lt;/A&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This row (in this case it storing it as a string)&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;ColorFillSchemeEntry&lt;/SPAN&gt;&lt;SPAN class=""&gt; entry &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;ColorFillSchemeEntry&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;StorageType&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;String&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I'm not sure as to whether the ColorFillScheme itself got a storage type (as per your code)&lt;BR /&gt;&lt;BR /&gt;I tried the above and that works...However, you need to ensure that the entry you are adding actually has a value set. In my case it was empty, and I got the same error message...why I ended up here in the first place&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ahhhh didnt see all the answers above ... ignore&lt;/P&gt;</description>
    <pubDate>Mon, 19 May 2025 01:02:10 GMT</pubDate>
    <dc:creator>jchristel9Y7MH</dc:creator>
    <dc:date>2025-05-19T01:02:10Z</dc:date>
    <item>
      <title>Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10432787#M25059</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how to create a color scheme through the newly developed Color Fill API for Revit 2022 but I'm not sure what I'm doing wrong. Here's a snippet of my code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (Transaction t = new Transaction(doc))
{
                t.Start("Create Color Scheme");
                Category roomCategory = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Rooms);

                // Create Color Scheme by duplicating an existing one 
                // (randomly chosen from category: Room)
                var firstOrDefaultColorScheme = new FilteredElementCollector(doc)
                    .OfCategory(BuiltInCategory.OST_ColorFillSchema)
                    .Cast&amp;lt;ColorFillScheme&amp;gt;()
                    .Where(c =&amp;gt; c.CategoryId == roomCategory.Id)
                    .FirstOrDefault();

                ElementId newColorSchemeId = firstOrDefaultColorScheme.Duplicate("Name");
                ColorFillScheme colorScheme = doc.GetElement(newColorSchemeId) as ColorFillScheme;

                // Create entry
                ColorFillSchemeEntry entry = new ColorFillSchemeEntry(colorScheme.StorageType);
                entry.Caption = "Entry Caption";
                entry.Color = new Color(0, 0, 0);
                colorScheme.AddEntry(entry);

                // Apply color scheme to view
                View currentView = uiapp.ActiveUIDocument.ActiveView;
                currentView.SetColorFillSchemeId(roomCategory.Id, colorScheme.Id);
                t.Commit();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using this code, I'm getting an error on colorScheme.AddEntry(entry): "The entry value is out of range.&amp;nbsp;Parameter name: colorFillData". I can't find that parameter neither on the color scheme nor the entry. Anyone knows how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sofia&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 15:28:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10432787#M25059</guid>
      <dc:creator>sofia_feist</dc:creator>
      <dc:date>2021-06-30T15:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10433152#M25060</link>
      <description>&lt;P&gt;Turns out, I was missing two things: the error was due to the fact that I never gave a value to the&amp;nbsp;color scheme entry and if you want the colors to actually show in the view, you also have to specify the fill pattern. In sum, here is the working code for someone looking to do something similar:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (Transaction t = new Transaction(doc))
{
                t.Start("Create Color Scheme");
                Category roomCategory = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Rooms);

                // Create Color Scheme by duplicating an existing one 
                // (randomly chosen from category: Room)
                var firstOrDefaultColorScheme = new FilteredElementCollector(doc)
                    .OfCategory(BuiltInCategory.OST_ColorFillSchema)
                    .Cast&amp;lt;ColorFillScheme&amp;gt;()
                    .Where(c =&amp;gt; c.CategoryId == roomCategory.Id)
                    .FirstOrDefault();

                ElementId newColorSchemeId = firstOrDefaultColorScheme.Duplicate("Name");
                ColorFillScheme colorScheme = doc.GetElement(newColorSchemeId) as ColorFillScheme;

                var solidPattern = new FilteredElementCollector(doc)
                    .OfClass(typeof(FillPatternElement))
                    .Cast&amp;lt;FillPatternElement&amp;gt;()
                    .First(a =&amp;gt; a.GetFillPattern().IsSolidFill == true); ;

                // Create entry
                ColorFillSchemeEntry entry = new ColorFillSchemeEntry(StorageType.Integer);
                entry.Caption = "Entry Caption";
                entry.Color = new Color(0, 0, 0);
                entry.FillPatternId = solidPattern.Id;
                entry.SetIntegerValue(1);
                colorScheme.AddEntry(entry);

                // Apply color scheme to view
                View currentView = uiapp.ActiveUIDocument.ActiveView;
                currentView.SetColorFillSchemeId(roomCategory.Id, colorScheme.Id);
                t.Commit();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sofia&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 17:52:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10433152#M25060</guid>
      <dc:creator>sofia_feist</dc:creator>
      <dc:date>2021-06-30T17:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10682423#M25061</link>
      <description>&lt;P&gt;After a day trawling the internet to find a way to create a new ColorFillScheme and add it to the current view, this was extremely helpful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only thing I'm now battling with is figuring out how to change the variable that the ColorFillLegend is looking at to assign colors based on the ColorFillScheme. Any clue how to to this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;Tomé&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 08:43:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10682423#M25061</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-12T08:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10682979#M25062</link>
      <description>&lt;P&gt;Hello&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't have to use &lt;SPAN&gt;ColorFillLegends in my code so I'm not entirely sure but one thing that is missing from my code above (that I found out later) is that, if you have a specific parameter you want to assign the color scheme to, you can assign it using:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;colorScheme.ParameterDefinition = parameter.Id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After that, you just have to make sure that all ColorFillSchemeEntries have the same storageType as the given parameter.&lt;BR /&gt;&lt;BR /&gt;I hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Sofia&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 12:53:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10682979#M25062</guid>
      <dc:creator>sofia_feist</dc:creator>
      <dc:date>2021-10-12T12:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683029#M25063</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9301687"&gt;@sofia_feist&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I got to that in the end. You can also check what parameters you can use with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;colorScheme.GetSupportedParameterIds()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, I'm searching through the parameters and selecting the one I want by name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;selected_parId = None
for parId in colorScheme.GetSupportedParameterIds():
    par = doc.GetElement(parId)
    if par is not None:
        if par.GetDefinition().Name == selected_name:
            selected_parId = parId

colorScheme.ParameterDefinition = selected_parId&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm now more worried about if there is no default color scheme available in the model, then there's nothing to .Duplicate from. But I guess I'll get there when I do!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers once again for your help!&lt;/P&gt;&lt;P&gt;Tomé&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 13:10:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683029#M25063</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-12T13:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683035#M25064</link>
      <description>I'm also coding in python, not C#, but the syntax is very very similar...</description>
      <pubDate>Tue, 12 Oct 2021 13:11:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683035#M25064</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-12T13:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683333#M25065</link>
      <description>&lt;P&gt;I understand what you mean; I would love to have the option of creating a new color scheme without duplicating an existing one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, Revit templates usually come with 1 or more default colorScheme templates for each category since, even in the UI, there is no way to create a new color scheme without duplicating an existing one. You also cannot delete the last color scheme if only one exists so there should always be at least one color scheme to duplicate from. That shouldn't be a problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The properties of the old color scheme are also overriden when you change the parameter definition so you can basically start from scratch.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 14:54:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683333#M25065</guid>
      <dc:creator>sofia_feist</dc:creator>
      <dc:date>2021-10-12T14:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683364#M25066</link>
      <description>&lt;P&gt;Oh that's very good to know!&lt;/P&gt;&lt;P&gt;You've saved my day! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 15:08:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/10683364#M25066</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-12T15:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13603836#M25067</link>
      <description>&lt;P&gt;Is this the complete code?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 13:04:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13603836#M25067</guid>
      <dc:creator>mofalk9CB4P</dc:creator>
      <dc:date>2025-04-28T13:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13615789#M25068</link>
      <description>&lt;P&gt;For creating a new color scheme of storage type integer with a singular entry, yes.&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 10:29:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13615789#M25068</guid>
      <dc:creator>sofia_feist</dc:creator>
      <dc:date>2025-05-06T10:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Color Schemes through the API (Revit 2022)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13636508#M25069</link>
      <description>&lt;P&gt;Hi Sofia,&lt;BR /&gt;&lt;BR /&gt;Hopefully not too late for an answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;One issue with the above code is the storage type assignment on the area scheme entry.&lt;BR /&gt;There is some autodesk sample code provided&lt;A href="https://help.autodesk.com/view/RVT/2023/ITA/?guid=Revit_API_Revit_API_Developers_Guide_Revit_Geometric_Elements_Annotation_Elements_Color_Fill_html" target="_blank" rel="noopener"&gt; here&lt;/A&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This row (in this case it storing it as a string)&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;ColorFillSchemeEntry&lt;/SPAN&gt;&lt;SPAN class=""&gt; entry &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;ColorFillSchemeEntry&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;StorageType&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;String&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I'm not sure as to whether the ColorFillScheme itself got a storage type (as per your code)&lt;BR /&gt;&lt;BR /&gt;I tried the above and that works...However, you need to ensure that the entry you are adding actually has a value set. In my case it was empty, and I got the same error message...why I ended up here in the first place&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ahhhh didnt see all the answers above ... ignore&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 01:02:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-color-schemes-through-the-api-revit-2022/m-p/13636508#M25069</guid>
      <dc:creator>jchristel9Y7MH</dc:creator>
      <dc:date>2025-05-19T01:02:10Z</dc:date>
    </item>
  </channel>
</rss>

