Skip to content

Commit

Permalink
implemented FilterForSheetsByBrowserOrganisation for https://forums.a…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytammik committed Sep 21, 2021
1 parent 7b97d97 commit 43d4e76
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 36 deletions.
95 changes: 61 additions & 34 deletions BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ public Result Execute(
ElementClassFilter f1
= new ElementClassFilter(
typeof( FamilyInstance ) );

ElementCategoryFilter f2
= new ElementCategoryFilter(
BuiltInCategory.OST_Doors );

ElementCategoryFilter f3
= new ElementCategoryFilter(
BuiltInCategory.OST_Windows );

LogicalOrFilter f4
= new LogicalOrFilter( f2, f3 );

LogicalAndFilter f5
= new LogicalAndFilter( f1, f4 );

FilteredElementCollector collector
= new FilteredElementCollector( doc );

Expand Down Expand Up @@ -639,7 +639,7 @@ List<ElementId> categoriesOnLevel
/// <summary>
/// Return a sorted list of all levels
/// </summary>
IOrderedEnumerable<Level> GetSortedLevels(
IOrderedEnumerable<Level> GetSortedLevels(
Document doc )
{
return new FilteredElementCollector( doc )
Expand Down Expand Up @@ -712,7 +712,7 @@ public static Level GetLevelFor(
// }
//}

level = sorted_levels.FirstOrDefault(
level = sorted_levels.FirstOrDefault(
l => Util.IsLessOrEqual(
l.Elevation, element_z ) );

Expand Down Expand Up @@ -1091,16 +1091,16 @@ public void GetListOfLinestyles( Document doc )
FilteredElementCollector collector
= new FilteredElementCollector( doc );

ElementCategoryFilter fi
= new ElementCategoryFilter(
ElementCategoryFilter fi
= new ElementCategoryFilter(
BuiltInCategory.OST_GenericLines, true );

ICollection<Element> collection
ICollection<Element> collection
= collector.OfClass( typeof( CurveElement ) )
.WherePasses( fi )
.ToElements();

TaskDialog.Show( "Number of curves",
TaskDialog.Show( "Number of curves",
collection.Count.ToString() );

List<Element> detail_lines = new List<Element>();
Expand All @@ -1113,7 +1113,7 @@ ICollection<Element> collection
}
}

TaskDialog.Show( "Number of Detail Lines",
TaskDialog.Show( "Number of Detail Lines",
detail_lines.Count.ToString() );

List<Element> some_detail_lines = new List<Element>();
Expand All @@ -1125,38 +1125,38 @@ ICollection<Element> collection
}
}

TaskDialog.Show(
"Number of Detail Lines of MyNewLineStyle",
TaskDialog.Show(
"Number of Detail Lines of MyNewLineStyle",
some_detail_lines.Count.ToString() );


Category targetLineStyle = null;

IEnumerable<GraphicsStyle> gstyles
IEnumerable<GraphicsStyle> gstyles
= new FilteredElementCollector( doc )
.OfClass( typeof( GraphicsStyle ) )
.Cast<GraphicsStyle>()
.Where( gs => gs.GraphicsStyleCategory.Id.IntegerValue
.Where( gs => gs.GraphicsStyleCategory.Id.IntegerValue
== targetLineStyle.Id.IntegerValue );

ElementId targetGraphicsStyleId
ElementId targetGraphicsStyleId
= gstyles.FirstOrDefault().Id;

CurveElementFilter filter_detail
= new CurveElementFilter(
CurveElementFilter filter_detail
= new CurveElementFilter(
CurveElementType.DetailCurve );

FilterRule frule_typeId
= ParameterFilterRuleFactory.CreateEqualsRule(
new ElementId(
BuiltInParameter.BUILDING_CURVE_GSTYLE ),
FilterRule frule_typeId
= ParameterFilterRuleFactory.CreateEqualsRule(
new ElementId(
BuiltInParameter.BUILDING_CURVE_GSTYLE ),
targetGraphicsStyleId );

ElementParameterFilter filter_type
= new ElementParameterFilter(
ElementParameterFilter filter_type
= new ElementParameterFilter(
new List<FilterRule>() { frule_typeId } );

IEnumerable<Element> lines
IEnumerable<Element> lines
= new FilteredElementCollector( doc )
.WhereElementIsNotElementType()
.WhereElementIsCurveDriven()
Expand Down Expand Up @@ -1185,7 +1185,34 @@ FilteredElementCollector a

doc.Delete( a.ToElementIds() );
}
#endregion // Filter for non-room-separating curve elements
#endregion // Delete non-room-separating curve elements

#region Filter for sheets based on browser organisation
// for https://forums.autodesk.com/t5/revit-api-forum/change-the-sheet-issue-date-on-sheets-filtered-by-project/td-p/10633770
/// <summary>
/// Filter for sheets based on browser organisation
/// </summary>
IEnumerable<ElementId> FilterForSheetsByBrowserOrganisation(
Document doc,
string folder_name )
{
// Dim Els As List(Of ElementId) = FEC.WherePasses(ECF).ToElementIds _
// .Where( Function( k ) bOrg.GetFolderItems( k )( 1 ).Name = "Type 1" ) _
// .ToList

BrowserOrganization bOrg = BrowserOrganization
.GetCurrentBrowserOrganizationForSheets( doc );

IEnumerable<ElementId> ids
= new FilteredElementCollector( doc )
.OfClass( typeof( ViewSheet ) )
.Where( s => bOrg.GetFolderItems( s.Id ).First().Name.Equals(
folder_name ) )
.Select<Element, ElementId>( e => e.Id );

return ids;
}
#endregion // Filter for sheets based on browser organisation

#region Filter for views
FilteredElementCollector GetViews( Document doc )
Expand Down Expand Up @@ -1414,7 +1441,7 @@ public void TestFilterStringContains( Document doc )
ParameterValueProvider provider
= new ParameterValueProvider( pid );

FilterStringRuleEvaluator evaluator
FilterStringRuleEvaluator evaluator
= new FilterStringContains();

//FilterStringRule rule = new FilterStringRule( // 2021
Expand All @@ -1423,14 +1450,14 @@ FilterStringRuleEvaluator evaluator
FilterStringRule rule = new FilterStringRule( // 2022
provider, evaluator, "/" );

ElementParameterFilter filter
ElementParameterFilter filter
= new ElementParameterFilter( rule );

var myWalls = new FilteredElementCollector( doc )
.OfCategory( BuiltInCategory.OST_Walls )
.WherePasses( filter );

List<ElementId> false_positive_ids
List<ElementId> false_positive_ids
= new List<ElementId>();

foreach( Element wall in myWalls )
Expand All @@ -1441,8 +1468,8 @@ List<ElementId> false_positive_ids
false_positive_ids.Add( wall.Id );
}
}
string s = string.Join( ", ",
false_positive_ids.Select<ElementId, string>(
string s = string.Join( ", ",
false_positive_ids.Select<ElementId, string>(
id => id.IntegerValue.ToString() ) );

TaskDialog dlg = new TaskDialog( "False Positives" );
Expand Down Expand Up @@ -1571,8 +1598,8 @@ static IEnumerable<FamilySymbol>
Document doc,
string parameter_name )
{
ICollection<ElementId> ids_family
= ViewSchedule.GetValidFamiliesForNoteBlock(
ICollection<ElementId> ids_family
= ViewSchedule.GetValidFamiliesForNoteBlock(
doc );

IEnumerable<FamilySymbol> symbols
Expand Down
5 changes: 3 additions & 2 deletions BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
// 2021-08-19 2022.0.151.3 integrated pull request #17 by @mmcpt fixing off-by-one error in CreateCurveLoop
// 2021-08-30 2022.0.151.4 eliminated deprecated API usage of NewFloor and NewSlab methods
// 2021-08-30 2022.0.152.0 implemented CmdLog4 to test using Log4Net in a Revit add-in
// 2021-09-21 2022.0.152.1 implemented FilterForSheetsByBrowserOrganisation for https://forums.autodesk.com/t5/revit-api-forum/change-the-sheet-issue-date-on-sheets-filtered-by-project/td-p/10633770
//
[assembly: AssemblyVersion( "2022.0.152.0" )]
[assembly: AssemblyFileVersion( "2022.0.152.0" )]
[assembly: AssemblyVersion( "2022.0.152.1" )]
[assembly: AssemblyFileVersion( "2022.0.152.1" )]

0 comments on commit 43d4e76

Please sign in to comment.