Message 1 of 3
Can not add connetions between walls and floors using Dynamic update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,All
I'm trying to make an add-in which is used to correct(or adjust) the connection between components such as walls, columns, beams and floors after placing. There exists an error while the Dynamic update codes work on a wall trying to make a connection with another floor, and there is no detail message about the error. Any ideas to solve this?
Screenshot:
Key codes below:
public void Execute(UpdaterData data)
{
Document document = data.GetDocument();
List<ElementId> additionElementIds = data.GetAddedElementIds().ToList();
//List<ElementId> modifiedElementIds = data.GetModifiedElementIds().ToList();
View view = document.ActiveView;
foreach (ElementId elementId in additionElementIds)
{
Element element = document.GetElement(elementId);
if (element != null)
{
List<Element> intersectedElements = new FilteredElementCollector(document,view.Id).
WherePasses(GetBoundingBoxIntersectsFilter(element, view)).Where(x => x.Id != elementId).ToList();
if (intersectedElements.Count > 0)
{
foreach (Element intersectedElement in intersectedElements)
{
try
{
JoinGeometryUtils.JoinGeometry(document, element, intersectedElement);
}
catch (Exception ex)
{
TaskDialog.Show("Error", ex.Message.ToString() + "\n" + intersectedElement.GetType().ToString());
continue;
}
}
}
}
}
}
private BoundingBoxIntersectsFilter GetBoundingBoxIntersectsFilter(Element element,View view)
{
XYZ boundingBox_min = element.get_BoundingBox(view).Min;
XYZ boundingBox_max = element.get_BoundingBox(view).Max;
Outline outline = new Outline(boundingBox_min, boundingBox_max);
return new BoundingBoxIntersectsFilter(outline);
}