executing script at terminal command prompt

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.

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Mon Oct 17, 2011 4:39 pm

Is any trial version of QCAD 3 Beta 3 now to try?

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Mon Oct 17, 2011 4:44 pm

oh, I've found it!
http://www.ribbonsoft.com/qcad_downloads.html
(if anyone else need it)

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Mon Oct 17, 2011 7:32 pm

The full list of command in my windows script is below:

line
rectang
circle
ellipse
arc

copybase
pasteblock

fillet
chamfer
rotate
scale
trim
extend
erase
mirror
move

-color
-hatch
-linetype
ltscale

dimlinear
dimangular
dimaligned

zoom

-mtext
-text

hungerburg, may I ask you to make a simple script wich will use maximum of theese commands to make a drawind, and save the drawing in script locate folder or in any other filder. I see you very good linux and QCAD user.

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Mon Oct 17, 2011 7:56 pm

I forgot that the script should be saved in both DWG and DPF formats.

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Tue Oct 18, 2011 7:37 pm

hungerburg, andrew please help me. I understand, that this is maybe my arrogance to ask you write some scripts. But I begin to get confused. Almost get lost.

If you can - just write the script, wich draws two lines
line (0,0) - (50,50)
line (50,50) - (0,100)

and makes a chamfer (or fillet) between this lines
and save this drawing as pdf anywhere.

Thanks in advance.

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Post by andrew » Tue Oct 18, 2011 10:16 pm

Rather than posting large pieces of code to this forum, we are continuously updating our API documentation and howtos.

Here's a howto about creating a drawing document in a command line application and adding three lines that form a triangle. The drawing is also saved to a DXF file:

http://www.ribbonsoft.com/doc/qcad/3.0/ ... awing.html

More will follow...

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Wed Oct 19, 2011 9:16 pm

I tried to run script from link, byt something is wrong with it (please look at my log below).
Then I comment the last row: di.exportFile("example.dxf", "DXF 2000");
Then no any errors arrived.
But I can't get result file.

alf3@ubuntu:~/Downloads/qcad-3.0.0-beta3-trial-linux$ DISPLAY="" ./qcad-trial -no-gui -autostart '/home/alf3/Downloads/example.js'
#50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011
i686
RDwgExporter::exportDocumentSettings
RDwgExporter::addXData: "Grid/DisplayGrid" : QVariant(bool, true)
RDwgExporter::setXData
type name: bool
"ANGBASE"
"ANGDIR"
"ATTMODE"
"AUNITS"
...
"VISRETAIN" false
"WORLDVIEW" false
alf3@ubuntu:~/Downloads/qcad-3.0.0-beta3-trial-linux$

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Post by hungerburg » Thu Oct 20, 2011 12:06 am

hello Alf,

where did you look for the file "example.dxf"? I found it in /opt/qcad3, because this is where I installed qcad3. (That's called the "working directory" of the application. Unfortunately this is different from the "current directory", the one where I issue the command…)

You will not find it though, if you comment the line that saves the drawing to file ;) Maybe make the line read "di.exportFile("/home/alf/example.dxf", "DXF 2000");" to have it created in your home directory, if you go by the name "alf" on your system…

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Post by andrew » Thu Oct 20, 2011 8:24 am

alf2006x: output looks good and normal. Nothing to worry about. I don't see any errors and your file should be perfectly fine.

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Thu Oct 20, 2011 8:47 am

hello, hungerburg

that is fantastic! i've found my example.dxf file in qcad directory! that wasn't , that was log.

but now it dont work again.
first it writes an error:
alf3@ubuntu:~/Downloads/qcad-3.0.0-beta3-trial-linux$ time DISPLAY="" ./qcad-trial -no-gui -autostart '/home/alf3/Downloads/example.js'
#50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011
i686
RFileExporterRegistry::getFileExporter: No suitable exporter found

real 0m1.398s
user 0m0.340s
sys 0m0.256s

then i goes to site again, copy text of script and make my new file example.js
but now it writes this:
alf3@ubuntu:~/Downloads/qcad-3.0.0-beta3-trial-linux$ time DISPLAY="" ./qcad-trial -no-gui -autostart '/home/alf3/Downloads/example.js'
#50-Ubuntu SMP Mon Sep 12 21:18:14 UTC 2011
i686
QWidget: Cannot create a QWidget when no GUI is being used
./qcad-trial: строка 39: 15328 Аварийный останов LD_LIBRARY_PATH="$DIR" "$binary" $OPT1 $OPT2 "$@"

real 0m0.522s
user 0m0.232s
sys 0m0.132s

i cant understand anything . what was happend?

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Post by hungerburg » Thu Oct 20, 2011 11:11 am

Yes, that is really strange. Things should not fail inconsistently.

So you did modify example.js and it stopped working? You then replaced the contents of example.js with the text from the howto? and it still doesnt work.

Perhaps you changed something else? If you cannot remember, just start from scratch. Unpack the qcad archive again. Try with different arguments. What widget will be created, if you allow that? Etc.

As a developer, you have to be very careful in what you are doing. Best practice was, to note every move you make.

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Post by andrew » Thu Oct 20, 2011 11:16 am

alf2006x: one common cause of this, is that an exception occurs (syntax error, typo, etc) and QCAD wants to show the debugger but cannot since we are using the -no-gui switch. Try to run the script without -no-gui and see if the debugger pops up. Once your script works, try with -no-gui again.

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Post by hungerburg » Thu Oct 20, 2011 11:20 am

Alf, previous post was general advise. This time I suggest: compare the contents of example.js with the text of the howto. I am sure you will find that they dont match.

User avatar
andrew
Site Admin
Posts: 9019
Joined: Fri Mar 30, 2007 6:07 am

Post by andrew » Thu Oct 20, 2011 11:28 am

hungerburg wrote:I am sure you will find that they dont match.
Yes, I also think something went wrong with the contents of that file. At least I am unable to reproduce the problem here with example.js

alf2006x
Active Member
Posts: 42
Joined: Mon Oct 10, 2011 11:29 am

Post by alf2006x » Thu Oct 20, 2011 12:02 pm

yes, that was my fault.
in first string of my script comments was written with only one slash. like this:
"/ init application name:"
:oops:

and what about converting my drawing in pdf? i dont found any information about this on API documentation and howtos page. i used "search"

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”