Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add View Filters #1502

Open
wants to merge 136 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 133 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
6525ab7
draft oM classes added
pawelbaran Jan 29, 2024
495685a
draft support for pull of views and view filters added
pawelbaran Jan 29, 2024
48d61ff
draft support for views and view filters added
pawelbaran Jan 29, 2024
08ba4fb
Merge branch 'Revit_Toolkit-#1444-FilterPrototype' of https://github.…
GCRA101 Feb 18, 2024
917cf9f
Add bespoke classes defining graphics settings for new view filters
GCRA101 Feb 19, 2024
fcb57c0
Rename Class FilterWithOverrides to ViewFilterWithOverrides
GCRA101 Feb 19, 2024
1b9d28d
Add FilterRuleType Enumeration
GCRA101 Feb 19, 2024
e70ed56
Move classes FillPattern, FilterRule and LinePattern from Elements to…
GCRA101 Feb 20, 2024
0ed3572
Implement Update of View based on filters and overrides
GCRA101 Feb 20, 2024
561839a
Add minor updates to main classes in Elements namespace
GCRA101 Feb 20, 2024
ae53ef6
Implement Conversion of BHoM classes to Revit
GCRA101 Feb 20, 2024
b38eab0
Add minor updates to BHoM ViewFilterOverrides Class
GCRA101 Feb 20, 2024
54a0143
Update Query/BHoMType.cs class for View and ParameterFilterElement
GCRA101 Feb 20, 2024
07b0fa1
Minor updates to main new classes for View and filtering
GCRA101 Mar 12, 2024
0efa9b0
Merge branch 'Revit_Toolkit-#1444-FilterPrototype' of https://github.…
GCRA101 Apr 18, 2024
4620c1b
Add FilterRuleEvaluatorType Enumeration
GCRA101 Apr 20, 2024
3f2a258
Add FilterValueRule and modify FilterRuleType
GCRA101 Apr 20, 2024
93b92c9
Delete FilterRuleType Enum
GCRA101 Apr 25, 2024
1776342
Create FilterRule classes mirroring Revit API classes
GCRA101 Apr 26, 2024
54d1526
Move FillPattern and LinePattern to the Enums Namespace
GCRA101 Apr 26, 2024
fa49711
Modify BHoM Enum TextComparisonType
GCRA101 Apr 26, 2024
87e275c
Add LevelComparisonType Enumeration
GCRA101 Apr 26, 2024
4b1fa4f
Add conversion methods for FilterMaterialRule and FilterLevelRule in …
GCRA101 Apr 26, 2024
afd0b49
Update conversion of BHoM ViewFilters to Revit Parameter Filter Elements
GCRA101 Apr 26, 2024
4bbea09
Add enum values to TextComparisonType Enumeration
GCRA101 Apr 26, 2024
5cbef88
Update ToRevit ParameterFilterElement with additional TextComparisonT…
GCRA101 Apr 26, 2024
5c832b1
Add adapter code for FilterRules in ViewFilterFromRevit Method in Fro…
GCRA101 Apr 27, 2024
c329c72
Add FilterElementIdRule to the Revit BHoM Objects
GCRA101 Apr 28, 2024
6685f06
Add handling of FilterElementIdRule in conversion of ViewFilter From …
GCRA101 Apr 28, 2024
764157a
Initialize FilterRule Classes in FromRevit and ToRevit Namespaces
GCRA101 Apr 28, 2024
5338ba9
Delete all FilterRule classes created in the Convert.FromRevit/ToRevi…
GCRA101 Apr 28, 2024
29c3c1b
Reinstate the method filterCategoryRuleToRevit in the Convert.ToRevit…
GCRA101 Apr 28, 2024
41d425e
Add method to convert a Revit ParameterFilterElement into a BHoM View…
GCRA101 Apr 28, 2024
0186d7f
Incorporate minor fixes to references between classes
GCRA101 Apr 28, 2024
e0e27b2
Add ParameterValuePresenceRule
GCRA101 Apr 28, 2024
78306b0
Move all BHoM Filter Rules from oM.Elements to oM.FilterRules namespace.
GCRA101 Aug 19, 2024
4d56096
Refactor the partial class FromRevit.ViewFilter
GCRA101 Aug 19, 2024
0984037
Fix code for conversion of Revit Views into BHoM Views
GCRA101 Aug 19, 2024
69841b2
Make explicit distinction between Revit and BHoM View Class instances
GCRA101 Aug 19, 2024
5fefeed
Add conversion of BHoM FilterRule to Revit FilterRule
GCRA101 Aug 20, 2024
0c033a8
Fix bug with extraction of revit Id of selected parameter
GCRA101 Aug 20, 2024
23f5cae
Fix code for conversion of filterRules from BHoM to Revit_Core_Engine…
GCRA101 Aug 21, 2024
d60bfe5
Add call to method for convertion of FilterLevelRule to Revit.
GCRA101 Aug 21, 2024
bedbda8
Fix bug in creation of Revit Element Filter from BHoM FilterRules
GCRA101 Aug 21, 2024
a87ea3f
Add changes to Level and Material FilterRule Conversion
GCRA101 Aug 21, 2024
86d35dd
Fix bug with Push of View Filters based on Levels
GCRA101 Aug 21, 2024
1580cd6
Fix bug dispatching different types of FilterRule
GCRA101 Aug 27, 2024
07ab5b5
Turn FilterNumericValueRule into an abstract class
GCRA101 Aug 27, 2024
1fb229a
Fix bug related to incorrect extraction of Categories from the model.
GCRA101 Aug 27, 2024
06532f6
Add feature to create ViewFilters with No Rules.
GCRA101 Aug 27, 2024
55f414c
Fix code for extraction of categories and filter rules from Revit whe…
GCRA101 Aug 28, 2024
13a9772
Add GetParameterById Utility function and minor updates to parameter …
GCRA101 Aug 28, 2024
f6cdfc0
Add use of utility function GetParameterById where required to get pa…
GCRA101 Aug 28, 2024
fc1f664
Add conversion of double internal units when pulling filter parameter…
GCRA101 Aug 28, 2024
8ad2801
Add Update Method for Autodesk Revit View3D Class
GCRA101 Sep 2, 2024
463807e
Turn Update Methods for View and View3D into a single method using Ge…
GCRA101 Sep 2, 2024
42cd96d
Fix Fill and Line Pattern Name search turning letter case to Upper
GCRA101 Sep 2, 2024
9d17a6e
Fix bug text comparison between Cut and Surface Patterns
GCRA101 Sep 2, 2024
f7f8cdc
event suppression added
pawelbaran Sep 3, 2024
df3249e
Event suppression added to methods parsing properties of SpecTypeId a…
pawelbaran Sep 5, 2024
0edce3f
Update assembly file version to 8.0.0.0 and AssemblyVersion to 8.0.0.0
BHoMBot Sep 20, 2024
5a06ccf
Remove previous version attributes for 8.0
BHoMBot Sep 20, 2024
869f2de
Start of milestone changes for 8.0 (#1506)
adecler Sep 23, 2024
4be195d
Incorporate PR comments from Pawel Baran - Part01
GCRA101 Oct 14, 2024
a2f6205
Add new abstract class FilterParameterRule
GCRA101 Oct 14, 2024
b348415
Incorporate PR comments from Pawel Baran - Part02
GCRA101 Oct 15, 2024
5486724
Incorporate comments from Pawel Baran - Part03
GCRA101 Oct 15, 2024
3338dac
Incorporate PR Comments from Pawel Baran - Part04
GCRA101 Oct 15, 2024
7abafcc
draft oM classes added
pawelbaran Jan 29, 2024
919b232
draft support for pull of views and view filters added
pawelbaran Jan 29, 2024
584b00a
draft support for views and view filters added
pawelbaran Jan 29, 2024
5fe79b2
Add bespoke classes defining graphics settings for new view filters
GCRA101 Feb 19, 2024
35ea7fa
Rename Class FilterWithOverrides to ViewFilterWithOverrides
GCRA101 Feb 19, 2024
042e1b9
Add FilterRuleType Enumeration
GCRA101 Feb 19, 2024
e0d96d6
Move classes FillPattern, FilterRule and LinePattern from Elements to…
GCRA101 Feb 20, 2024
4a7247e
Implement Update of View based on filters and overrides
GCRA101 Feb 20, 2024
4031e85
Add minor updates to main classes in Elements namespace
GCRA101 Feb 20, 2024
970b4f2
Implement Conversion of BHoM classes to Revit
GCRA101 Feb 20, 2024
b4724ed
Add minor updates to BHoM ViewFilterOverrides Class
GCRA101 Feb 20, 2024
3cf7985
Update Query/BHoMType.cs class for View and ParameterFilterElement
GCRA101 Feb 20, 2024
99691d4
Minor updates to main new classes for View and filtering
GCRA101 Mar 12, 2024
cd9f1aa
Add FilterRuleEvaluatorType Enumeration
GCRA101 Apr 20, 2024
214fb7e
Add FilterValueRule and modify FilterRuleType
GCRA101 Apr 20, 2024
a8a6590
Delete FilterRuleType Enum
GCRA101 Apr 25, 2024
620b9c7
Create FilterRule classes mirroring Revit API classes
GCRA101 Apr 26, 2024
045991f
Move FillPattern and LinePattern to the Enums Namespace
GCRA101 Apr 26, 2024
e084976
Modify BHoM Enum TextComparisonType
GCRA101 Apr 26, 2024
45d9b1c
Add LevelComparisonType Enumeration
GCRA101 Apr 26, 2024
ebe8d7b
Add conversion methods for FilterMaterialRule and FilterLevelRule in …
GCRA101 Apr 26, 2024
e851805
Update conversion of BHoM ViewFilters to Revit Parameter Filter Elements
GCRA101 Apr 26, 2024
92f256f
Add enum values to TextComparisonType Enumeration
GCRA101 Apr 26, 2024
b15705b
Update ToRevit ParameterFilterElement with additional TextComparisonT…
GCRA101 Apr 26, 2024
f14e530
Add adapter code for FilterRules in ViewFilterFromRevit Method in Fro…
GCRA101 Apr 27, 2024
167de7a
Add FilterElementIdRule to the Revit BHoM Objects
GCRA101 Apr 28, 2024
49cb7b6
Add handling of FilterElementIdRule in conversion of ViewFilter From …
GCRA101 Apr 28, 2024
d4aa31a
Initialize FilterRule Classes in FromRevit and ToRevit Namespaces
GCRA101 Apr 28, 2024
f65b802
Delete all FilterRule classes created in the Convert.FromRevit/ToRevi…
GCRA101 Apr 28, 2024
0d761a2
Reinstate the method filterCategoryRuleToRevit in the Convert.ToRevit…
GCRA101 Apr 28, 2024
4c9918d
Add method to convert a Revit ParameterFilterElement into a BHoM View…
GCRA101 Apr 28, 2024
223768c
Incorporate minor fixes to references between classes
GCRA101 Apr 28, 2024
0c1c4bf
Add ParameterValuePresenceRule
GCRA101 Apr 28, 2024
76bf7ec
Move all BHoM Filter Rules from oM.Elements to oM.FilterRules namespace.
GCRA101 Aug 19, 2024
aecfb01
Refactor the partial class FromRevit.ViewFilter
GCRA101 Aug 19, 2024
7ca2b5c
Fix code for conversion of Revit Views into BHoM Views
GCRA101 Aug 19, 2024
0ce26f7
Make explicit distinction between Revit and BHoM View Class instances
GCRA101 Aug 19, 2024
8bfe55d
Add conversion of BHoM FilterRule to Revit FilterRule
GCRA101 Aug 20, 2024
7f22f9d
Fix bug with extraction of revit Id of selected parameter
GCRA101 Aug 20, 2024
f99df39
Fix code for conversion of filterRules from BHoM to Revit_Core_Engine…
GCRA101 Aug 21, 2024
65f491b
Add call to method for convertion of FilterLevelRule to Revit.
GCRA101 Aug 21, 2024
a4a98af
Fix bug in creation of Revit Element Filter from BHoM FilterRules
GCRA101 Aug 21, 2024
5aeb945
Add changes to Level and Material FilterRule Conversion
GCRA101 Aug 21, 2024
3fe9b8f
Fix bug with Push of View Filters based on Levels
GCRA101 Aug 21, 2024
ccb18c5
Fix bug dispatching different types of FilterRule
GCRA101 Aug 27, 2024
dcf3b32
Turn FilterNumericValueRule into an abstract class
GCRA101 Aug 27, 2024
1ba1bca
Fix bug related to incorrect extraction of Categories from the model.
GCRA101 Aug 27, 2024
afc9460
Add feature to create ViewFilters with No Rules.
GCRA101 Aug 27, 2024
b172fb2
Fix code for extraction of categories and filter rules from Revit whe…
GCRA101 Aug 28, 2024
71f2d47
Add GetParameterById Utility function and minor updates to parameter …
GCRA101 Aug 28, 2024
bb2b11c
Add use of utility function GetParameterById where required to get pa…
GCRA101 Aug 28, 2024
4e5f8f9
Add conversion of double internal units when pulling filter parameter…
GCRA101 Aug 28, 2024
4796b12
Add Update Method for Autodesk Revit View3D Class
GCRA101 Sep 2, 2024
e236c32
Turn Update Methods for View and View3D into a single method using Ge…
GCRA101 Sep 2, 2024
9853368
Fix Fill and Line Pattern Name search turning letter case to Upper
GCRA101 Sep 2, 2024
bdde33f
Fix bug text comparison between Cut and Surface Patterns
GCRA101 Sep 2, 2024
d56be5b
Incorporate PR comments from Pawel Baran - Part01
GCRA101 Oct 14, 2024
4767a61
Add new abstract class FilterParameterRule
GCRA101 Oct 14, 2024
a6e0960
Incorporate PR comments from Pawel Baran - Part02
GCRA101 Oct 15, 2024
a2377a6
Incorporate comments from Pawel Baran - Part03
GCRA101 Oct 15, 2024
fbdae30
Incorporate PR Comments from Pawel Baran - Part04
GCRA101 Oct 15, 2024
518a274
Incorporate PR comments from Pawel Baran - Part 05
GCRA101 Oct 15, 2024
a521793
Merge modifications
GCRA101 Oct 15, 2024
a75cff0
Fix merge conflict
GCRA101 Oct 15, 2024
53b434e
Fix minor bugs with dynamic casting and conversion between Category E…
GCRA101 Oct 16, 2024
b36aaa2
Update name of method OverrideGraphicSettings#fromRevit based on Pasc…
GCRA101 Oct 16, 2024
94b1712
Remove FilterRule downcasting and use of generic T type in Update Met…
GCRA101 Oct 16, 2024
501e2c2
Replace Try-catch statements with If-then statments for controlling e…
GCRA101 Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Revit_Adapter/Revit_Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/Revit_Toolkit</Description>
<Version>6.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Adapter.Revit</RootNamespace>
<FileVersion>7.3.0.0</FileVersion>
<FileVersion>8.0.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Revit_Core_Adapter/Revit_Core_Adapter.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/Revit_Toolkit</Description>
<Version>6.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Revit.Adapter.Core</RootNamespace>
<FileVersion>7.3.0.0</FileVersion>
<FileVersion>8.0.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
22 changes: 22 additions & 0 deletions Revit_Core_Engine/Convert/FromRevit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ public static IGeometry IFromRevit(this Location location)
/**** Convert Revit elements to BHoM ****/
/***************************************************/

[Description("Converts a Revit ParameterFilterElement to a BHoM object based on the requested engineering discipline.")]
[Input("parameterFilterElement", "Revit ParameterFilterElement to be converted.")]
[Input("discipline", "Engineering discipline based on the BHoM discipline classification.")]
[Input("transform", "Optional, a transform to apply to the converted object.")]
[Input("settings", "Revit adapter settings to be used while performing the convert.")]
[Input("refObjects", "Optional, a collection of objects already processed in the current adapter action, stored to avoid processing the same object more than once.")]
[Output("fromRevit", "Resulted BHoM object converted from a Revit ParameterFilterElement.")]
public static List<IBHoMObject> FromRevit(this ParameterFilterElement parameterFilterElement, Discipline discipline, Transform transform = null, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
if (parameterFilterElement == null)
{
BH.Engine.Base.Compute.RecordWarning("BHoM object could not be read because Revit Parameter Filter Element is null.");
return null;
}
else
{
return new List<IBHoMObject> { ViewFilterFromRevit(parameterFilterElement, settings, refObjects) };
}
}

/***************************************************/

[Description("Converts a Revit EnergyAnalysisDetailModel to a BHoM object based on the requested engineering discipline.")]
[Input("energyAnalysisModel", "Revit EnergyAnalysisDetailModel to be converted.")]
[Input("discipline", "Engineering discipline based on the BHoM discipline classification.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static DraftingInstance DraftingInstanceFromRevit(this FilledRegion fille
if (draftingInstance != null)
return draftingInstance;

View view = filledRegion.Document.GetElement(filledRegion.OwnerViewId) as View;
GCRA101 marked this conversation as resolved.
Show resolved Hide resolved
Autodesk.Revit.DB.View view = filledRegion.Document.GetElement(filledRegion.OwnerViewId) as Autodesk.Revit.DB.View;
if (view == null)
return null;

Expand Down
2 changes: 1 addition & 1 deletion Revit_Core_Engine/Convert/Revit/FromRevit/IInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static IInstance InstanceFromRevit(this CurveElement curveElement, RevitS

if (curveElement.ViewSpecific)
{
View view = curveElement.Document.GetElement(curveElement.OwnerViewId) as View;
GCRA101 marked this conversation as resolved.
Show resolved Hide resolved
Autodesk.Revit.DB.View view = curveElement.Document.GetElement(curveElement.OwnerViewId) as Autodesk.Revit.DB.View;
if (view == null)
return null;

Expand Down
164 changes: 164 additions & 0 deletions Revit_Core_Engine/Convert/Revit/FromRevit/View.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using Autodesk.Revit.DB;
using BH.Engine.Adapters.Revit;
using BH.oM.Adapters.Revit.Elements;
using BH.oM.Adapters.Revit.Settings;
using BH.oM.Base;
using BH.oM.Base.Attributes;
using BH.oM.Revit.Enums;
using BH.oM.Revit.Views;
using BH.Revit.Engine.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Security.Policy;
using System.Xml.Linq;
using FilterRule = BH.oM.Revit.FilterRules.FilterRule;
using OverrideGraphicSettings = BH.oM.Adapters.Revit.Elements.OverrideGraphicSettings;
using View = Autodesk.Revit.DB.View;

namespace BH.Revit.Engine.Core
{
public static partial class Convert
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Converts a Revit View to BH.oM.Adapters.Revit.Elements.View.")]
[Input("revitView", "Revit View to be converted.")]
[Input("settings", "Revit adapter settings to be used while performing the convert.")]
[Input("refObjects", "Optional, a collection of objects already processed in the current adapter action, stored to avoid processing the same object more than once.")]
[Output("view", "BH.oM.Adapters.Revit.Elements.View resulting from converting the input Revit View.")]
public static oM.Adapters.Revit.Elements.View ViewFromRevit(this View revitView, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
settings = settings.DefaultIfNull();

oM.Adapters.Revit.Elements.View view = refObjects.GetValue<oM.Adapters.Revit.Elements.View>(revitView.Id.IntegerValue);
if (view != null)
return view;

if (revitView.AreGraphicsOverridesAllowed()) {
/*1. Transfer ViewFilters and corresponding OverrideGraphicSettings into ViewFilterWithOverrides Objects - via STREAMS */
List<ViewFilterWithOverrides> filtersWithOverrides = revitView.GetFilters().ToDictionary<ElementId, ViewFilter, OverrideGraphicSettings>
(elId => Convert.ViewFilterFromRevit((ParameterFilterElement)revitView.Document.GetElement(elId)),
elId => overrideGraphicSettingsFromRevit(revitView, revitView.GetFilterOverrides(elId))).ToList()
.Select(kvp => new ViewFilterWithOverrides { Filter = kvp.Key, Overrides = kvp.Value }).ToList();
/*2. Create BHoM View Object with Name and FilterWithOverrides objects */
view = new oM.Adapters.Revit.Elements.View { Name = revitView.Name, FiltersWithOverrides = filtersWithOverrides };}
else { view = new oM.Adapters.Revit.Elements.View { Name=revitView.Name };}

//Set identifiers, parameters & custom data
view.SetIdentifiers(revitView);
view.CopyParameters(revitView, settings.MappingSettings);
view.SetProperties(revitView, settings.MappingSettings);

refObjects.AddOrReplace(revitView.Id, view);
return view;
}

/***************************************************/

private static OverrideGraphicSettings overrideGraphicSettingsFromRevit(this View element, Autodesk.Revit.DB.OverrideGraphicSettings revitOverrides)

Check failure on line 85 in Revit_Core_Engine/Convert/Revit/FromRevit/View.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Revit_Core_Engine/Convert/Revit/FromRevit/View.cs#L85

Method name should start with an uppercase letter - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/MethodNameStartsUpper
GCRA101 marked this conversation as resolved.
Show resolved Hide resolved
{
// Initialize BHoM OverrideGraphicsSettings object
OverrideGraphicSettings overrideGraphicsSettings = new OverrideGraphicSettings();


// Convert COLORS
if (revitOverrides.CutLineColor.IsValid) overrideGraphicsSettings.LineColor = System.Drawing.Color.FromArgb(revitOverrides.CutLineColor.Red, revitOverrides.CutLineColor.Green, revitOverrides.CutLineColor.Blue);
if (revitOverrides.CutForegroundPatternColor.IsValid) overrideGraphicsSettings.CutColor = System.Drawing.Color.FromArgb(revitOverrides.CutBackgroundPatternColor.Red, revitOverrides.CutBackgroundPatternColor.Green, revitOverrides.CutBackgroundPatternColor.Blue);
if (revitOverrides.SurfaceBackgroundPatternColor.IsValid) overrideGraphicsSettings.SurfaceColor = System.Drawing.Color.FromArgb(revitOverrides.SurfaceBackgroundPatternColor.Red, revitOverrides.SurfaceBackgroundPatternColor.Green, revitOverrides.SurfaceBackgroundPatternColor.Blue);

// Convert LINE PATTERNS
try
{
String linePatternName = element.Document.GetElement(revitOverrides.CutLinePatternId).Name;
GCRA101 marked this conversation as resolved.
Show resolved Hide resolved

if (linePatternName.Replace(" ","").ToUpper().Contains("DASHDOTDOT")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.DashDotDot; }
else if (linePatternName.ToUpper().Replace(" ","").Contains("DASHDOT")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.DashDot; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("DOUBLEDASH")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.DoubleDash; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("LONGDASH")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.LongDash; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("LOOSEDASH")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.LooseDash; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("TRIPLEDASH")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.TripleDash; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("DASH")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.Dash; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("DOT")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.Dot; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("HIDDEN")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.Hidden; }
else if (linePatternName.ToUpper().Replace(" ", "").Contains("SOLID")) { overrideGraphicsSettings.LinePattern = oM.Revit.Enums.LinePattern.Solid; }
else { BH.Engine.Base.Compute.RecordWarning($"The Revit Line Pattern {linePatternName} is not implemented yet in the BHoM.\n By default, the Line Pattern {linePatternName} will be set to SOLID."); }
}
catch
{
BH.Engine.Base.Compute.RecordWarning($"The Revit Line Pattern for the Revit OverrideGraphicSettings {revitOverrides.ToString()} is not defined.");
}


// Convert CUT PATTERNS
try
{
String cutPatternName = element.Document.GetElement(revitOverrides.CutBackgroundPatternId).Name;

if (cutPatternName.ToUpper().Contains("CROSSHATCH") && !cutPatternName.ToUpper().Contains("DIAGONAL")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.CrossHatch; }
else if (cutPatternName.ToUpper().Contains("CROSSHATCH") && cutPatternName.ToUpper().Contains("DIAGONAL")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.DiagonalCrossHatch; }
else if (cutPatternName.ToUpper().Contains("DIAGONAL") && cutPatternName.ToUpper().Contains("DOWN")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.DiagonalDown; }
else if (cutPatternName.ToUpper().Contains("DIAGONAL") && cutPatternName.ToUpper().Contains("UP")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.DiagonalUp; }
else if (cutPatternName.ToUpper().Contains("HORIZONTAL")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.Horizontal; }
else if (cutPatternName.ToUpper().Contains("STEEL")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.Steel; }
else if (cutPatternName.ToUpper().Contains("SOLID")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.Solid; }
else if (cutPatternName.ToUpper().Contains("VERTICAL")) { overrideGraphicsSettings.CutPattern = oM.Revit.Enums.FillPattern.Vertical; }
else { BH.Engine.Base.Compute.RecordWarning($"The Revit Fill Pattern {cutPatternName} is not implemented yet in the BHoM.\n By default, the Fill Pattern {cutPatternName} will be set to SOLID."); }
}
catch
{
BH.Engine.Base.Compute.RecordWarning($"The Revit Fill Pattern for the Revit OverrideGraphicSettings {revitOverrides.ToString()} is not defined.");
}


// Convert SURFACE PATTERNS
try
{
String surfacePatternName = element.Document.GetElement(revitOverrides.SurfaceBackgroundPatternId).Name;

if (surfacePatternName.ToUpper().Contains("CROSSHATCH") && !surfacePatternName.ToUpper().Contains("DIAGONAL")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.CrossHatch; }
else if (surfacePatternName.ToUpper().Contains("CROSSHATCH") && surfacePatternName.ToUpper().Contains("DIAGONAL")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.DiagonalCrossHatch; }
else if (surfacePatternName.ToUpper().Contains("DIAGONAL") && surfacePatternName.ToUpper().Contains("DOWN")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.DiagonalDown; }
else if (surfacePatternName.ToUpper().Contains("DIAGONAL") && surfacePatternName.ToUpper().Contains("UP")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.DiagonalUp; }
else if (surfacePatternName.ToUpper().Contains("HORIZONTAL")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.Horizontal; }
else if (surfacePatternName.ToUpper().Contains("STEEL")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.Steel; }
else if (surfacePatternName.ToUpper().Contains("SOLID")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.Solid; }
else if (surfacePatternName.ToUpper().Contains("VERTICAL")) { overrideGraphicsSettings.SurfacePattern = oM.Revit.Enums.FillPattern.Vertical; }
else { BH.Engine.Base.Compute.RecordWarning($"The Revit Fill Pattern {surfacePatternName} is not implemented yet in the BHoM.\n By default, the Fill Pattern {surfacePatternName} will be set to SOLID."); }
}
catch
{
BH.Engine.Base.Compute.RecordWarning($"The Revit Fill Pattern for the Revit OverrideGraphicSettings {revitOverrides.ToString()} is not defined.");
}

return overrideGraphicsSettings;
}

}
}
Loading