Export text file from ECMAScript routine

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
garciadelcastillo
Active Member
Posts: 28
Joined: Fri May 10, 2019 6:26 pm

Export text file from ECMAScript routine

Post by garciadelcastillo » Tue Jun 04, 2019 11:12 pm

Hi there!

Question: is the possibility of writing a plain text file to the system with the ECMAScript API for a custom CLI script?

Scenario: say I am writing a processing tool to perform a batch geometry operations on a set of files. I want to be able to save the modified file, which is straightforward through the documentInterface.exportFile() function. However, I want to generate an additional .log file with the same name, with a breakdown of the modifications on that file. How can that additional, plain text file be written to disk? Since it looks like the ECMAScript interface is not implemented with Node.js, none of its file system APIs are present...

Thanks a lot!

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

Re: Export text file from ECMAScript routine

Post by andrew » Tue Jun 04, 2019 11:17 pm

You can use the extensive Qt API. Have a look at:
https://github.com/qcad/qcad/blob/maste ... tExport.js

garciadelcastillo
Active Member
Posts: 28
Joined: Fri May 10, 2019 6:26 pm

Re: Export text file from ECMAScript routine

Post by garciadelcastillo » Wed Jun 05, 2019 12:15 am

Ooooh, I see... So the full Qt API has an ECMAScript mirror...? That is sooo interesting...

Wonderful, thank you Andrew!

Post Reply

Return to “QCAD 'How Do I' Questions”