Script needed to run DrawFromCSV on multiple CSV files

Use this forum for all posts and questions about the free QCAD Community Edition version 3

Moderator: andrew

Post Reply
spacester
Junior Member
Posts: 14
Joined: Wed Jan 25, 2023 12:54 am

Script needed to run DrawFromCSV on multiple CSV files

Post by spacester » Thu Oct 31, 2024 6:30 pm

Hi all, I am wrapping up my first Python project, a massive (to me) effort that represents the achievement of a goal I set some 20 years ago. My code solves for trajectories to transfer from Earth to Mars. Hopefully the attached will explain well enough.

Windows 10, QCAD 3.27.9 (free version)
2024_2460595_traject.csv
(62.82 KiB) Downloaded 606 times
2024_2460595_traject.pdf
(357.11 KiB) Downloaded 1170 times
My python code generates the CSV files, there will be many hundreds of them, ultimately thousands. I need to run the DrawFromCSV script (thanks CVH!) on a fresh DXF for each CSV and export to PDF using the same file name. That works fine when I do it by clicking and typing.

I am unable to find any relevant example scripts to get started and do not know what I am doing with ECMA script. I last worked with javascript 20 years ago. I am quite willing to learn but am getting nowhere so far.

TIA

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

Re: Script needed to run DrawFromCSV on multiple CSV files

Post by CVH » Fri Nov 01, 2024 12:36 am

Hi, after about a year or so of silence. :wink:
Also received the Private Message.

What you probably need is an OS Command Line script.

As far as I know, DrawFromCSV is not really tested to accept parameters from such a script.
But I did put the core apart working with a given document interface and a given filename.
Export to PDF should then also be handled in the Command Line script.

All a bit uncharted territory. Never to old to learn new tricks. :wink:
Another concern is that it uses the Command History rather extensively to communicate.
That is mostly because on a Windows platform it can not interface with a debug window.

Kinda odd you posted this in the QCAD CE section.
It will run in CE but it requires QCAD Pro for some parts (Polyline rounding, fitpoint splines, ...)
In the mean time some ellipse tools are migrated to Pro ... Need to check that.

Incredibly how fast it casts 903 new entities, not?
I was intrigued where all the 625 circles went.

For the rest I would like to refer you to the PM that is coming ... This week, I promise :lol:

Regards,
CVH

spacester
Junior Member
Posts: 14
Joined: Wed Jan 25, 2023 12:54 am

Re: Script needed to run DrawFromCSV on multiple CSV files

Post by spacester » Fri Nov 01, 2024 4:02 am

Thank you very much. I did post this on the scripts forum but it got moved to the CE forum which makes sense no problems. I apologize for being too broke to buy the pro version.

Yeah DrawFromCSV is fast, very cool. Good stuff.

It's a big help to know what direction to go in. It's time for me to learn OS command line scripts. Old dog, new tricks, here we go.

It would seem that the only parameter to pass is the folder name if it can read the files, or the filenames. Then the file extension is changed for the output file. Export to pdf works with just one click to confirm auto fit, and of course the folder path and filename. I could not find any os system commands for QCAD scripts. There is a gui capability but I am clueless there too and it seems that would not lead to automatic operation.

So I should be able to invoke the DrawFromCSV script from the OS command line? I didn't expect that because I didn't think you could access commands inside a program from the 'outside'. Apparently that just shows how much I don't know here.

I'll give it a shot and keep an eye out for that PM.

Thanks again.

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

Re: Script needed to run DrawFromCSV on multiple CSV files

Post by CVH » Fri Nov 01, 2024 3:26 pm

spacester wrote:
Fri Nov 01, 2024 4:02 am
So I should be able to invoke the DrawFromCSV script from the OS command line?
Presumably not straight out the box.

But yes you can start QCAD off-screen and let it execute a script, passing parameters.

Startup flags/arguments are explained here: related topic
Perhaps not complete or fully up to date.
Perhaps the -h switch seemingly does nothing (Windows).
The best resource I can refer to is the text itself in Autostart.js under function usage()
The up to date script can be found on Github.

Regards,
CVH

Post Reply

Return to “QCAD Community Edition”