startup.py special script not working

313
1
Jump to solution
10-10-2017 03:48 AM
MarekDekys
New Contributor III

Hello,

would like to execute a script during CE startup . In manual it says to put a script named startup.py into current CityEngine workspace. So I made a simple script that prints something in CE's console to check if it is working:

startup.py:

from scripting import *

ce = CE()


if __name__ == '__main__':

   print ("hello world from startup")

but when I startup CE it doesn't print anything to console. However, when I execute it, it works perfectly so it shouldn't contain any errors. but it doesn't get executed automatically during startup. Am I missing something?

also where exactly should this script be located by meaning "current CityEngine workspace" ? 

is it 

<workspace_root>/scripting.py

<workspace_root>/<project>/scripting.py

<workspace_root>/<project>/<scripts>/scripting.py

I placed it on all loactions and it doesn't work.

Any help appreciated.

Mark

0 Kudos
1 Solution

Accepted Solutions
ThomasFuchs
Esri Regular Contributor

Hello Marek Dekys

Thank you for your question.

On startup the __name__ variable is set to '__startup__'

Please change your script to:

from scripting import *
ce = CE()

if __name__ == '__startup__':
     print ("hello world from startup")

View solution in original post

1 Reply
ThomasFuchs
Esri Regular Contributor

Hello Marek Dekys

Thank you for your question.

On startup the __name__ variable is set to '__startup__'

Please change your script to:

from scripting import *
ce = CE()

if __name__ == '__startup__':
     print ("hello world from startup")