/// <summary> /// Sets the color of the Material. /// </summary> /// <param name="material">Material to set the Color for.</param> /// <param name="color">Color to set the Material to.</param> /// <returns>Material with the adjusted color.</returns> public static Material SetColor(Material material, Color color) { if (material == null) { throw new ArgumentNullException(nameof(material)); } if (color == null) { throw new ArgumentNullException(nameof(color)); } if (!(material.InternalElement is Autodesk.Revit.DB.Material m)) { throw new ArgumentNullException(nameof(material)); } var c = new Autodesk.Revit.DB.Color(color.Red, color.Green, color.Blue); var doc = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(doc); m.Color = c; TransactionManager.Instance.TransactionTaskDone(); return(material); }
/// <summary> /// Sets the Diffuse Color property for the Appearance Asset inside of the Material. /// </summary> /// <param name="appearanceAsset">Appearance Asset to set the color for.</param> /// <param name="color">Color that property will be set to.</param> /// <returns>Appearance Asset with the adjusted color property.</returns> public static Element SetDiffuseColor(Element appearanceAsset, Color color) { if (appearanceAsset == null) { throw new ArgumentNullException(nameof(appearanceAsset)); } if (color == null) { throw new ArgumentNullException(nameof(color)); } var aa = appearanceAsset.InternalElement as Autodesk.Revit.DB.AppearanceAssetElement; var c = new Autodesk.Revit.DB.Color(color.Red, color.Green, color.Blue); var doc = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(doc); using (var editScope = new Autodesk.Revit.DB.Visual.AppearanceAssetEditScope(doc)) { var editableAsset = editScope.Start(aa.Id); var diffuseProperty = editableAsset.FindByName("generic_diffuse") as Autodesk.Revit.DB.Visual.AssetPropertyDoubleArray4d; diffuseProperty.SetValueAsColor(c); editScope.Commit(true); } TransactionManager.Instance.TransactionTaskDone(); return(aa.ToDSType(true)); }
public void add(Autodesk.Revit.DB.Color c) { if (c == null) { add(0); add(0); add(0); } else { add(c.Red); add(c.Green); add(c.Blue); } }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { object result = new Autodesk.Revit.DB.Color(255, 0, 0); if (value != null) { try { System.Windows.Media.Brush wpf = value as System.Windows.Media.Brush; var colorSystem = ((SolidColorBrush)wpf).Color; result = new Autodesk.Revit.DB.Color(colorSystem.R, colorSystem.G, colorSystem.B); return(result); } catch { } } return(result); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { object result = System.Windows.Media.Brushes.Red; if (value != null) { try { ColorRevit rvt = value as ColorRevit; System.Drawing.Color colorSystem = System.Drawing.Color.FromArgb(rvt.Red, rvt.Green, rvt.Blue); result = new SolidColorBrush(System.Windows.Media.Color.FromArgb(colorSystem.A, colorSystem.R, colorSystem.G, colorSystem.B)); return(result); } catch { } } return(result); }
public ColorChoiceForm(IList <Objects.Change.ChangeTypeEnum> types) { InitializeComponent(); treeView1.CheckBoxes = true; _root = treeView1.Nodes.Add("Change Type(s)"); foreach (var typ in types) { TreeNode tn = _root.Nodes.Add(typ.ToString(), typ.ToString()); tn.Tag = typ; Autodesk.Revit.DB.Color c = Utilities.Settings.GetColor(typ); tn.BackColor = Color.FromArgb(c.Red, c.Green, c.Blue); tn.Checked = true; } _root.ExpandAll(); }
/// <summary> /// Convert Revit to DS Color /// </summary> /// <param name="color"></param> /// <returns></returns> private DSCore.Color ToDSColor(Autodesk.Revit.DB.Color color) { return(DSCore.Color.ByARGB(255, color.Red, color.Green, color.Blue)); }
/// <summary> /// /// </summary> /// <param name="color"></param> /// <returns></returns> public static string GetColor(Autodesk.Revit.DB.Color color) { return($"Color(Red = {color.Red}, Green = {color.Green}, Blue = {color.Blue}, Alpha = 255)"); }
public ColorData(string label, Color color) : base(label) { _color = color; }
public Color(string label, Autodesk.Revit.DB.Color color) : base(label) { m_color = color; }
/// <summary> /// /// </summary> /// <param name="color"></param> /// <returns></returns> public static Color DsColorByColor(Autodesk.Revit.DB.Color color) { return(!color.IsValid ? null : Color.ByARGB(255, color.Red, color.Green, color.Blue)); }
/// <summary> /// Creates a new wrapper for a Revit color /// </summary> /// <param name="color">A Revit Color</param> /// <returns name="color">A wrapped Revit color.</returns> public static ColorWrapper Wrap(RevitColor color) { return(new ColorWrapper(color)); }
internal ColorWrapper(RevitColor _revitColor) { this.revitColor = _revitColor; }