Bounding Box Issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When I use bounding box for joining wall and structural framing, while joining it its shows warning that Highlighted elements are joined but do not intersect.
This is because of the structural framing bounding box is joined to wall bounding box,but not actual structural framing and wall has been Intersect.
I want to join wall and structural framing and also use bounding box for this.I want the bounding box is equal to actual length of structural framing that means structural framing and bounding box boundary is same. How I do this without changing revit model only bounding box boundary is equal to actual element length?
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace JoinGeometry
{
[Transaction(TransactionMode.Manual)]
class WBjoin
{
bool check;
public Result Execute(ExternalCommandData commandData)
{
UIApplication uiApp = commandData.Application;
UIDocument uidoc = uiApp.ActiveUIDocument;
Document doc = uidoc.Document;
//--get walls on the active view-----------
FilteredElementCollector collWalls = new FilteredElementCollector(doc, doc.ActiveView.Id);
collWalls.OfClass(typeof(Wall));
try
{
foreach (Wall w in collWalls)
{
FilteredElementCollector wallbeam = new FilteredElementCollector(doc, doc.ActiveView.Id);
wallbeam.OfClass(typeof(FamilyInstance));
wallbeam.OfCategory(BuiltInCategory.OST_StructuralFraming);
BoundingBoxXYZ bb = w.get_BoundingBox(doc.ActiveView);
Outline outline = new Outline(bb.Min,bb.Max);
BoundingBoxIntersectsFilter bbfilter =
new BoundingBoxIntersectsFilter(outline);
wallbeam.WherePasses(bbfilter);
foreach (FamilyInstance bem in wallbeam)
{
using (Transaction t = new Transaction(doc, "Join All Walls/beam"))
{
t.Start();
check = JoinGeometryUtils.AreElementsJoined(doc, w, bem);
if (check == true)
{
}
else
{
JoinGeometryUtils.JoinGeometry(doc, w, bem);
}
t.Commit();
}
}
}
}
catch
{
TaskDialog.Show("Revit", "not join");
}
return Result.Succeeded;
}
}
}
What changes I want to do in the code for this?