I am working on exporting the vertices of all walls.
I manage to output the results, but every wall has the same set of vertices.
I used the approach of getting the edges of the element but that consisted of 92 endpoints per wall which cannot be correct on the basic walls I use.
Then I used the approach of getting the faces and getting the Mesh out of it and then the Vertices via the Vertices property.
This delivered 28 vertices which is correct for some walls, but the coordinates were all the same for every element.
How do I approach this in a correct way?
My code:
FilteredElementCollector wallcollector = new FilteredElementCollector(doc).OfClass(typeof(Wall)).WhereElementIsNotElementType();
bool isconcrete = false;
foreach (var element in wallcollector.ToElements())
{
foreach (var mat in element.GetMaterialIds(false))
{
if (doc.GetElement(mat).Name.Contains("Concrete")) isconcrete = true;
}
if (isconcrete)
{
GeometryElement geo = element.get_Geometry(new Options());
if (geo != null)
{
foreach (var g in geo)
{
Solid geosolid = g as Solid;
if (geosolid != null)
{
foreach (Face f in geosolid.Faces)
{
Mesh mesh = f.Triangulate();
foreach (var xyz in mesh.Vertices)
{
FillDictionary(xyz, element);
}
}
}
}
}
}
}
I don't think my iteration is wrong since i basically just foreach everything, but maybe there is some hidden error i cannot see. I use dictionaries to store my data. Here is how I fill it:
public void FillDictionary(XYZ point, Element element) {
if (element.Id.IntegerValue == formerid)
{
cornerByID[element.UniqueId].Add(ttr.OfPoint(point));
}
else
{
cornerlist.Clear();
cornerlist.Add(element.Name);
cornerlist.Add(element);
cornerlist.Add(element.Id);
cornerlist.Add(ttr.OfPoint(point));
cornerByID.Add(element.UniqueId, cornerlist);
formerid = element.Id.IntegerValue;
}
}
If you use a dictionary with XYZ
object keys, you need to implement fuzzy comparison to compare the keys.
Here is an example of a Geometry Traversal to Retrieve Unique Vertices.
I make use of it in my structural concrete setout point add-in.