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.

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

Post by hungerburg » Thu Oct 20, 2011 12:36 pm

Alf, this might be off-topic, but I think it may be of use for you: In many places SVG can do, what you want PDF for… So if you paste these lines to the bottom of example.js, QCAD will write an SVG representation of the drawing:

Code: Select all

include("scripts/ImportExport/SvgExporter/SvgExporterPG.js");
var exporter = new SvgExporterPG(document, { "scale": "10:1"});
exporter.exportFile("example.svg");

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

Post by andrew » Thu Oct 20, 2011 12:43 pm

PDF export will be documented soon in the tutorials as well. Maybe later today, if I can find the time.

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

Post by hungerburg » Thu Oct 20, 2011 1:15 pm

hungerburg wrote:

Code: Select all

include("scripts/ImportExport/SvgExporter/SvgExporterPG.js");
var exporter = new SvgExporterPG(document, { "scale": "10:1"});
exporter.exportFile("example.svg");
Obviously, this will fail when -no-gui was called for. Below patch helps though:

Code: Select all

--- SvgExporter.js~	2011-10-20 14:11:45.527589416 +0200
+++ SvgExporter.js	2011-10-20 14:12:46.277502814 +0200
@@ -1,6 +1,5 @@
 include("scripts/library.js");
 include("scripts/date.js");
-include("scripts/File/PrintPreview/Print.js");
 
 /**
  * File exporter implementation for the SVG format.
@@ -116,7 +115,7 @@
     this.svgUnitAbbr = ret[1];
 
     // scale
-    this.scale = Print.parseScale(this.scaleStr);
+    this.scale = RMath.parseScale(this.scaleStr);
 
     var bb = this.doc.getBoundingBox();
     var size = bb.getSize();

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

Post by alf2006x » Thu Oct 20, 2011 1:27 pm

we need exactly pdf because it is non editable format. drawings maked from site will be signed his author (director of customer) and send to manufacturer (back to us)

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

Post by hungerburg » Thu Oct 20, 2011 2:03 pm

I would like to further expand the tutorial text:

Code: Select all

var td = new RTextData();
td.setText("QCAD rocks");
td.setTextHeight(1);
td.setPosition(p1);
operation.addObject(new RTextEntity(document, td));
Pasting this before the operation gets applied will write this flattering line - because it is true :)

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

Post by alf2006x » Thu Oct 20, 2011 7:28 pm

hungerburg, andrew one more question to you.

How can I do the best performance of my system? I see two ways to solve the problem.

First one is to make some daemon, witch will gets input data, then generate the text file, save it as script and runs the script in "headless silent mode".

The second way is to write the script for QCAD, wich will runs one time and will wait for incoming file with input data.

What do you think?

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

Post by andrew » Thu Oct 20, 2011 10:04 pm

I don't know your exact environment, but I assume your service is somehow web based?

If so, your application will have to be able to handle multiple requests simultaneously, so running only one instance of QCAD is not an option.

You could for example create a CGI which handles incoming requests, parses incoming user data (e.g. POST or GET parameters) and creates a QCAD script from this user data.

The CGI then launches QCAD with that script file as -autostart parameter. QCAD generates the PDF file and the CGI returns the PDF file contents as response to the request.

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

Post by andrew » Fri Oct 21, 2011 3:03 pm

A PDF export tutorial is now online at:
http://www.ribbonsoft.com/doc/qcad/3.0/ ... xport.html

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

Post by alf2006x » Fri Oct 21, 2011 7:30 pm

Example works in main mode of QCAD, but do not work in -no-gui mode
It shows message:

alf3@ubuntu:~/Downloads/qcad-3.0.0-beta3-trial-linux$ ./qcad-trial -no-gui -autostart '/home/alf3/QCAD/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: 16545 Аварийный останов LD_LIBRARY_PATH="$DIR" "$binary" $OPT1 $OPT2 "$@"

and command:
./qcad-trial -autostart '/home/alf3/QCAD/example.js'
works wery well

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

Post by andrew » Fri Oct 21, 2011 9:38 pm

alf2006x: please apply the fix to EAction.js that I have posted in this thread earlier. See:
http://www.ribbonsoft.com/rsforum/viewt ... =4966#4966

-> post at bottom of the page from 17 Oct 2011 09:28 am

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

Post by alf2006x » Fri Oct 21, 2011 10:07 pm

Perfect, wonderful, superb!
It works! It works !!! IT WORKS !!!
:D

I copy my example.pdf in Windows and it opens!

GREAT THANKS! QCAD IS THE BEST CAD FOR LINUX!
Now my project will be completed. I do not doubt it.

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

Post by alf2006x » Mon Oct 24, 2011 8:11 am

andrew, help me again please. our provider uses Ubuntu-Server 10.04.2 LTS Lucid Lynx - Release amd64
how can i install qcad3 beta3 on this system? will it be enough simple copying linux tar.gz package and unpacking them to run headless qcad3 beta3? or i must do something else?

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

Post by andrew » Mon Oct 24, 2011 10:15 am

To run QCAD (32bit) on a 64bit platform, you need to have the 32bit libraries installed (package ia32-libs).

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

Post by hungerburg » Tue Oct 25, 2011 1:30 pm

alf2006x wrote: Ubuntu-Server 10.04.2 LTS Lucid Lynx - Release amd64
how can i install qcad3 beta3 on this system? will it be enough simple copying linux tar.gz package and unpacking them to run headless qcad3 beta3? or i must do something else?
I do not use the installer, instead I download the archive and unpack into /opt/, which is a widely used convention for packages like qcad. On a server edition of ubuntu -- depending on how strict -no-gui works -- you may also have to install some X11 libraries on your own, because they are not part of the base. The ldd utility can help you find out which prerequisites are missing: "ldd /opt/qcad3/qcad-bin". Also "apt-cache search something" comes quite handy.

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

Post by alf2006x » Wed Oct 26, 2011 9:55 pm

Hi to all.
This is my new trouble.
On my "Ubuntu-Server 10.04.2 LTS Lucid Lynx - Release amd64" I installed ia32-libs.
And moved my folder '/qcad/qcad3b' (with qcad files) into '/opt' folder.

Now command prompt shows me this:

alfus@ubuntu:/opt/qcad/qcad3b$ ./qcad-trial
#55-Ubuntu SMP Mon Jan 10 23:42:43 UTC 2011
x86_64
./qcad-trial-bin: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory
alfus@ubuntu:/opt/qcad/qcad3b$

What is it?

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”