/// <summary> /// Metodo che cambia il colore dei Pannelli nel colore BIANCO /// </summary> /// <remarks> /// </remarks> /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m> /// private void ChangeColorToBlank(UIApplication uiapp) { using (Transaction trans = new Transaction(uiapp.ActiveUIDocument.Document)) { trans.Start("Change Color"); foreach (Element ele in _elements) { // Metodo per la trasformazione del colore da System.Drawing.Color a Autodesk.Revit.DB.Color System.Drawing.Color colorToConvert = new System.Drawing.Color(); colorToConvert = System.Drawing.Color.FromName("White"); Autodesk.Revit.DB.Color newColor = new Autodesk.Revit.DB.Color(colorToConvert.R, colorToConvert.G, colorToConvert.B); // Assegna il nuovo colore all'elemento di override delle impostazioni grafiche _ogs.SetSurfaceForegroundPatternColor(newColor); _ogs.SetSurfaceForegroundPatternVisible(true); // Estrae il valore Id per settare il Pattern come Solid FIll(Riempimento) FilteredElementCollector elements = new FilteredElementCollector(uiapp.ActiveUIDocument.Document); FillPatternElement solidFillPattern = elements.OfClass(typeof(FillPatternElement)) .Cast <FillPatternElement>() .First(a => a.GetFillPattern().IsSolidFill); ElementId solidFillPatternId = null; if (solidFillPattern.GetFillPattern().IsSolidFill) { solidFillPatternId = solidFillPattern.Id; } // Imposta l'elemento come Solid Fill _ogs.SetSurfaceForegroundPatternId(solidFillPatternId); // Fa l'override delle impostazioni grafiche dell'elemento uiapp.ActiveUIDocument.Document.ActiveView.SetElementOverrides(ele.Id, _ogs); //Autodesk.Revit.DB.Color colorForeground = el.Category.Material.SurfaceForegroundPatternColor; Autodesk.Revit.DB.Color colorForegroundOGS = _ogs.SurfaceForegroundPatternColor; } trans.Commit(); } //// Refresha la View attiva in modo da attivare il cambiamento //uiapp.ActiveUIDocument.RefreshActiveView(); }
private void SettingBtn_Click(object sender, EventArgs e) { SettingForm form = new SettingForm(WriteParms.Text); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { foreach (var item in form.GetParamSettingColor()) { if (!m_instance.m_paramColor.ContainsKey(item.Key)) { System.Drawing.Color dialogColor = item.Value; Autodesk.Revit.DB.Color color = new Autodesk.Revit.DB.Color(dialogColor.R, dialogColor.G, dialogColor.B); m_instance.m_paramColor.Add(item.Key, color); } } } }
public static Color material_color(Color color) { try { if (color == null) { return(Source.material_color); } else if (color.Red == 0 && color.Green == 0 && color.Blue == 0) { return(Source.material_color); } else { return(color); } } catch (Exception) { return(Source.material_color); } }
public static Color ChangeColorBrightness(Color color, float correctionFactor) { float red = (float)color.Red; float green = (float)color.Green; float blue = (float)color.Blue; if (correctionFactor < 0) { correctionFactor = 1 + correctionFactor; red *= correctionFactor; green *= correctionFactor; blue *= correctionFactor; } else { red = (255 - red) * correctionFactor + red; green = (255 - green) * correctionFactor + green; blue = (255 - blue) * correctionFactor + blue; } Color myColorReturn = new Autodesk.Revit.DB.Color((byte)red, (byte)green, (byte)blue); return(myColorReturn); }
/// <summary> /// Gets material handle from material id or creates one if there is none. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="materialId">The material id.</param> /// <returns>The handle.</returns> public static IFCAnyHandle GetOrCreateMaterialHandle(ExporterIFC exporterIFC, ElementId materialId) { Document document = ExporterCacheManager.Document; IFCAnyHandle materialNameHandle = ExporterCacheManager.MaterialHandleCache.Find(materialId); if (IFCAnyHandleUtil.IsNullOrHasNoValue(materialNameHandle)) { string materialName = " <Unnamed>"; string description = null; string category = null; if (materialId != ElementId.InvalidElementId) { Material material = document.GetElement(materialId) as Material; if (material != null) { materialName = NamingUtil.GetNameOverride(material, material.Name); } if (ExporterCacheManager.ExportOptionsCache.ExportAs4) { category = NamingUtil.GetOverrideStringValue(material, "IfcCategory", NamingUtil.GetOverrideStringValue(material, "Category", material.MaterialCategory)); description = NamingUtil.GetOverrideStringValue(material, "IfcDescription", null); } } materialNameHandle = IFCInstanceExporter.CreateMaterial(exporterIFC.GetFile(), materialName, description: description, category: category); ExporterCacheManager.MaterialHandleCache.Register(materialId, materialNameHandle); // associate Material with SurfaceStyle if necessary. IFCFile file = exporterIFC.GetFile(); if (materialId != ElementId.InvalidElementId && !ExporterCacheManager.ExportOptionsCache.ExportAs2x2 && materialNameHandle.HasValue) { HashSet <IFCAnyHandle> matRepHandles = IFCAnyHandleUtil.GetHasRepresentation(materialNameHandle); if (matRepHandles.Count == 0) { Material matElem = document.GetElement(materialId) as Material; // TODO_DOUBLE_PATTERN - deal with background pattern ElementId fillPatternId = (matElem != null) ? matElem.CutPatternId : ElementId.InvalidElementId; Autodesk.Revit.DB.Color color = (matElem != null) ? GetSafeColor(matElem.CutPatternColor) : new Color(0, 0, 0); double planScale = 100.0; HashSet <IFCAnyHandle> styles = new HashSet <IFCAnyHandle>(); bool hasFill = false; IFCAnyHandle styledRepItem = null; IFCAnyHandle matStyleHnd = CategoryUtil.GetOrCreateMaterialStyle(document, exporterIFC, materialId); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(matStyleHnd) && !ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView) { styles.Add(matStyleHnd); bool supportCutStyles = !ExporterCacheManager.ExportOptionsCache.ExportAsCoordinationView2; if (fillPatternId != ElementId.InvalidElementId && supportCutStyles) { IFCAnyHandle cutStyleHnd = exporterIFC.GetOrCreateFillPattern(fillPatternId, color, planScale); if (cutStyleHnd.HasValue) { styles.Add(cutStyleHnd); hasFill = true; } } IFCAnyHandle presStyleHnd = IFCInstanceExporter.CreatePresentationStyleAssignment(file, styles); HashSet <IFCAnyHandle> presStyleSet = new HashSet <IFCAnyHandle>(); presStyleSet.Add(presStyleHnd); IFCAnyHandle styledItemHnd = IFCInstanceExporter.CreateStyledItem(file, styledRepItem, presStyleSet, null); IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle(""); string repId = "Style"; string repType = (hasFill) ? "Material and Cut Pattern" : "Material"; HashSet <IFCAnyHandle> repItems = new HashSet <IFCAnyHandle>(); repItems.Add(styledItemHnd); IFCAnyHandle styleRepHnd = IFCInstanceExporter.CreateStyledRepresentation(file, contextOfItems, repId, repType, repItems); List <IFCAnyHandle> repList = new List <IFCAnyHandle>(); repList.Add(styleRepHnd); IFCAnyHandle matDefRepHnd = IFCInstanceExporter.CreateMaterialDefinitionRepresentation(file, null, null, repList, materialNameHandle); } } } } return(materialNameHandle); }
public static Color ToColor(this DB.Color c) { return(c.IsValid ? Color.FromArgb(c.Red, c.Green, c.Blue, 0xFF) : Color.FromArgb(0, 0, 0, 0)); }
private static int ColorToInt(RvtColor color) { return((int)(Math.Pow(256, 0) * color.Red + Math.Pow(256, 1) * color.Green + Math.Pow(256, 2) * color.Blue)); }
public void Execute(UIApplication uiapp) { try { UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; // myListView_ALL_Fam_Master.Items.Add(doc.GetElement(uidoc.Selection.GetElementIds().First()).Name); using (Transaction tx = new Transaction(doc)) { tx.Start("Show Arrangement"); KeyValuePair <string, Entity> myKeyValuePair = (KeyValuePair <string, Entity>)myWindow1.myWindow4.myListViewEE.SelectedItem; IDictionary <ElementId, XYZ> dict_Child = myKeyValuePair.Value.Get <IDictionary <ElementId, XYZ> >("FurnLocations", DisplayUnitType.DUT_MILLIMETERS); string myStringAggregate_Location = ""; foreach (KeyValuePair <ElementId, XYZ> myKP in dict_Child) { Element Searchelem = doc.GetElement(myKP.Key); if (Searchelem == null) { continue; } ElementTransformUtils.MoveElement(doc, myKP.Key, myKP.Value - ((LocationPoint)Searchelem.Location).Point); myStringAggregate_Location = myStringAggregate_Location + Environment.NewLine + ((FamilyInstance)doc.GetElement(myKP.Key)).get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString() + "," + Math.Round(myKP.Value.X, 2) + "," + Math.Round(myKP.Value.Y, 2) + "," + Math.Round(myKP.Value.Z, 2); } IDictionary <ElementId, double> dict_Child_Angle = myKeyValuePair.Value.Get <IDictionary <ElementId, double> >("FurnLocations_Angle", DisplayUnitType.DUT_MILLIMETERS); string myStringAggregate_Angle = ""; foreach (KeyValuePair <ElementId, double> myKP in dict_Child_Angle) { FamilyInstance Searchelem = doc.GetElement(myKP.Key) as FamilyInstance; if (Searchelem == null) { continue; } Line line = Line.CreateBound(((LocationPoint)Searchelem.Location).Point, ((LocationPoint)Searchelem.Location).Point + XYZ.BasisZ); double myDouble = Searchelem.GetTransform().BasisX.AngleOnPlaneTo(XYZ.BasisY, XYZ.BasisZ) - myKP.Value; ElementTransformUtils.RotateElement(doc, myKP.Key, line, myDouble); myStringAggregate_Angle = myStringAggregate_Angle + Environment.NewLine + (IsZero(myKP.Value, _eps) ? 0 : Math.Round(myKP.Value, 2)); } IDictionary <ElementId, ElementId> dict_Child_Pattern = myKeyValuePair.Value.Get <IDictionary <ElementId, ElementId> >("FurnLocations_Pattern", DisplayUnitType.DUT_MILLIMETERS); IDictionary <ElementId, int> dict_Child_Red = myKeyValuePair.Value.Get <IDictionary <ElementId, int> >("FurnLocations_ColorRed", DisplayUnitType.DUT_MILLIMETERS); IDictionary <ElementId, int> dict_Child_Green = myKeyValuePair.Value.Get <IDictionary <ElementId, int> >("FurnLocations_ColorGreen", DisplayUnitType.DUT_MILLIMETERS); IDictionary <ElementId, int> dict_Child_Blue = myKeyValuePair.Value.Get <IDictionary <ElementId, int> >("FurnLocations_ColorBlue", DisplayUnitType.DUT_MILLIMETERS); int myInt = -1; foreach (KeyValuePair <ElementId, ElementId> myKP in dict_Child_Pattern) { myInt++; FamilyInstance Searchelem = doc.GetElement(myKP.Key) as FamilyInstance; if (Searchelem == null) { continue; } if (Searchelem.Category.Name != "Furniture") { continue; } OverrideGraphicSettings ogs = new OverrideGraphicSettings(); OverrideGraphicSettings ogsCheeck = doc.ActiveView.GetElementOverrides(myKP.Key); Color myColor = new Autodesk.Revit.DB.Color((byte)dict_Child_Red[myKP.Key], (byte)dict_Child_Green[myKP.Key], (byte)dict_Child_Blue[myKP.Key]); Color myColorBrighter = ChangeColorBrightness(myColor, (float)0.5); ogs.SetSurfaceForegroundPatternId(myKP.Value); ogs.SetSurfaceForegroundPatternColor(myColor); ogs.SetProjectionLineWeight(5); ogs.SetProjectionLineColor(myColor); FillPatternElement myFillPattern_SolidFill = new FilteredElementCollector(doc).OfClass(typeof(FillPatternElement)).Cast <FillPatternElement>().First(a => a.Name.Contains("Solid fill")); ogs.SetSurfaceBackgroundPatternId(myFillPattern_SolidFill.Id); ogs.SetSurfaceBackgroundPatternColor(myColorBrighter); doc.ActiveView.SetElementOverrides(myKP.Key, ogs); } tx.Commit(); } } #region catch and finally catch (Exception ex) { _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE13_ExtensibleStorage_Rearrange" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, true); } finally { } #endregion }
/// <summary> /// Gets material handle from material id or creates one if there is none. /// </summary> /// <param name="document"> /// The Revit document. /// </param> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="materialId"> /// The material id. /// </param> /// <returns> /// The handle. /// </returns> public static IFCAnyHandle GetOrCreateMaterialHandle(Document document, ExporterIFC exporterIFC, ElementId materialId) { IFCAnyHandle materialNameHandle = null; materialNameHandle = ExporterCacheManager.MaterialHandleCache.Find(materialId); if (IFCAnyHandleUtil.IsNullOrHasNoValue(materialNameHandle)) { string materialName = " <Unnamed>"; if (materialId != ElementId.InvalidElementId) { Material material = document.GetElement(materialId) as Material; if (material != null) { materialName = material.Name; } } materialNameHandle = IFCInstanceExporter.CreateMaterial(exporterIFC.GetFile(), materialName); ExporterCacheManager.MaterialHandleCache.Register(materialId, materialNameHandle); // associate Material with SurfaceStyle if necessary. IFCFile file = exporterIFC.GetFile(); if (materialId != ElementId.InvalidElementId && !ExporterCacheManager.ExportOptionsCache.ExportAs2x2 && materialNameHandle.HasValue) { HashSet <IFCAnyHandle> matRepHandles = IFCAnyHandleUtil.GetHasRepresentation(materialNameHandle); if (matRepHandles.Count == 0) { Material matElem = document.GetElement(materialId) as Material; ElementId fillPatternId = (matElem != null) ? matElem.GetCutPatternId() : ElementId.InvalidElementId; Autodesk.Revit.DB.Color color = (matElem != null) ? matElem.GetCutPatternColor() : new Color(0, 0, 0); double planScale = 100.0; HashSet <IFCAnyHandle> styles = new HashSet <IFCAnyHandle>(); bool hasFill = false; IFCAnyHandle styledRepItem = null; IFCAnyHandle matStyleHnd = CategoryUtil.GetOrCreateMaterialStyle(document, exporterIFC, materialId); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(matStyleHnd)) { styles.Add(matStyleHnd); if (fillPatternId != ElementId.InvalidElementId && !ExporterCacheManager.ExportOptionsCache.ExportAs2x3CoordinationView2) { IFCAnyHandle cutStyleHnd = exporterIFC.GetOrCreateFillPattern(fillPatternId, color, planScale); if (cutStyleHnd.HasValue) { styles.Add(cutStyleHnd); hasFill = true; } } IFCAnyHandle presStyleHnd = IFCInstanceExporter.CreatePresentationStyleAssignment(file, styles); HashSet <IFCAnyHandle> presStyleSet = new HashSet <IFCAnyHandle>(); presStyleSet.Add(presStyleHnd); IFCAnyHandle styledItemHnd = IFCInstanceExporter.CreateStyledItem(file, styledRepItem, presStyleSet, null); IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle(""); string repId = "Style"; string repType = (hasFill) ? "Material and Cut Pattern" : "Material"; HashSet <IFCAnyHandle> repItems = new HashSet <IFCAnyHandle>(); repItems.Add(styledItemHnd); IFCAnyHandle styleRepHnd = IFCInstanceExporter.CreateStyledRepresentation(file, contextOfItems, repId, repType, repItems); List <IFCAnyHandle> repList = new List <IFCAnyHandle>(); repList.Add(styleRepHnd); IFCAnyHandle matDefRepHnd = IFCInstanceExporter.CreateMaterialDefinitionRepresentation(file, null, null, repList, materialNameHandle); } } } } return(materialNameHandle); }
public static System.Drawing.Color ConvertToSystemColor(Autodesk.Revit.DB.Color revitColor) { System.Drawing.Color systemColor = System.Drawing.Color.FromArgb(revitColor.Red, revitColor.Green, revitColor.Blue); return(systemColor); }
public static System.Drawing.Color ToRhino(this DB.Color c) { return(System.Drawing.Color.FromArgb(c.Red, c.Green, c.Blue)); }
private void SetCutPatternSettings(View view, BuiltInCategory buildInCategory, Autodesk.Revit.DB.Color backgroundColor, FillPatternElement foregroundFillPattern) { ElementId categoryId = new ElementId(buildInCategory); OverrideGraphicSettings ogSettings = view.GetCategoryOverrides(categoryId); if ((ogSettings == null) || (!ogSettings.IsValidObject)) { Utils.ShowWarningMessageBox(string.Format("Graphic overrides category '{0}' is not found or is not valid", buildInCategory.ToString())); return; } if (!(view.IsCategoryOverridable(categoryId))) { Utils.ShowWarningMessageBox(string.Format("Graphic overrides category '{0}' is not overridable", buildInCategory.ToString())); return; } ogSettings.SetCutBackgroundPatternColor(backgroundColor); ogSettings.SetCutForegroundPatternId(foregroundFillPattern.Id); view.SetCategoryOverrides(categoryId, ogSettings); }
public static System.Drawing.Color ToRhino(this DB.Color c) => ColorConverter.ToColor(c);
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; FilteredElementCollector elementsInView = new FilteredElementCollector(doc); FillPatternElement solidFillPattern = elementsInView.OfClass(typeof(FillPatternElement)).Cast <FillPatternElement>().First(a => a.GetFillPattern().IsSolidFill); List <BuiltInCategory> builtInCats = new List <BuiltInCategory>(); builtInCats.Add(BuiltInCategory.OST_StructuralFraming); builtInCats.Add(BuiltInCategory.OST_Walls); builtInCats.Add(BuiltInCategory.OST_Floors); builtInCats.Add(BuiltInCategory.OST_StructuralColumns); builtInCats.Add(BuiltInCategory.OST_StructuralFoundation); ElementMulticategoryFilter filter1 = new ElementMulticategoryFilter(builtInCats); IList <Element> allElementsInView = new FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(filter1).WhereElementIsNotElementType().ToElements(); var grouped = allElementsInView.GroupBy(x => x.GetTypeId()); Random pRand = new Random(); //TaskDialog.Show("r", grouped.First().First().Name); OverrideGraphicSettings ogs = new OverrideGraphicSettings(); #if REVIT2020 ogs.SetSurfaceForegroundPatternId(solidFillPattern.Id); #else ogs.SetProjectionFillPatternId(solidFillPattern.Id); #endif using (Transaction t = new Transaction(doc, "Override Colors")) { t.Start(); foreach (var element in grouped) { byte iR, iG, iB; iR = Convert.ToByte(pRand.Next(0, 255)); iG = Convert.ToByte(pRand.Next(0, 255)); iB = Convert.ToByte(pRand.Next(0, 255)); Autodesk.Revit.DB.Color pcolor = new Autodesk.Revit.DB.Color(iR, iG, iB); #if REVIT2020 ogs.SetSurfaceForegroundPatternColor(pcolor); #else ogs.SetProjectionFillColor(pcolor); #endif try { foreach (FamilyInstance item in element) { doc.ActiveView.SetElementOverrides(item.Id, ogs); } } catch { } } t.Commit(); } return(Result.Succeeded); }
public void Execute(UIApplication uiapp) { try { UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; if (myWindow1.myWindow4.myListViewEE.Items.Count == 0) { MessageBox.Show("Please save an an arrangement"); return; } if (myWindow1.myWindow4.myListViewEE.SelectedIndex == -1) { myWindow1.myWindow4.myListViewEE.SelectedIndex = 0; } Random rnd = new Random(); using (Transaction tx = new Transaction(doc)) { tx.Start("Show Arrangement"); KeyValuePair <string, Autodesk.Revit.DB.ExtensibleStorage.Entity> myKeyValuePair = (KeyValuePair <string, Entity>)myWindow1.myWindow4.myListViewEE.SelectedItem; IDictionary <ElementId, XYZ> dict_Child = myKeyValuePair.Value.Get <IDictionary <ElementId, XYZ> >("FurnLocations", DisplayUnitType.DUT_MILLIMETERS); string myStringAggregate_Location = ""; foreach (KeyValuePair <ElementId, XYZ> myKP in dict_Child) { Element Searchelem = doc.GetElement(myKP.Key); if (Searchelem == null) { continue; } if (Searchelem.Category.Name != "Furniture") { continue; } OverrideGraphicSettings ogs = new OverrideGraphicSettings(); OverrideGraphicSettings ogsCheeck = doc.ActiveView.GetElementOverrides(myKP.Key); //FillPatternElement myFillPattern = new FilteredElementCollector(doc).OfClass(typeof(FillPatternElement)).Cast<FillPatternElement>().First(a => a.Name.Contains("Solid fill")); List <FillPatternElement> myListFillPattern = new FilteredElementCollector(doc).OfClass(typeof(FillPatternElement)).Cast <FillPatternElement>().Where(x => x.GetFillPattern().Target == FillPatternTarget.Drafting).ToList(); FillPatternElement myFillPattern = myListFillPattern[(byte)rnd.Next(0, myListFillPattern.Count - 1)]; ogs.SetSurfaceBackgroundPatternId(myFillPattern.Id); Color myColor_Random01 = new Autodesk.Revit.DB.Color((byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256)); ogs.SetProjectionLineWeight(5); ogs.SetProjectionLineColor(myColor_Random01); ogs.SetSurfaceBackgroundPatternColor(myColor_Random01); doc.ActiveView.SetElementOverrides(myKP.Key, ogs); myStringAggregate_Location = myStringAggregate_Location + Environment.NewLine + ((FamilyInstance)doc.GetElement(myKP.Key)).get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString() + "," + Math.Round(myKP.Value.X, 2) + "," + Math.Round(myKP.Value.Y, 2) + "," + Math.Round(myKP.Value.Z, 2); } tx.Commit(); } } #region catch and finally catch (Exception ex) { _952_PRLoogleClassLibrary.DatabaseMethods.writeDebug("EE01_Part1_ManualColorOverride" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, true); } finally { } #endregion }
/// <summary> /// Metodo che cambia il colore di tutti o molti pannelli /// </summary> /// <remarks> /// </remarks> /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m> /// private void ChangeColorOfAllPanels(UIApplication uiapp, List <string[]> listParameters) { using (Transaction trans = new Transaction(uiapp.ActiveUIDocument.Document)) { trans.Start("Change All Colors"); foreach (string[] singleParameter in listParameters) { // Lista degli elementi che hanno l'identificatore selezionato List <Element> chosenElements = new List <Element>(); foreach (Element ele in _elements) { ElementType eleType = uiapp.ActiveUIDocument.Document.GetElement(ele.GetTypeId()) as ElementType; if (eleType != null && eleType.LookupParameter("UI-ItemCategory") != null && eleType.LookupParameter("UI-ProjectAbbreviation") != null && eleType.LookupParameter("UI-ItemCategory").AsString() == singleParameter[0]) { if (eleType.LookupParameter("UI-ProjectAbbreviation").AsString() == singleParameter[1] && ele.LookupParameter("UI-Quadrant").AsString() == singleParameter[2] && ele.LookupParameter("UI-FloorNumber").AsString() == singleParameter[3] && ele.LookupParameter("UI-UnitNumber").AsString() == singleParameter[04]) { chosenElements.Add(ele); } } else if (eleType != null && eleType.LookupParameter("PNT-ItemCategory") != null && eleType.LookupParameter("PNT-ProjectAbbreviation") != null && eleType.LookupParameter("PNT-WallType") != null && ele.LookupParameter("PNT-PanelType") != null && eleType.LookupParameter("PNT-ItemCategory").AsString() == singleParameter[0]) { if (eleType.LookupParameter("PNT-ProjectAbbreviation").AsString() == singleParameter[1] && eleType.LookupParameter("PNT-WallType").AsString() == singleParameter[2] && ele.LookupParameter("PNT-PanelType").AsString() == singleParameter[3]) { chosenElements.Add(ele); } } } // Metodo per la trasformazione del colore da System.Drawing.Color a Autodesk.Revit.DB.Color System.Drawing.Color colorToConvert = new System.Drawing.Color(); if (singleParameter.Count() == 6) { colorToConvert = System.Drawing.Color.FromName(singleParameter[5]); } else if (singleParameter.Count() == 5) { colorToConvert = System.Drawing.Color.FromName(singleParameter[4]); } Autodesk.Revit.DB.Color newColor = new Autodesk.Revit.DB.Color(colorToConvert.R, colorToConvert.G, colorToConvert.B); // Assegna il nuovo colore all'elemento di override delle impostazioni grafiche _ogs.SetSurfaceForegroundPatternColor(newColor); _ogs.SetSurfaceForegroundPatternVisible(true); // Estrae il valore Id per settare il Pattern come Solid FIll(Riempimento) FilteredElementCollector elements = new FilteredElementCollector(uiapp.ActiveUIDocument.Document); FillPatternElement solidFillPattern = elements.OfClass(typeof(FillPatternElement)) .Cast <FillPatternElement>() .First(a => a.GetFillPattern().IsSolidFill); ElementId solidFillPatternId = null; if (solidFillPattern.GetFillPattern().IsSolidFill) { solidFillPatternId = solidFillPattern.Id; } // Imposta l'elemento come Solid Fill _ogs.SetSurfaceForegroundPatternId(solidFillPatternId); foreach (Element el in chosenElements) { // Fa l'override delle impostazioni grafiche dell'elemento uiapp.ActiveUIDocument.Document.ActiveView.SetElementOverrides(el.Id, _ogs); } } trans.Commit(); } }
public static void ConvertColor(System.Windows.Media.Color mediaColor, out Autodesk.Revit.DB.Color color2) { color2 = new Autodesk.Revit.DB.Color(mediaColor.R, mediaColor.G, mediaColor.B); }
public static Autodesk.Revit.DB.Color ConvertToRevitColor(System.Drawing.Color systemColor) { Autodesk.Revit.DB.Color revitColor = new Autodesk.Revit.DB.Color(systemColor.R, systemColor.G, systemColor.B); return(revitColor); }
public static void ConvertColor(System.Drawing.Color drawingColor, out Autodesk.Revit.DB.Color color2) { color2 = new Autodesk.Revit.DB.Color(drawingColor.R, drawingColor.G, drawingColor.B); }
private void performColor() { // we need to collect all of the element Ids Transaction t = new Transaction(_uiDoc.Document, "Color Changed Elements"); t.Start(); if (!_isResetting) { _viewsColored[_uiDoc.ActiveGraphicalView.Id.IntegerValue] = true; } Autodesk.Revit.DB.Color overrideColor = new Autodesk.Revit.DB.Color(0, 0, 0); // group changes by type... var grouped = _changes.GroupBy(c => c.ChangeType).ToDictionary(c => c.Key, c => c.ToList()); var list = grouped.Keys.ToList(); if (list.Contains(Objects.Change.ChangeTypeEnum.DeletedElement)) { list.Remove(Objects.Change.ChangeTypeEnum.DeletedElement); } if (list.Count == 0) { MessageBox.Show("No color-able change types!"); t.RollBack(); return; } UI.ColorChoiceForm choice = new UI.ColorChoiceForm(list); if (choice.ShowDialog(this) != DialogResult.OK) { t.RollBack(); return; } foreach (var group in grouped) { if (group.Key == Objects.Change.ChangeTypeEnum.DeletedElement) { continue; // can't } if (choice.ChangeTypes.Contains(group.Key) == false) { continue; // not selected. } var ogs = new Autodesk.Revit.DB.OverrideGraphicSettings(); var patternCollector = new FilteredElementCollector(_uiDoc.Document); patternCollector.OfClass(typeof(Autodesk.Revit.DB.FillPatternElement)); Autodesk.Revit.DB.FillPatternElement solidFill = patternCollector.ToElements().Cast <Autodesk.Revit.DB.FillPatternElement>().First(x => x.GetFillPattern().IsSolidFill); IList <ElementId> ids = collectIds(group.Value); overrideColor = Utilities.Settings.GetColor(group.Key); #if REVIT2015 || REVIT2016 || REVIT2017 || REVIT2018 ogs.SetProjectionFillColor(overrideColor); ogs.SetProjectionFillPatternId(solidFill.Id); ogs.SetProjectionLineColor(overrideColor); ogs.SetCutFillColor(overrideColor); ogs.SetCutFillPatternId(solidFill.Id); ogs.SetCutLineColor(overrideColor); #else ogs.SetSurfaceForegroundPatternColor(overrideColor); ogs.SetSurfaceForegroundPatternId(solidFill.Id); ogs.SetProjectionLineColor(overrideColor); ogs.SetCutForegroundPatternColor(overrideColor); ogs.SetCutForegroundPatternId(solidFill.Id); ogs.SetCutLineColor(overrideColor); #endif foreach (ElementId id in ids) { _uiDoc.ActiveGraphicalView.SetElementOverrides(id, ogs); } } t.Commit(); }
void SetOneFloorColor(Document doc, FillPatternElement fillPatternElement, ElementId floorId, Autodesk.Revit.DB.Color color) { OverrideGraphicSettings OverrideGraphicSettings = new OverrideGraphicSettings(); OverrideGraphicSettings = doc.ActiveView.GetElementOverrides(floorId); OverrideGraphicSettings.SetProjectionFillPatternId(fillPatternElement.Id); OverrideGraphicSettings.SetProjectionFillColor(color); doc.ActiveView.SetElementOverrides(floorId, OverrideGraphicSettings); }