Hi,
To retrive all visible elements, we referred the following post in ADN forum . This post suggests to use HasMaterialQuantities()
http://forums.autodesk.com/t5/revit-api/retrieving-all-elements/td-p/3377715
But Category::HasMaterialQuantities is returning false for Topography, railings, and similar elements. So, they are missing when we try to get all the revit model elements. Below is the snippet of code that we are trying.
FilteredElementCollector^ allInstances = gcnew FilteredElementCollector( revitDocument );
allInstances = allInstances->WhereElementIsNotElementType();
for each( Element^ element in allInstances )
{
if( element != nullptr && element->Category != nullptr
&& !element->Category->Name->Contains(“Legend Components”)
&& element->Category->HasMaterialQuantities )
{
GeometryElement^ geomElem = element->Geometry::get(geomOption);
if( geomElem != nullptr && geomElem->GetEnumerator()->MoveNext() ) // Check if this geom element genuinely contains geometry
// put element in list
}
}
Any idea on why HasMaterialQuantities () is skipping visible elements like topography, railings etc.
If we remove the HasMaterialQuantities condition, then we are getting the topography, railings along with all other elements, but we also get extra elements such as Rooms, which are not visible in revit project.
So what should be the right approach so that we get all the visible elements without skipping any valid visible elements like topography, railings etc.
Thanks
Sunil
Hi,
To retrive all visible elements, we referred the following post in ADN forum . This post suggests to use HasMaterialQuantities()
http://forums.autodesk.com/t5/revit-api/retrieving-all-elements/td-p/3377715
But Category::HasMaterialQuantities is returning false for Topography, railings, and similar elements. So, they are missing when we try to get all the revit model elements. Below is the snippet of code that we are trying.
FilteredElementCollector^ allInstances = gcnew FilteredElementCollector( revitDocument );
allInstances = allInstances->WhereElementIsNotElementType();
for each( Element^ element in allInstances )
{
if( element != nullptr && element->Category != nullptr
&& !element->Category->Name->Contains(“Legend Components”)
&& element->Category->HasMaterialQuantities )
{
GeometryElement^ geomElem = element->Geometry::get(geomOption);
if( geomElem != nullptr && geomElem->GetEnumerator()->MoveNext() ) // Check if this geom element genuinely contains geometry
// put element in list
}
}
Any idea on why HasMaterialQuantities () is skipping visible elements like topography, railings etc.
If we remove the HasMaterialQuantities condition, then we are getting the topography, railings along with all other elements, but we also get extra elements such as Rooms, which are not visible in revit project.
So what should be the right approach so that we get all the visible elements without skipping any valid visible elements like topography, railings etc.
Thanks
Sunil
Dear Sunil,
I am afraid that you are encountering a basic and incontestable aspect of BIM: it is complex.
It may be hard or impossible to find a simple one-line criteria that satisfies your exact needs.
Here is The Building Coder topic group on Filtering for all Elements that discusses this exact issue:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9
You will probably have to implement some more complex filtering criteria, and possibly handle different groups of elements in different ways.
Here are two examples of simple first stabs at retrieving structural and MEP elements demonstrating such combinations:
http://thebuildingcoder.typepad.com/blog/2010/07/retrieve-structural-elements.html
http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html
You will probably have to implement a similar kind of combined filtering algorithm for your needs.
Many more filtering samples are assembled in The Building Coder samplesCmdCollectorPerformance module:
Also, I am sure that you understand that the next developer's needs will differ ever so slightly from yours, so there cannot be a simple solution for this challenge.
Please let us know how you end up solving this!
Thank you!
Cheers,
Jeremy
Dear Sunil,
I am afraid that you are encountering a basic and incontestable aspect of BIM: it is complex.
It may be hard or impossible to find a simple one-line criteria that satisfies your exact needs.
Here is The Building Coder topic group on Filtering for all Elements that discusses this exact issue:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9
You will probably have to implement some more complex filtering criteria, and possibly handle different groups of elements in different ways.
Here are two examples of simple first stabs at retrieving structural and MEP elements demonstrating such combinations:
http://thebuildingcoder.typepad.com/blog/2010/07/retrieve-structural-elements.html
http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html
You will probably have to implement a similar kind of combined filtering algorithm for your needs.
Many more filtering samples are assembled in The Building Coder samplesCmdCollectorPerformance module:
Also, I am sure that you understand that the next developer's needs will differ ever so slightly from yours, so there cannot be a simple solution for this challenge.
Please let us know how you end up solving this!
Thank you!
Cheers,
Jeremy
Thanks Jeremy for your inputs.
I am now using Custom Exporter for getting all elements and it is serving the purpose. I followed the samples that you have put on Building Coder. And I agree that special filtering logic will be needed for specific elements and there is no one generic logic that can be used. If I encounter any filtering issues with Custome Exporter, i will post them here.
Thank you once more.
Best regards
Sunil
Thanks Jeremy for your inputs.
I am now using Custom Exporter for getting all elements and it is serving the purpose. I followed the samples that you have put on Building Coder. And I agree that special filtering logic will be needed for specific elements and there is no one generic logic that can be used. If I encounter any filtering issues with Custome Exporter, i will post them here.
Thank you once more.
Best regards
Sunil
Dear Sunil,
Yes, that is definitely a sensible way to go.
Thank you and good luck!
Cheers,
Jeremy
Dear Sunil,
Yes, that is definitely a sensible way to go.
Thank you and good luck!
Cheers,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.