Material Collector Running Before Material Is Applied

I have racked my brain trying to figure this one out. The attached script is for calculating the area of selected surfaces. I am having to use the paint method as per a previous post of mine, which seems to be a Revit glitch, when you select a face of an element that has an opening, Revit will randomly either only select the face or select the face and include the area of the opening in with the area of the face. I have not found a way to account for both conditions. Luckily when using the paint method, only the true area of the face is painted and not the area of the opening and I get the area of the material. So at least there is an alternative.

Now for my issue. For some reason, the Element.MaterialCollector node and the python script, which basically does the same thing, fires off before the surface is painted. So the painted area is not returned. I have tried passthrough as you can see and also transaction start and end nodes, but it still doesn’t work. Below is a clip of my graph. My script and a test project (Revit 2020) is attached. Any guidance would be greatly appreciated.

Area of Selected Faces Only.dyn (44.7 KB)
Face selection test.rvt (2.7 MB)

Sounds like a transaction issue.

Wire the results of the node which applies the paint into a Transaction.End and wire that into a Transaction.Start node and then continue from there as if your Transaction.Start was the previous node that applies the paint.

Thanks for quick response Jacob. That worked like a charm. I had actually tried using the Transaction nodes in that sequence, but I had them in place of where the Passthrough nodes are shown. Never thought about placing them directly after the paint face node. Learn something new everyday.
Thanks again for your help!

1 Like