Remove text from DXF/DWG files - command line tool/script

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
Reiska
Newbie Member
Posts: 3
Joined: Sat Jan 13, 2018 8:56 am

Remove text from DXF/DWG files - command line tool/script

Post by Reiska » Sat Jan 13, 2018 9:02 am

Hello,

I just found the QCAD and I'm looking for a solution to automatically or by given mask/wildcards to remove text automatically from a bunch of DXF/DWG files.

Would you be able to help me with this? Would QCAD Command-line tools allow this, or would it require building own application using QCAD API?
Alternatively, GUI interface solution could work for this as well, if there's just solution to do the removal without using a mouse pointer to locate the text from the document.

Hope I didn't post this thread to wrong forum section?

Thanks,
Riku

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

Re: Remove text from DXF/DWG files - command line tool/script

Post by andrew » Mon Jan 15, 2018 10:56 am

A command line tool is not included out of the box (but could be created using the script interface with relatively little effort).

A GUI solution would be View > Selection Filter which supports regular expressions (much more powerful but also more complex than wildcards):
Screen Shot 2018-01-15 at 09.55.44.png
Screen Shot 2018-01-15 at 09.55.44.png (71.35 KiB) Viewed 3999 times
Here we are selecting all texts containing at least one capital letter (A-Z), followed by at least one number (0-9).

Reiska
Newbie Member
Posts: 3
Joined: Sat Jan 13, 2018 8:56 am

Re: Remove text from DXF/DWG files - command line tool/script

Post by Reiska » Mon Jan 15, 2018 12:40 pm

Thanks.

GUI solution would work quite nicely as well using Regexp. Thanks!

However, when modifying a bunch of CAD files, the command-line solution might be faster solution.
Can you tell me, how would I get in the beginning using the script interface?

- Riku

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

Re: Remove text from DXF/DWG files - command line tool/script

Post by andrew » Wed Jan 17, 2018 11:20 am

For the general structure of a command line tool in QCAD, please refer to the included merge tool:

Batch file (Windows):
https://github.com/qcad/qcad/blob/master/merge.bat

Bash file (macOS, Linux):
https://github.com/qcad/qcad/blob/master/merge

ECMAScript Implementation:
https://github.com/qcad/qcad/tree/maste ... geDrawings

You can find plenty of example code for iterating through all entities, etc. under the scripts folder of your QCAD installation or online at:
https://github.com/qcad/qcad/tree/master/scripts

Reiska
Newbie Member
Posts: 3
Joined: Sat Jan 13, 2018 8:56 am

Re: Remove text from DXF/DWG files - command line tool/script

Post by Reiska » Wed Jan 17, 2018 11:59 am

Great.

I will keep looking at these. Thanks!

Post Reply

Return to “QCAD 'How Do I' Questions”