private static AnalysisDisplayStyle CreateDefaultSpaceSyntaxAnalysisDisplayStyle(Document doc) { AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; coloredSurfaceSettings.ShowContourLines = false; AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings(); colorSettings.ColorSettingsType = AnalysisDisplayStyleColorSettingsType.GradientColor; colorSettings.MaxColor = new Color(255, 0, 255); // Magenta colorSettings.MinColor = new Color(255, 255, 0); // Yellow AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings(); legendSettings.ShowLegend = true; legendSettings.ShowUnits = true; legendSettings.ShowDataDescription = false; var analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle( doc, _defaultSpaceSyntaxDisplayStyleName, coloredSurfaceSettings, colorSettings, legendSettings); return(analysisDisplayStyle); }
private AnalysisDisplayStyle CreateAnalysisDisplayStyle(string displayStyleName, List <Color> colors) { var coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); var colorSettings = CreateAnalysisDisplayColorSettings(colors); var legendSettings = new AnalysisDisplayLegendSettings(); return(AnalysisDisplayStyle.CreateAnalysisDisplayStyle(this.elem.Document, displayStyleName, coloredSurfaceSettings, colorSettings, legendSettings)); }
AnalysisDisplayStyle CreateDisplayStyle() { AnalysisDisplayStyle analysisDisplayStyle = null; Document doc = dynRevitSettings.Doc.Document; // Look for an existing analysis display style with a specific name FilteredElementCollector collector1 = new FilteredElementCollector(doc); ICollection <Element> collection = collector1.OfClass(typeof(AnalysisDisplayStyle)).ToElements(); var displayStyle = from element in collection where element.Name == DISPLAY_STYLE_NAME select element; // If display style does not already exist in the document, create it if (displayStyle.Count() == 0) { var coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; var colorSettings = new AnalysisDisplayColorSettings(); var orange = new Color(255, 205, 0); var purple = new Color(200, 0, 200); colorSettings.MaxColor = orange; colorSettings.MinColor = purple; var legendSettings = new AnalysisDisplayLegendSettings { NumberOfSteps = 10, Rounding = 0.05, ShowDataDescription = false, ShowLegend = true }; var collector2 = new FilteredElementCollector(doc); ICollection <Element> elementCollection = collector2.OfClass(typeof(TextNoteType)).ToElements(); var textElements = from element in collector2 select element; // if LegendText exists, use it for this Display Style if (textElements.Any()) { var textType = textElements.Cast <TextNoteType>().ElementAt <TextNoteType>(0); legendSettings.TextTypeId = textType.Id; } analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, DISPLAY_STYLE_NAME, coloredSurfaceSettings, colorSettings, legendSettings); } else { analysisDisplayStyle = displayStyle.Cast <AnalysisDisplayStyle>().ElementAt <AnalysisDisplayStyle>(0); } return(analysisDisplayStyle); }
AnalysisDisplayStyle CreateDisplayStyle() { AnalysisDisplayStyle analysisDisplayStyle = null; Document doc = dynRevitSettings.Doc.Document; // Look for an existing analysis display style with a specific name FilteredElementCollector collector1 = new FilteredElementCollector(doc); ICollection<Element> collection = collector1.OfClass(typeof(AnalysisDisplayStyle)).ToElements(); var displayStyle = from element in collection where element.Name == DISPLAY_STYLE_NAME select element; // If display style does not already exist in the document, create it if (displayStyle.Count() == 0) { var coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; var colorSettings = new AnalysisDisplayColorSettings(); var orange = new Color(255, 205, 0); var purple = new Color(200, 0, 200); colorSettings.MaxColor = orange; colorSettings.MinColor = purple; var legendSettings = new AnalysisDisplayLegendSettings{ NumberOfSteps = 10, Rounding = 0.05, ShowDataDescription = false, ShowLegend = true}; var collector2 = new FilteredElementCollector(doc); ICollection<Element> elementCollection = collector2.OfClass(typeof(TextNoteType)).ToElements(); var textElements = from element in collector2 select element; // if LegendText exists, use it for this Display Style if (textElements.Any()) { var textType = textElements.Cast<TextNoteType>().ElementAt<TextNoteType>(0); legendSettings.TextTypeId = textType.Id; } analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, DISPLAY_STYLE_NAME, coloredSurfaceSettings, colorSettings, legendSettings); } else { analysisDisplayStyle = displayStyle.Cast<AnalysisDisplayStyle>().ElementAt<AnalysisDisplayStyle>(0); } return analysisDisplayStyle; }
private void CreateAVFDisplayStyle(Document doc, View view) { AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = true; AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings(); AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings(); legendSettings.ShowLegend = false; var rnd = new Random(); AnalysisDisplayStyle analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, "Paint Solid-" + rnd.Next(), coloredSurfaceSettings, colorSettings, legendSettings); view.AnalysisDisplayStyleId = analysisDisplayStyle.Id; }
/// <summary> /// Retrieve or set up the attenuation /// display style for the given view. /// </summary> static void SetAvfDisplayStyle(View view) { Document doc = view.Document; ElementId id = AnalysisDisplayStyle.FindByName( doc, _displayStyleName); if (ElementId.InvalidElementId == id) { using (Transaction t = new Transaction(doc)) { t.Start("Create AVF Display Style"); AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings(); colorSettings.MinColor = new Color(0, 255, 0); colorSettings.MaxColor = new Color(255, 0, 0); AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings(); legendSettings.ShowLegend = true; AnalysisDisplayStyle analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle( doc, _displayStyleName, coloredSurfaceSettings, colorSettings, legendSettings); view.AnalysisDisplayStyleId = analysisDisplayStyle.Id; t.Commit(); } } }
private static void CreateAVFDisplayStyle(Document doc, Autodesk.Revit.DB.View view) { Transaction t = new Transaction(doc, "Create AVF style"); t.Start(); AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = true; AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings(); AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings(); legendSettings.ShowLegend = false; string name = "Paint Solid"; AnalysisDisplayStyle analysisDisplayStyle = new FilteredElementCollector(doc).OfClass(typeof(AnalysisDisplayStyle)).Cast <AnalysisDisplayStyle>().FirstOrDefault(q => q.Name == name); if (analysisDisplayStyle == null) { analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, name, coloredSurfaceSettings, colorSettings, legendSettings); } view.AnalysisDisplayStyleId = analysisDisplayStyle.Id; t.Commit(); }
public static ElementId CreateAnalysisScheme(List <AnalysisDisplayColorEntry> colours, Document doc, string name, bool showLegend) { var result = ElementId.InvalidElementId; var colouredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); colouredSurfaceSettings.ShowContourLines = true; colouredSurfaceSettings.ShowGridLines = false; var colourSettings = new AnalysisDisplayColorSettings(); colourSettings.MaxColor = colours.Last().Color; colourSettings.MinColor = colours.First().Color; colourSettings.SetIntermediateColors(colours); colourSettings.ColorSettingsType = AnalysisDisplayStyleColorSettingsType.GradientColor; if (AnalysisDisplayStyle.IsNameUnique(doc, name, null)) { var ads = AnalysisDisplayStyle.CreateAnalysisDisplayStyle( doc, name, colouredSurfaceSettings, colourSettings, new AnalysisDisplayLegendSettings()); if (!showLegend) { ads.GetLegendSettings().ShowLegend = false; } result = ads.Id; } else { result = AnalysisDisplayStyle.FindByName(doc, name); } return(result); }
private static Element createSolidDisplayStyle(Document doc, string name) { AnalysisDisplayColoredSurfaceSettings style = new AnalysisDisplayColoredSurfaceSettings(); style.ShowGridLines = true; AnalysisDisplayColorSettings colors = new AnalysisDisplayColorSettings(); colors.ColorSettingsType = AnalysisDisplayStyleColorSettingsType.GradientColor; colors.MinColor = new Color((byte)255, (byte)165, (byte)0); colors.MaxColor = new Color((byte)0, (byte)0, (byte)255); // orange to blue // we need to create it Element pc = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, name, style, colors, new AnalysisDisplayLegendSettings() { ShowLegend = false }); return(pc); }
/// <summary> /// We setup our preferred style for displaying the results /// </summary> /// <remarks> /// This is to make it easier to run this sample on any document. /// We create a gradient-like style (unless it already exists) /// and register it with the given view. Then we set it as the /// default analysis stile in that view. /// </remarks> /// private void SetupDisplayStyle(Autodesk.Revit.DB.View view) { const string styleName = "SDK2014-AL Style"; AnalysisDisplayStyle ourStyle = null; // check if we are already using our preferred display style if (ElementId.InvalidElementId != view.AnalysisDisplayStyleId) { ourStyle = view.Document.GetElement(view.AnalysisDisplayStyleId) as AnalysisDisplayStyle; if (ourStyle.Name == styleName) { return; } } // Look if the style exist at all in the document FilteredElementCollector collector = new FilteredElementCollector(view.Document); ICollection <Element> allStyles = collector.OfClass(typeof(AnalysisDisplayStyle)).ToElements(); foreach (Element elem in allStyles) { if (elem.Name == styleName) { using (Transaction trans = new Transaction(view.Document)) { trans.Start("Change Analysis Display Style"); view.AnalysisDisplayStyleId = elem.Id; trans.Commit(); return; } } } // we do not have out style yet - let's create it // a) grid lines AnalysisDisplayColoredSurfaceSettings surface = new AnalysisDisplayColoredSurfaceSettings(); surface.ShowGridLines = true; // b) colors AnalysisDisplayColorSettings colors = new AnalysisDisplayColorSettings(); Color orange = new Color(255, 205, 0); Color green = new Color(0, 255, 0); colors.MinColor = orange; colors.MaxColor = green; // c) the legend AnalysisDisplayLegendSettings legend = new AnalysisDisplayLegendSettings(); legend.NumberOfSteps = 10; legend.Rounding = 0.1; legend.ShowDataDescription = false; legend.ShowLegend = false; // creation of a style needs to be in a transaction using (Transaction trans = new Transaction(view.Document)) { trans.Start("Set Analysis Display Style"); ourStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(view.Document, styleName, surface, colors, legend); view.AnalysisDisplayStyleId = ourStyle.Id; trans.Commit(); } }
/// <summary> /// Set analysis display style to switch off grid lines /// and use greyscale values in active view. /// </summary> void SetAnalysisDisplayStyle(Document doc) { AnalysisDisplayStyle analysisDisplayStyle; const string styleName = "Revit Webcam Display Style"; // extract existing display styles with specific name FilteredElementCollector a = new FilteredElementCollector(doc); IList <Element> elements = a .OfClass(typeof(AnalysisDisplayStyle)) .Where(x => x.Name.Equals(styleName)) .Cast <Element>() .ToList(); if (0 < elements.Count) { // use the existing display style analysisDisplayStyle = elements[0] as AnalysisDisplayStyle; } else { // create new display style: // coloured surface settings: AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; // color settings: AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings(); colorSettings.MaxColor = new Color(255, 255, 255); colorSettings.MinColor = new Color(0, 0, 0); // legend settings: AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings(); legendSettings.NumberOfSteps = 10; legendSettings.Rounding = 0.05; legendSettings.ShowDataDescription = false; legendSettings.ShowLegend = true; //// extract legend text: //a = new FilteredElementCollector( doc ); //elements = a // .OfClass( typeof( TextNoteType ) ) // .Where( x => x.Name == "LegendText" ) // .Cast<Element>() // .ToList(); //if( 0 < elements.Count ) //{ // // if LegendText exists, use it for this display style // TextNoteType textType = elements[0] as TextNoteType; // // warning CS0618: // // SetTextTypeId(ElementId, Document) is obsolete: // // this method will be obsolete from 2012. // legendSettings.SetTextTypeId( textType.Id, doc ); //} // Create the analysis display style: var transaction = new Transaction(doc); transaction.Start("Create AnalysisDisplayStyle"); try { analysisDisplayStyle = AnalysisDisplayStyle .CreateAnalysisDisplayStyle( doc, styleName, coloredSurfaceSettings, colorSettings, legendSettings); // assign the display style to the active view doc.ActiveView.AnalysisDisplayStyleId = analysisDisplayStyle.Id; transaction.Commit(); } catch { transaction.RollBack(); throw; } } }
/// <summary> /// Set analysis display style to switch off grid lines /// and use greyscale values in active view. /// </summary> void SetAnalysisDisplayStyle(Document doc) { AnalysisDisplayStyle analysisDisplayStyle; const string styleName = "Revit Webcam Display Style"; // extract existing display styles with specific name FilteredElementCollector a = new FilteredElementCollector(doc); IList <Element> elements = a .OfClass(typeof(AnalysisDisplayStyle)) .Where(x => x.Name.Equals(styleName)) .Cast <Element>() .ToList(); if (0 < elements.Count) { // use the existing display style analysisDisplayStyle = elements[0] as AnalysisDisplayStyle; } else { // create new display style: // coloured surface settings: AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; // color settings: AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings(); colorSettings.MaxColor = new Color(255, 255, 255); colorSettings.MinColor = new Color(0, 0, 0); // legend settings: AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings(); legendSettings.NumberOfSteps = 10; legendSettings.Rounding = 0.05; legendSettings.ShowDataDescription = false; legendSettings.ShowLegend = true; // extract legend text: a = new FilteredElementCollector(doc); elements = a .OfClass(typeof(TextNoteType)) .Where(x => x.Name == "LegendText") .Cast <Element>() .ToList(); if (0 < elements.Count) { // if LegendText exists, use it for this display style TextNoteType textType = elements[0] as TextNoteType; legendSettings.SetTextTypeId(textType.Id, doc); } // create the analysis display style: analysisDisplayStyle = AnalysisDisplayStyle .CreateAnalysisDisplayStyle( doc, styleName, coloredSurfaceSettings, colorSettings, legendSettings); } // assign the display style to the active view doc.ActiveView.AnalysisDisplayStyleId = analysisDisplayStyle.Id; }
private bool IsViewForAnalysis(Autodesk.Revit.DB.View activeView) { var result = false; try { if (activeView.ViewType == ViewType.FloorPlan) { AnalysisDisplayStyle displayStyle = null; var collector = new FilteredElementCollector(m_doc); var displayStyles = collector.OfClass(typeof(AnalysisDisplayStyle)).ToElements().Cast <AnalysisDisplayStyle>().ToList(); var viewAnlysisStyle = from style in displayStyles where style.Name == "View Analysis" select style; if (viewAnlysisStyle.Any()) { displayStyle = viewAnlysisStyle.First(); } else { var coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings(); coloredSurfaceSettings.ShowGridLines = false; var colorSettings = new AnalysisDisplayColorSettings(); var yellow = new Color(255, 255, 0); var blue = new Color(0, 128, 255); var colorEntries = new List <AnalysisDisplayColorEntry> { new AnalysisDisplayColorEntry(blue) }; colorSettings.SetIntermediateColors(colorEntries); colorSettings.MinColor = blue; colorSettings.MaxColor = yellow; colorSettings.ColorSettingsType = AnalysisDisplayStyleColorSettingsType.SolidColorRanges; var legendSettings = new AnalysisDisplayLegendSettings { NumberOfSteps = 1, ShowDataDescription = false, ShowLegend = false }; using (var trans = new Transaction(m_doc)) { trans.Start("Create an Analysis Display Style"); try { displayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(m_doc, "View Analysis", coloredSurfaceSettings, colorSettings, legendSettings); trans.Commit(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); trans.RollBack(); } } } if (null != displayStyle) { using (var trans = new Transaction(m_doc)) { trans.Start("Set Display Style"); try { m_doc.ActiveView.AnalysisDisplayStyleId = displayStyle.Id; trans.Commit(); result = true; } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); trans.RollBack(); result = false; } } } else { result = false; } } else { result = false; MessageBox.Show("A floor plan should be an active view for the view anlaysis.\n", "View Analysis - Active View", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Failed to get information of the active view.\n" + ex.Message, "View Analysis - Active View", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(result); }
public void SetCO2eAnalysisDisplayStyle(View view) { var t = new Transaction(view.Document); t.Start("SetCO2eAnalysisDisplayStyle"); AnalysisDisplayStyle analysisDisplayStyle = null; // Look for an existing analysis display style with a specific name var collector1 = new FilteredElementCollector(view.Document); ICollection <Element> collection = collector1.OfClass(typeof(AnalysisDisplayStyle)).ToElements(); var displayStyle = from element in collection where element.Name == "CO2e Display Style 1" select element; // If display style does not already exist in the document, create it if (displayStyle.Count() == 0) { var coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings { ShowGridLines = false }; var colorSettings = new AnalysisDisplayColorSettings(); var deepRed = new Color(166, 0, 0); var red = new Color(255, 44, 01); var orange = new Color(255, 179, 0); var green = new Color(0, 253, 0); var lightGreen = new Color(128, 255, 12); colorSettings.MaxColor = deepRed; colorSettings.SetIntermediateColors(new List <AnalysisDisplayColorEntry> { new AnalysisDisplayColorEntry(green), new AnalysisDisplayColorEntry(orange), new AnalysisDisplayColorEntry(red) }); colorSettings.MinColor = lightGreen; var legendSettings = new AnalysisDisplayLegendSettings { NumberOfSteps = 10, Rounding = 0.05, ShowDataDescription = false, ShowLegend = true }; var collector2 = new FilteredElementCollector(view.Document); ICollection <Element> elementCollection = collector2.OfClass(typeof(TextNoteType)).ToElements(); var textElements = from element in collector2 where element.Name == "LegendText" select element; // if LegendText exists, use it for this Display Style if (textElements.Count() > 0) { var textType = textElements.Cast <TextNoteType>().ElementAt(0); legendSettings.SetTextTypeId(textType.Id, view.Document); } analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(view.Document, "CO2e Display Style 1", coloredSurfaceSettings, colorSettings, legendSettings); } else { analysisDisplayStyle = displayStyle.Cast <AnalysisDisplayStyle>().ElementAt(0); } // now assign the display style to the view view.AnalysisDisplayStyleId = analysisDisplayStyle.Id; t.Commit(); }
public void SetCO2eAnalysisDisplayStyle(View view) { var t = new Transaction(view.Document); t.Start("SetCO2eAnalysisDisplayStyle"); AnalysisDisplayStyle analysisDisplayStyle = null; // Look for an existing analysis display style with a specific name var collector1 = new FilteredElementCollector(view.Document); ICollection<Element> collection = collector1.OfClass(typeof(AnalysisDisplayStyle)).ToElements(); var displayStyle = from element in collection where element.Name == "CO2e Display Style 1" select element; // If display style does not already exist in the document, create it if (displayStyle.Count() == 0) { var coloredSurfaceSettings = new AnalysisDisplayColoredSurfaceSettings { ShowGridLines = false }; var colorSettings = new AnalysisDisplayColorSettings(); var deepRed = new Color(166, 0, 0); var red = new Color(255, 44, 01); var orange = new Color(255, 179, 0); var green = new Color(0, 253, 0); var lightGreen = new Color(128, 255, 12); colorSettings.MaxColor = deepRed; colorSettings.SetIntermediateColors(new List<AnalysisDisplayColorEntry> { new AnalysisDisplayColorEntry(green), new AnalysisDisplayColorEntry(orange), new AnalysisDisplayColorEntry(red) }); colorSettings.MinColor = lightGreen; var legendSettings = new AnalysisDisplayLegendSettings { NumberOfSteps = 10, Rounding = 0.05, ShowDataDescription = false, ShowLegend = true }; var collector2 = new FilteredElementCollector(view.Document); ICollection<Element> elementCollection = collector2.OfClass(typeof(TextNoteType)).ToElements(); var textElements = from element in collector2 where element.Name == "LegendText" select element; // if LegendText exists, use it for this Display Style if (textElements.Count() > 0) { var textType = textElements.Cast<TextNoteType>().ElementAt(0); legendSettings.SetTextTypeId(textType.Id, view.Document); } analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(view.Document, "CO2e Display Style 1", coloredSurfaceSettings, colorSettings, legendSettings); } else { analysisDisplayStyle = displayStyle.Cast<AnalysisDisplayStyle>().ElementAt(0); } // now assign the display style to the view view.AnalysisDisplayStyleId = analysisDisplayStyle.Id; t.Commit(); }