Page 1 of 1

to get the current directory

Posted: Fri Sep 29, 2017 11:56 am
by Nick1974
Hello.
How can I get the current directory from ECMAScript to use it in include, importFile and exportFile commands?
I do not want use full path.
I run qcad as

Code: Select all

qcad -allow-multiple-instances -autostart foo.js && qcad foo.dxf

Re: to get the current directory

Posted: Mon Oct 02, 2017 10:27 am
by andrew
Includes are relative to the script that contains the include.

I.e.:

include("myscript.js");

will look in the same directory as the script that contains that include. Then, it will look in the current working directory (that's the QCAD installation directory that contains the "scripts", "plugins", etc. folders.

For import / export paths, I'd using absolute paths. You can get the current working directory using QDir.currentPath(). See also http://doc.qt.io/qt-5/qdir.html#currentPath

Re: to get the current directory

Posted: Wed Oct 11, 2017 1:13 pm
by Nick1974
Thanks.