why below code is not functioning in Dynamo. Thank you in advance.

why below code is not functioning in Dynamo. Thank you in advance.

This code is specific for Revit Python Shell. RPS is a completely different beast than Dynamo and it’s quirks like __revit__ won’t work.
Also, see https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration for code reference.
There is a Dynamo Python Github Repository that has some examples that may help to guide you.