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
Beginner scripting, non-GUI
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: Beginner scripting, non-GUI
Hi,
Its all vagely, I know.
I have a copy off the resources at hand:
https://github.com/qcad/qcad
so I can peek in most of the scripts involved with QCAD.
Then you have the classes:
https://www.qcad.org/doc/qcad/latest/de ... index.html
https://www.qcad.org/doc/qcad/latest/de ... 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.
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.
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.
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.
Regards,
CVH
Its all vagely, I know.
I have a copy off the resources at hand:
https://github.com/qcad/qcad
so I can peek in most of the scripts involved with QCAD.
Then you have the classes:
https://www.qcad.org/doc/qcad/latest/de ... index.html
https://www.qcad.org/doc/qcad/latest/de ... 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.
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.
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.
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.
Regards,
CVH
Re: Beginner scripting, non-GUI
Thanks CVH! I can dodge those gui functions now.