Change Autodesk.Revit.DB.Color to DSCore.Color

Hello,
I tried to place color palette nodes in a user interface (I couldn’t)
Therefore I went through a color pickup, is it possible to recover (the a,r,g,b of Autodesk.Revit.Db.Color)
Thanks in advance for the help provided.

Cordially
christian.stan

1 Like

There is no alpha, it’s always 255.

The Red, Green and Blue values are properties of a color in the Revit API. So assuming you have the proper imports, you can try this:

colors = IN[0]
rgbValues = [c.Red, c.Green, c.Blue for c in colors]
OUT = rgbValues

If you import the DSCore module as well, you can then directly generate the Dynamo color values. SOmething like this:

#Standard imports here
clr.AddReference('DSCoreNodes')
import DSCore
revitColors = IN[0]
dynamoColors = [ DSCore.Color.ByARGB(255, c.Red, c.Green, c.Blue) for c in revitColors ]
OUT = dynamoColors
3 Likes

Hi Christan it normally work for me i jthink you just need a pattern as well…edit saw you already has a pattern :slight_smile: hmmmm strange then

1 Like

Hello,
Thank you very much it works wonderfully :ok_hand: (can only be done in python?)

Cordially
christian.stan

Hello,
I am under the Revit 2020 version, it may be from this state (Thank you @ you).

Cordially
christian.stan

1 Like

There may be a Revit.Color class somewhere, but I haven’t come across it. Genius Loci package, or another package which deals with materials may have something. I am 90% certain it isn’t in the Revit section of the library, which means I am 90% certain that some type of custom code would be required, be it Python or a zero touch node.

Whenever I have needed to convert colors between applications I have just done the above in my code base, as it’s simple enough that it doesn’t necessarily slow down efforts, while moving along an extra node or two might…

1 Like

dragging up an old thread so I dont have to make a new one- Im a python noob, when I run this I get an iteration over non sequence error. Im kinda stuck in a graph where i need to convert a revit color to a dscore color. help ^^ :slight_smile:

Please start a new thread and include a sample graph with the python so we can reproduce.

By the sound of it you’re passing a null object, so check inputs and data retrieved first.

1 Like

Wait, I have noticed my python scripts execute before my graph, this might be the issue, because I am passing it a revitDB color from a Datashapes UI. will post tho.