Hi all, I'm taking a look on the scripting from qcad and I was wondering if there is any way I can export a determined bounding box to an image.
For instance, I have those coordinates:
min: 120,120
max: 240,240
And I want to export the view from this box to an image with 500px, 500px.
There's any scripting or command line I can do it?
Export determined bounding box to image
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.
-
- Junior Member
- Posts: 24
- Joined: Fri Apr 28, 2023 12:39 pm
Re: Export determined bounding box to image
Under file there's the bitmap export where you can select what image filetype you want and also the image size (i.e., 500x500px). I could imagine to do this you would create a view that looks at your 120x120 coordinates, then view your view, then do the bitmap export. Pretty sure it's doable with the scripting interface.
Re: Export determined bounding box to image
@jocieldo
Hi, and welcome to the QCAD forum.
There is a OS Command Line method but I don't think that this will crop the output to a given area, window or box: dwg2bmp
https://www.ribbonsoft.com/en/products/ ... line-tools
The GUI method BitmapExport.js is open source, see: https://github.com/qcad/qcad/blob/maste ... pExport.js
The beginEvent eventually calls this.exportBitmap(this.getDocumentInterface(), bmpFileName, properties); at line 277.
Cropping is another problem, QCAD exports all visible and/or the region of a box around all selected.
One can indeed create a Viewport on a Layout block and export that.
A simple test exported the content cropped to the Viewport as expected but it included the border of the Viewport.
That should be tweaked somehow when exporting a border is not intended but then the export area is less defined.
Another method is creating a temporary copy of the intended art in an off-screen document clipped to a rectangle (CLR).
You can then export only the clipped area with the associated document interface, deleting the off-screen document afterwards.
But there may be a different route ...
The export itself is handled in BitmapExportWorker.js:
https://github.com/qcad/qcad/blob/maste ... tWorker.js
You might simply exploit the window property but again it is unsure if that crops.
Probably it only zooms in/out to that RBox like dwg2bmp does.
Regards,
CVH
Hi, and welcome to the QCAD forum.
There is a OS Command Line method but I don't think that this will crop the output to a given area, window or box: dwg2bmp
https://www.ribbonsoft.com/en/products/ ... line-tools
The GUI method BitmapExport.js is open source, see: https://github.com/qcad/qcad/blob/maste ... pExport.js
The beginEvent eventually calls this.exportBitmap(this.getDocumentInterface(), bmpFileName, properties); at line 277.
- this.getDocumentInterface() is a reference to a document interface, in this case the current.
bmpFileName is a path+filename for the generated output.
properties is a collection of properties or settings to work with.
Cropping is another problem, QCAD exports all visible and/or the region of a box around all selected.
One can indeed create a Viewport on a Layout block and export that.
A simple test exported the content cropped to the Viewport as expected but it included the border of the Viewport.
That should be tweaked somehow when exporting a border is not intended but then the export area is less defined.
Another method is creating a temporary copy of the intended art in an off-screen document clipped to a rectangle (CLR).
You can then export only the clipped area with the associated document interface, deleting the off-screen document afterwards.
But there may be a different route ...
The export itself is handled in BitmapExportWorker.js:
https://github.com/qcad/qcad/blob/maste ... tWorker.js
You might simply exploit the window property but again it is unsure if that crops.
Probably it only zooms in/out to that RBox like dwg2bmp does.
Regards,
CVH