Hi,
Trying using the RIE package, it has lots of nodes for circuiting.
I had a similar script and I created circuits based on a panel then adds components after.
I know that the API has changed a bit depending on what version you are in. The one I made is for 2016, the RIE I believe is either 2017 or 2018 and newer.
Edit: heres a good thread for this.