mastoron.colors¶
- class Color[source]¶
Bases:
objectClass for basic color operations.
- static HEXtoRGB(hex)[source]¶
Converts a hex color string to rgb.
- Parameters
hex (sting) – The hex color
- Returns
The rgb color
- Return type
tuple
- class ColorRange(count, min=0, max=100)[source]¶
Bases:
objectClass for working with color ranges.
- class ColorScheme[source]¶
Bases:
objectClass for handling relationships between labels and colors.
- JSON_PATH = 'C:\\temp\\mastoron\\colorscheme.json'¶
- static apply(view, elements, schemeName, isInstance, type, patternId)[source]¶
Applies a mastoron color scheme to given elements in given view. Updates the colors scheme with new keys and colors.
- Parameters
view (object) – A Revit view
elements (object) – A list of Revit elements
schemeName (string) – The name of the color scheme
isInstance (bool) – True for instance parameters, false for type parameters
type (string) – The type of the parameter (Area, Number, Length, etc..)
patternId (object) – The Revit element id of the fillpattern to use
- Returns
The applied and updated color scheme
- Return type
dict
- delete(scheme)[source]¶
Deletes a color scheme from the revitron DocumenConfigStorage.
- Parameters
scheme (dict) – A color scheme
- static fromJSON(path)[source]¶
Reads a color scheme from json.
- Parameters
path (string) – The json file
- Returns
The color scheme
- Return type
dict
- generate(schemeName, keys, isInstance=None, paramType=None, excludeColors=None, gradient=False)[source]¶
Generates a new color scheme.
- Parameters
schemeName (string) – The name of the color scheme
keys (string) – A set of keys
excludeColors (string, optional) – A list of colors to exclude
gradient (int, optional) – A tuple with start and end color
- Returns
A color scheme: {name: schemeName, data: {key: color}}
- Return type
dict
- getColors(count, excludeColors=[])[source]¶
Gets a given amount of colors.
- Parameters
count (int) – The number of colors to get
excludeColors (string, optional) – List of colors to exclude. Defaults to None.
- Returns
A list of colors
- Return type
string
- static getFromUser(excludeSchemes=None, excludeViews=None)[source]¶
Asks the user to select a mastoron color scheme.
- Parameters
excludeSchemes (string, optional) – The name of one or more schemes to exclude. Defaults to None.
excludeViews (string, optional) – The id(s) of one ore more views to exclude. Defaults to None.
- Returns
The selected mastoron color scheme
- Return type
dict
- load(schemeName)[source]¶
Loads a color scheme by name.
- Parameters
schemeName (string) – The name of the color scheme
- Returns
The color scheme
- Return type
dict
- save(scheme)[source]¶
Saves a color scheme to the revitron DocumentConfigStorage.
- Parameters
scheme (dict) – A color scheme