Python Error when trying to run a script

Python Error when trying to run a script

wr_xr
Explorer Explorer
1,192 Views
5 Replies
Message 1 of 6

Python Error when trying to run a script

wr_xr
Explorer
Explorer

Im trying try get this free script to run but getting the error 
https://github.com/dravec-ky/mayaCityGen?tab=readme-ov-file

I tried in 2024 first but then dropped back to 2020 but still get this error. I have very little  coding knowledge. I've contacted the author but he hasn't got back to me and dosnt look like its been supported for a number of years.

Any ideas ?

# Error: line 0: NameError: file <maya console> line 2206: global name 'scriptPath' is not defined #

Thanks


0 Likes
1,193 Views
5 Replies
Replies (5)
Message 2 of 6

mcw0
Advisor
Advisor

This is where it is being defined
Screenshot 2025-01-03 141021.png
As you can see, it checks to see if the "mayaCityGen.py" file exists in the proper location.  Then it assigns "scriptPath".  Do you have "mayaCityGen.py" in the proper location as per the Readme instructions?
Screenshot 2025-01-03 141240.png

0 Likes
Message 3 of 6

wr_xr
Explorer
Explorer

Thanks for the reply.
Yes the insides of the Maya CityGen src folder are placed in the scripts folder of the relevant maya version (Maya 2020) and I still get the same error

wr_xr_0-1736075843057.png

 

0 Likes
Message 4 of 6

mcw0
Advisor
Advisor

To help in debugging, you can try a couple of print statements.

projectDirectory = mc.workspace(q=True, rd=True)
print("Project Dir: " + projectDirectory)
if os.path.exists(projectDirectory+'scripts/mayaCityGen.py'):
    scriptPath = projectDirectory+"scripts"
    print("Script Path: " + scriptPath)
0 Likes
Message 5 of 6

FirespriteNate
Advocate
Advocate

If you go back and look at the github repository you posted the link to, you should see on the main "menu bar" area that it has only one reported "issue", which is the exact same problem you describe here, from 2 years ago, with an answer/solution posted there by the author himself.

0 Likes
Message 6 of 6

mcw0
Advisor
Advisor

DOH!!!  OF COURSE!  Just hardcode the path.  Nice!

0 Likes