to get the current directory

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

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

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: 9059
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 Programming, Script Programming and Contributing”