Hey !
I have to retrieve all elements from the document (without the need of a user selection) to get all information about Face, Mesh, Vertex... I have to export those data to a rendering engine. I have no idea how to do that and the only exemples I found are about getting data from a selected element.
Best !
Hi there,
This should help to get back "all" the elements: http://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html
But actually it seems you only need the visible elements:
IList<Element> GetAllModelElements( Document doc ) { List<Element> elements = new List<Element>(); FilteredElementCollector collector = new FilteredElementCollector( doc ) .WhereElementIsNotElementType(); foreach( Element e in collector ) { if( null != e.Category && e.Category.HasMaterialQuantities ) { elements.Add( e ); } } return elements; }
Then you need to retrieve the geometry from each element you are interested in.
There are many topics on Jeremy's blog concerning this: http://thebuildingcoder.typepad.com/blog/2010/01/analyse-building-geometry.html
I hope this helps.
Adam Nagy
Autodesk Developer Network
It works, thank you so much !
But I'm not sure that I'm using it correctly. Here is my code:
UIApplication uiApplication = cmdData.Application; UIDocument uiDocument = uiApplication.ActiveUIDocument; List<double> listData = new List<double>(); Options geoOptions = uiApplication.Application.Create.NewGeometryOptions(); if (geoOptions != null) { geoOptions.ComputeReferences = true; geoOptions.DetailLevel = DetailLevels.Fine; } List<Element> elements = new List<Element>(); FilteredElementCollector collector = new FilteredElementCollector(uiDocument.Document).WhereElementIsNotElementType(); foreach (Element e in collector) { if (e.Category != null && e.Category.HasMaterialQuantities) { elements.Add(e); } } foreach (Element elem in elements) { GeometryElement geoElement = elem.get_Geometry(geoOptions); // Get geometry object foreach (GeometryObject geoObject in geoElement.Objects) { // Get the geometry instance which contains the geometry information GeometryInstance geometryInstance = geoObject as GeometryInstance; if (geometryInstance != null) { foreach (GeometryObject instObj in geometryInstance.SymbolGeometry.Objects) { Solid solid = instObj as Solid; if (solid == null || solid.Faces.Size == 0) { continue; } Transform transform = geometryInstance.Transform; // Get the faces from solid foreach (Face face in solid.Faces) { Mesh mesh = face.Triangulate(); foreach (XYZ point in mesh.Vertices) { listData.Add(point.X); listData.Add(point.Y); listData.Add(point.Z); } } } } } }
What about getting information about the Transformation ?
Can't find what you're looking for? Ask the community or share your knowledge.