Note that obj1 in
pin2=obj1.pin['a0'] is not in scope of this snippet. If obj1 refers to an instance in another cell than you are working in you will get the “outside the scope” message. Note that obj1 should not be a Cell. Try type(obj1) to see what obj1 is.
Can you reproduce this behaviour without the custom import?
The nd.clear statements are better put directly after
import nazca as nd
Which Nazca version are you using?