Is it possible to import file from the buffer, or readed file data?

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
ilyasozkurt
Newbie Member
Posts: 9
Joined: Sat Nov 19, 2022 3:20 pm

Is it possible to import file from the buffer, or readed file data?

Post by ilyasozkurt » Sun Nov 20, 2022 2:28 pm

Hello there,

Is it possible to import a file with a buffer that reads from cad files? I mean without writing them to the disk.

Thank you.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Is it possible to import file from the buffer, or readed file data?

Post by CVH » Mon Nov 21, 2022 4:29 am

Hi,

When importing or loading a drawing QCAD generates a workable image in physical memory.
Apart from updating the QCAD.ini/config or caching the physical memory not much writing is involved to my knowledge.

But that is probably not what your question is about.

QCAD can run without GUI and can execute scripts just the same.

There is also the capability to work with off-screen documents.
https://github.com/qcad/qcad/blob/maste ... ple.js#L88
https://github.com/qcad/qcad/blob/maste ... ple.js#L99
https://github.com/qcad/qcad/blob/bc881 ... drawing.js
https://github.com/qcad/qcad/blob/bc881 ... Drawing.js
One can import/load a drawing file to an off-screen document and it is not required to save that to disk.

Regards,
CVH

ilyasozkurt
Newbie Member
Posts: 9
Joined: Sat Nov 19, 2022 3:20 pm

Re: Is it possible to import file from the buffer, or readed file data?

Post by ilyasozkurt » Mon Nov 21, 2022 7:30 am

Thank you for the answer. But still these are not the things that I search.

When you create an automated script you still need to give the file trough disk with doc.importFile, instead of this, I want to use a buffer that comes directly uploaded file to memory like doc.importBuffer… This means you do not need to use disk to provide the drawing file to the qcad.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Is it possible to import file from the buffer, or readed file data?

Post by CVH » Mon Nov 21, 2022 9:50 am

Hi,
still not with you .... :oops:

First, it will most likely be di.importFile(...) to my knowledge.
Aka: Importing a drawing file into an existent document interface.

The file is most certainly stored somewhere and that can be a local disk, a portable drive, a network drive, a cloud drive or at a certain url.

For example:
Files posted on the QCAD forum open directly from there:
But in essence there is a copy in your browser cache.

It eludes me where to retrieve a drawing that is not stored somewhere on a disk or drive and that is not an existent QCAD on/off-screen document in memory.

Please elaborate your question, give examples, explain what buffer.

1 final thought or another shot in the dark :wink:
Perhaps this is the "buffer" you're referring to ...

The document interface of the drawing that is active in the GUI when you launch a script is:
var di = this.getDocumentInterface();
Or basically var di = EAction.getDocumentInterface();
The active RDocument is then:
var doc = di.getDocument();
Or similar var doc = this.getDocument(); or var doc = EAction.getDocument();


Regards,
CVH

ilyasozkurt
Newbie Member
Posts: 9
Joined: Sat Nov 19, 2022 3:20 pm

Re: Is it possible to import file from the buffer, or readed file data?

Post by ilyasozkurt » Mon Nov 21, 2022 11:43 am

Thank you so much for your time and response effort.

Let me give you an example. I'm trying to build an API service with node.js and child_process modules. When I upload the file to the server, there are two options: write the file to the temp directory or keep it on memory until I save it anywhere. The idea is to use that uploaded file buffer to the qcad process.

Here's the diagram:
Untitled - Frame 1.jpg
Untitled - Frame 1.jpg (151.4 KiB) Viewed 6072 times

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Is it possible to import file from the buffer, or readed file data?

Post by CVH » Wed Nov 23, 2022 9:12 am

ilyasozkurt wrote:
Mon Nov 21, 2022 11:43 am
The idea is to use that uploaded file buffer to the qcad process.
Honestly, Not a clue.
On open or on Import a file is read from disk to a new or to an existent document interface.
Unless there is a way to spoof the origin of the source I see no means.

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”