Directshape.bygeometry operation effect is overwritten

The second run result of the ‘directshape. bygeometry’ node will overwrite the previous run result. I tried to replace the node with a Python node, but the effect was not very ideal: I wanted to color the element, but the element created with a Python node did not have a very good coloring effect.

Here is my Python script script:

category = ElementId(BuiltInCategory.OST_GenericModel)
geometry = IN[0].ToRevitType()
TransactionManager.Instance.EnsureInTransaction(DOC)

direct_shape = DirectShape.CreateElement(DOC, category)
direct_shape.SetShape(geometry)
TransactionManager.Instance.TransactionTaskDone()

OUT = direct_shape

This is my node flowchart:

This is my run coloring effect, It seems that coloring only adds color to the borders of the cube, but the faces of the cube do not have color:
image

I think this is because there was no material added when creating the directshape, but I don’t know how to solve this problem.

This issue has been bothering me for a long time. If you have any suggestions, thank you very much!!!!!

You want to search for “element binding” on this forum to understand why you re runs are overwriting the previous run.

Thank you for your reply. I think I probably know where the problem lies