I have script1, in there the String "path" gets set. Then the script1 runs blender as a subprocess, together with script2. Now script2 needs to have access to the String "path", how can I do this?
Currently im Saving the string to a text file and then accesing it from script2 but I know this solution is very very ugly.
maybe someone has an idea? :)
script1:
path=("/example/ex/")
subprocess.run([blenderpath, "--background", blenderscene, "--python", scriptpath])
script2 (atm just reading out the txt file with the right path, but that's not how I want it to be):
file=open("Blabla")
file_name = fiel.readline()
mat_path = file_name
def prepscene(mat_path)
It works right now with the text file, but If I try to import the variable into the second script it won't work, if I try to somehow start the blender script with it it also won't work.
import sys # to get command line args
argv = sys.argv
argv will be array
If you just want to access the varible you can use importing.
ScriptA:
...
path = "/example/ex/"
...
ScriptB:
from .ScriptA import path
(this only works if both scripts are in the same directory)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.