Can not add connetions between walls and floors using Dynamic update

Can not add connetions between walls and floors using Dynamic update

awesomeoneee
Explorer Explorer
284 Views
2 Replies
Message 1 of 3

Can not add connetions between walls and floors using Dynamic update

awesomeoneee
Explorer
Explorer

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:

screenshot.png

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);
        } 

 

 

 

0 Likes
285 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

Maybe your updater is making a change to the model that results in the same updater being triggered again. That would generate an infinite loop if it was not detected and terminated by Revit.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

RPTHOMAS108
Mentor
Mentor

I don't think bounding box intersecting is a good enough indication of if two elements can be joined. There will be an exception if the elements can't be joined. When your geometry is view specific it may not have the full 3D extents you would otherwise expect.

 

Additionally you should probably not show a task dialog in your execute method since Execute may be called multiple times for the same transaction due to changes from other updaters. There is a lot of automatic joining that goes on so there is probably a conflict with that process. Elements of same concrete material are joined automatically. 

 

 

0 Likes