JoinGeometry for walls and columns

By Augusto Goncalves (@augustomaia)

I was actually looking for a sample of JoinGeometry on the blogs and could not find one, so here it is.

This method, like many others on the API, mimic the UI behavior: it requires 2 elements to join. So the ‘trick’ is find those elements. For this sample, let’s assume we have a model with walls and columns to join. We cannot call join for all walls and columns, it’s a exponential problem. Jeremy wrote a cool sample that help us find intersecting elements, so let’s use it.

Basically just get all Walls, then for each wall, get intersecting Columns (via Bounding Box) and call JoinGeometry for these 2 elements.

UIApplication uiapp = commandData.Application;UIDocument uidoc = uiapp.ActiveUIDocument;Application app = uiapp.Application;Document doc = uidoc.Document; // get all walls on the active viewFilteredElementCollector collWalls =   new FilteredElementCollector(doc, doc.ActiveView.Id);collWalls.OfClass(typeof(Wall)); foreach (Wall w in collWalls){  // get columns on the active view  FilteredElementCollector collColumnsOnThisWall =    new FilteredElementCollector(doc, doc.ActiveView.Id);  collColumnsOnThisWall.OfClass(typeof(FamilyInstance));  collColumnsOnThisWall.OfCategory(    BuiltInCategory.OST_StructuralColumns);   // as we don't want all columns, let's filter  // by the wall bounding box (intersect)  BoundingBoxXYZ bb = w.get_BoundingBox(doc.ActiveView);  Outline outline = new Outline(bb.Min, bb.Max);  BoundingBoxIntersectsFilter bbfilter =    new BoundingBoxIntersectsFilter(outline);  collColumnsOnThisWall.WherePasses(bbfilter);   // finally, call JOIN on the wall and column  foreach (FamilyInstance column in collColumnsOnThisWall)  {    JoinGeometryUtils.JoinGeometry(doc, w, column);  }}

Comments

One response to “JoinGeometry for walls and columns”

  1. I’d like to thank the author for writing such an insightful and informative blog post about walls and columns that is not just useful to the readers but also revealing.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading