Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytammik committed Jan 6, 2021
1 parent f8a468e commit 8a692a6
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
92 changes: 92 additions & 0 deletions BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,98 @@ FilteredElementCollector collector

collector.OfClass( typeof( DetailCurve ) );
}

public void GetListOfLinestyles( Document doc )
{
Category c = doc.Settings.Categories.get_Item(
BuiltInCategory.OST_Lines );

CategoryNameMap subcats = c.SubCategories;

foreach( Category lineStyle in subcats )
{
TaskDialog.Show( "Line style", string.Format(
"Linestyle {0} id {1}", lineStyle.Name,
lineStyle.Id.ToString() ) );
}


FilteredElementCollector collector
= new FilteredElementCollector( doc );

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

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

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

List<Element> detail_lines = new List<Element>();

foreach( Element e in collection )
{
if( e is DetailLine )
{
detail_lines.Add( e );
}
}

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

List<Element> some_detail_lines = new List<Element>();
foreach( DetailLine dl in detail_lines )
{
if( dl.LineStyle.Name == "MyNewLineStyle" )
{
some_detail_lines.Add( dl );
}
}

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


Category targetLineStyle = null;

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

ElementId targetGraphicsStyleId
= gstyles.FirstOrDefault().Id;

CurveElementFilter filter_detail
= new CurveElementFilter(
CurveElementType.DetailCurve );

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

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

IEnumerable<Element> lines
= new FilteredElementCollector( doc )
.WhereElementIsNotElementType()
.WhereElementIsCurveDriven()
.WherePasses( filter_detail )
.WherePasses( filter_type );
}

#endregion // Filter for detail curves

#region Delete non-room-separating curve elements
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 @@ -356,6 +356,7 @@
// 2021-01-02 2021.0.150.11 implemented CreateConduitOffsets for https://forums.autodesk.com/t5/revit-api-forum/offset-conduit-only-by-z-axis/m-p/9972671
// 2021-01-02 2021.0.150.12 incremented copyright year
// 2021-01-04 2021.0.150.13 implemented CreateConduitOffsets for https://forums.autodesk.com/t5/revit-api-forum/offset-conduit-only-by-z-axis/m-p/9972671
// 2021-01-06 2021.0.150.14 sample code for https://forums.autodesk.com/t5/revit-api-forum/collect-all-detail-lines-of-a-particular-subcategory/td-p/9956260
//
[assembly: AssemblyVersion( "2021.0.150.13" )]
[assembly: AssemblyFileVersion( "2021.0.150.13" )]
[assembly: AssemblyVersion( "2021.0.150.14" )]
[assembly: AssemblyFileVersion( "2021.0.150.14" )]

0 comments on commit 8a692a6

Please sign in to comment.