0

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.

Erich
  • 1,838
  • 16
  • 20
N0ESCAPE
  • 1
  • 1

2 Answers2

0
import sys       # to get command line args

argv = sys.argv
argv will be array
double-beep
  • 5,031
  • 17
  • 33
  • 41
Chevdawala
  • 11
  • 2
  • 4
    It would be helpful if you edited your question to provide some context and explanation of how this code answers the question. – Dragonthoughts Jun 03 '20 at 20:37
0

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)

Ph.lpp
  • 484
  • 1
  • 4
  • 17