Calling Environment Variables
-
wrote on 29 Jun 2017, 03:05 last edited by
Hi,
I'm trying to load external environment variables with QML or JavaScript, but I can find any function to do that.
what I do normally is to clarify the variable in command line like so:
set MY_PATH="C:/ProjectA"
and if I lunch the python in same command line I can call the variable like so:
>>> import os >>> print os.environ.get("MY_PATH") C:/ProjectA
but now I'm trying to do the same thing in Substance Painter and they only support QML and JavaScript but not C++.
Is there any way that I can call the OS environment variables in JS or QML? -
Hi,
I'm trying to load external environment variables with QML or JavaScript, but I can find any function to do that.
what I do normally is to clarify the variable in command line like so:
set MY_PATH="C:/ProjectA"
and if I lunch the python in same command line I can call the variable like so:
>>> import os >>> print os.environ.get("MY_PATH") C:/ProjectA
but now I'm trying to do the same thing in Substance Painter and they only support QML and JavaScript but not C++.
Is there any way that I can call the OS environment variables in JS or QML?wrote on 29 Jun 2017, 03:22 last edited by@Bernard-Rouhi I would get the environment variable on the c++ side and pass it to qml.
Unfortunately if you are on client-side java script there is no way to access environment variables. Which is probably a good thing for the massive security problems that would create. :)
-
@Bernard-Rouhi I would get the environment variable on the c++ side and pass it to qml.
Unfortunately if you are on client-side java script there is no way to access environment variables. Which is probably a good thing for the massive security problems that would create. :)
wrote on 29 Jun 2017, 05:22 last edited by@ambershark Thank you for the reply, I agree with you, but Substance Painter doesn't support C++, according to their documentation, "The plugin are wrote in Javascript and can be combined with the QML language to create custom interface inside the application." Link.
Is there anyway that I can execute Command line or python file from JS/QML and get the return value?
-
@ambershark Thank you for the reply, I agree with you, but Substance Painter doesn't support C++, according to their documentation, "The plugin are wrote in Javascript and can be combined with the QML language to create custom interface inside the application." Link.
Is there anyway that I can execute Command line or python file from JS/QML and get the return value?
wrote on 29 Jun 2017, 08:45 last edited by@Bernard-Rouhi I don't think so. That would have the same security problems. I'm no expert in qml or js but I don't think you can do that.
Node.js supports getting environment variables but that is a different beast altogether.
-
@Bernard-Rouhi I don't think so. That would have the same security problems. I'm no expert in qml or js but I don't think you can do that.
Node.js supports getting environment variables but that is a different beast altogether.
wrote on 29 Jun 2017, 13:24 last edited by Bernard Rouhi@ambershark thanks for the reply again, I have noticed that the Substance Painter doesn't compile my QML and JavaScript, and that would be the reason I couldn't link C++ to my QML plugin.
However, I found that there is a workaround, I can run Substance Painter 2.exe on command line along multiple variables and then call them by using application.arguments
Example:
in the command line I go into Substance Painter 2 directory and type:"Substance Painter 2.exe" C:/ProjectA
and in my QML plugin I use:
Qt.application.arguments
and it will return:
{ "0": "Substance Painter 2.exe", "1": "ProjectA" }
This is not a very smart way, but at least lead to some result.
I'm wondering if there is any way that I can write what I need in C++ and compile it with Qt Creative and add it to the Substance Painter's QML library, but I'm not sure if it's a good idea.
1/5