Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
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:
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<ColorFillScheme>()
.Where(c => 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();
}
Using this code, I'm getting an error on colorScheme.AddEntry(entry): "The entry value is out of range. Parameter name: colorFillData". I can't find that parameter neither on the color scheme nor the entry. Anyone knows how to fix this?
Thanks,
Sofia
Solved! Go to Solution.