Beginner scripting, non-GUI

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

Post Reply
Junior Member
Posts: 11
Joined: Wed Jul 08, 2020 5:08 pm

Beginner scripting, non-GUI

Post by ScottP » Thu Jul 16, 2020 11:27 pm

Hi all,

I'm a beginner at scripting. To begin, I've read through the docs to find the non-GUI functions that I'll need for a no-user-interaction script. But I haven't found function to select all entities in a layer - could someone point me to one? Most of the layer selection related functions in the docs and source code scripts take GUI interaction events instead of layer index, or layer name.

"Select all layers" is the first place I got stuck in trying to make this script:
- Import a dwg file as a RDocument (doc) object
- Get the IDs or names of each layer present in the doc, e.g. doc.queryAllLayers()
- For each layer: select all entities in the layer (which is where I'm stuck); get the geometric center of the selection as (X, Y) in default [mm] units of the dwg; set the color of all entities in the layer; save all entities in the layer in a single dxf document

Then use dwg2bmp to create bitmap images of each of the generated dxf's at resolution that depends on the (X,Y) [mm] center coordinates found above. I'd like to execute dwg2mp from within the script, to avoid saving the (X,Y) coordinates in a separate file.

Thank you for any pointers!
- Scott

Premier Member
Posts: 781
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Beginner scripting, non-GUI

Post by CVH » Fri Jul 17, 2020 10:22 am

Its all vagely, I know. :oops:

I have a copy off the resources at hand: :wink:
so I can peek in most of the scripts involved with QCAD.

Then you have the classes: :wink: ... index.html ... tated.html

I know to get a list of things = query.
So I look up with NPP (Notepad++) the word "query" in al the files in the copy of the master of Qcad.
>> lots of ways to query entities. :P
Mostly doc related. At first view nothing related to layers in direct.

In the annotaded class list I search for "quer..y.."
Already with "quer" I see a bunch of query methods. :P
Selected one and chosen the document related.

Now I am at the subdivision RDocument with a bunch of methods.
Scrolled down to RDocument.queryLayerEntities()

I think that look promising. :P
Again I can search for "queryLayerEntities" in the master: 2 hits
So there are two examples to peek in.
A double click and NPP opens those scripts. :wink:

QCADpro / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

Junior Member
Posts: 11
Joined: Wed Jul 08, 2020 5:08 pm

Re: Beginner scripting, non-GUI

Post by ScottP » Tue Jul 21, 2020 11:57 pm

Thanks CVH! I can dodge those gui functions now.

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”