DirectShape.ByGeometry Failing - Dont know why

Hi - I’m fairly new to dynamo so hopefully this should be an easy fix. I’m trying to generate volumetric massing of the rooms in a model and then colour them according to their volume and/or function.

I’ve got as far as generating the geometry but my directshape.bygeometry stopped working shortly after. It’s giving the message:
*Warning: DirectShape.ByGeometry operation failed. *
The referenced object is not valid, possibly because it has been deleted from the database, or its creation was undone.

Here’s the setup in question:

Any help and explanation would be greatly appreciated!

Generally, when you use a node for creation, and then undo it in Revit and try to re-perform the automation in Dynamo, it sometimes holds onto that original set of data. That error is telling you that we’ve created this object in Revit and it’s been deleted or you’ve hit the undo button thus, we can’t do anything with it because we can’t find it.

You can either A. save, close, open and re run the graph again, or B find where elements are being created in the graph probably on the direct shape node, disconnect the geometry input (I don’t think it matters, but I tend to disconnect the node where the “create” stuff goes, in this case geometry) temporarily, run the graph, re connect the geometry input, then run again so Dynamo can create whatever was undone or deleted in Revit to re perform the tasks set in front of it.

I hope that made sense!