animated hide&unhide work on viewport but not on render

If D1.ishidden Then
UnHide D1; Hide D2; Hide D3

with this position script code i animate the hide property and its work good on view port but when i render the scene it doesn't work.

please help.