Workflow infinite loop

I’m working on an implementation of the Opening class as a Dynamo element. Creating an opening works great - can generate shafts through floors, etc, element binding works a treat. But if the geometry I’m using to derive the opening depends on a floor or other element that is cut by the shaft, I run into a problem - dynamo and revit churn for a bit and then crash, hard.

What I suspect is happening is that in run automatic mode the creation of the shaft registers as a change to the floor element, which triggers a new calculation, which regenerates the opening, which registers as a change to the floor element, which triggers a new calculation… infinite loop and death. Are there any mechanisms to avoid this from a developer standpoint? Do I just have to warn the user to watch out and either not derive the opening geometry from the floor, or at least not rely on “run automatic” in that case? @Zach_Kron @Ian_Keough1 (decided not to bug you on twitter for once :-p)

Also - this forum needs a developer category!

Hi @Andrew_Heumann
Take a look at the FamilyInstance.ByFace functionality. I believe this ran into similar issues initially, as face hosted families can cut their host and potentially create a recursive referencing.

Also . . .changed the “Python” category to “Developers”, as the topics seem to encompass that idea

cc @Aparajit_Pratap

Sorry for the delayed reply.

Your idea about what is causing the infinite loop is most likely correct. The way we break these loops in other cases is to check that the result of the operation which is causing the loop, in your case the updating of a shaft, is seen as a no-op as far as the floor is concerned. This most likely requires adding a check to the opening code which checks whether the opening that is being requested is the same as the one that exists. If so, you skip the rest of the update, thereby not causing the floor to be updated. This is assuming that the floor is selected by an upstream node.

Make sense?

Ian Keough

Software Architect
AEC Generative Design

Autodesk, Inc.
23 Drydock Ave.,x-apple-data-detectors://6/1
Boston, MA 02210x-apple-data-detectors://6/1

Mobile 646.621.0026tel:646.621.0026
@ikeough