/// <summary> /// Override the element's color in the active view. /// </summary> /// <param name="color">The color to apply to a solid fill on the element.</param> public void OverrideColorInView(Color color) { TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); var view = DocumentManager.Instance.CurrentUIDocument.ActiveView; var ogs = new OverrideGraphicSettings(); var patternCollector = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); patternCollector.OfClass(typeof(FillPatternElement)); FillPatternElement solidFill = patternCollector.ToElements().Cast <FillPatternElement>().First(x => x.GetFillPattern().Name == "Solid fill"); ogs.SetProjectionFillColor(new Autodesk.Revit.DB.Color(color.Red, color.Green, color.Blue)); ogs.SetProjectionFillPatternId(solidFill.Id); view.SetElementOverrides(this.InternalElementId, ogs); TransactionManager.Instance.TransactionTaskDone(); }
/// <summary> /// Gets the brightness value for this color. /// </summary> /// <returns name="val">Brightness value for the color.</returns> public static float Brightness(Color c) { return c.color.GetBrightness(); }
protected bool Equals(Color other) { return color.Equals(other.color); }
public static Color BuildColorFromRange(Color start, Color end, double value) { var selRed = (int)(start.Red + (end.Red - start.Red) * value); var selGreen = (int)(start.Green + (end.Green - start.Green) * value); var selBlue = (int)(start.Blue + (end.Blue - start.Blue) * value); return ByARGB(255, selRed, selGreen, selBlue); }
public static Dictionary<string, byte> Components(Color c) { return new Dictionary<string, byte> { {"a", c.color.A}, {"r", c.color.R}, {"g", c.color.G}, {"b", c.color.B}, }; }
/// <summary> /// Gets the hue value for this color. /// </summary> /// <returns name="val">Hue value for the color.</returns> public static float Hue(Color c) { return c.color.GetHue(); }
/// <summary> /// Gets the saturation value for this color. /// </summary> /// <returns name="val">Saturation value for the color.</returns> public static float Saturation(Color c) { return c.color.GetSaturation(); }
/// <summary> /// Override the element's color in the active view. /// </summary> /// <param name="color">The color to apply to a solid fill on the element.</param> public Element OverrideColorInView(Color color) { TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); var view = DocumentManager.Instance.CurrentUIDocument.ActiveView; var ogs = new OverrideGraphicSettings(); var patternCollector = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); patternCollector.OfClass(typeof(FillPatternElement)); FillPatternElement solidFill = patternCollector.ToElements().Cast<FillPatternElement>().First(x => x.GetFillPattern().Name == "Solid fill"); ogs.SetProjectionFillColor(new Autodesk.Revit.DB.Color(color.Red, color.Green, color.Blue)); ogs.SetProjectionFillPatternId(solidFill.Id); view.SetElementOverrides(this.InternalElementId, ogs); TransactionManager.Instance.TransactionTaskDone(); return this; }