to get the current directory

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
Nick1974
Newbie Member
Posts: 5
Joined: Fri Sep 29, 2017 11:35 am

to get the current directory

Post by Nick1974 » Fri Sep 29, 2017 11:56 am

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

User avatar
andrew
Site Admin
Posts: 5375
Joined: Fri Mar 30, 2007 6:07 am

Re: to get the current directory

Post by andrew » Mon Oct 02, 2017 10:27 am

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

Nick1974
Newbie Member
Posts: 5
Joined: Fri Sep 29, 2017 11:35 am

Re: to get the current directory

Post by Nick1974 » Wed Oct 11, 2017 1:13 pm

Thanks.

Post Reply

Return to “QCAD Developers and Contributors”