Rebar removed when running script..?

This is element binding.

See this post: Element Binding in Revit