API-Doc up-to-date?

Post here to ask questions about or get help with the scripting module of QCAD 2.1/2.2.

Moderator: andrew

API-Doc up-to-date?

Postby chri » Sat Oct 25, 2008 4:11 pm

Hi,

I just started scripting, and i wonder if the API doc (http://www.ribbonsoft.com/qcadlib_qcadscripting_classref.html) is up-to-date?

E.g.
Code: Select all
var doc = new Document();
doc.firstEntity().getEntity();

According to the API, there should be a getEntity function (http://www.ribbonsoft.com/qcadscripting/classref/class_q_s___entity_wrapper.html), but there isn't. How can I generate an up-to-date version of the API for the current professional edition, preferable with inheritances to qsa base classes?

Thanks for reading!

chri
chri
Newbie Member
 
Posts: 6
Joined: Sat Oct 25, 2008 3:56 pm

Re: API-Doc up-to-date?

Postby andrew » Sat Oct 25, 2008 4:26 pm

chri wrote:I just started scripting, and i wonder if the API doc (http://www.ribbonsoft.com/qcadlib_qcadscripting_classref.html) is up-to-date?


Yes.

chri wrote:E.g.
Code: Select all
var doc = new Document();
doc.firstEntity().getEntity();



The correct syntax is:
Code: Select all
var doc = new Document;
var entity = doc.firstEntity();


chri wrote:According to the API, there should be a getEntity function (http://www.ribbonsoft.com/qcadscripting/classref/class_q_s___entity_wrapper.html), but there isn't.


The API doc is generated from the C++ code and therefore also lists internal C++ functions that are not available to scripts (like getEntity which in C++ returns the internal entity object that is wrapped by the entity wrapper class).

chri wrote:How can I generate an up-to-date version of the API for the current professional edition, preferable with inheritances to qsa base classes?


Please have a look at the script examples that come with QCAD. They demonstrate almost everything that can currently be done with the scripting interface of QCAD (mainly adding entities). For generic QSA classes, please refer to: http://doc.trolltech.com/qsa-1.2.0/language.html and http://doc.trolltech.com/qsa-1.2.0/exte ... ework.html
User avatar
andrew
Site Admin
 
Posts: 2528
Joined: Fri Mar 30, 2007 6:07 am

Postby chri » Sat Oct 25, 2008 4:38 pm

Thanks for the fast reply!

So it is probably not possible to loop through all the entities of a document, collect all RS_Text object, parse them to Integer values and compute the sum of these values?
chri
Newbie Member
 
Posts: 6
Joined: Sat Oct 25, 2008 3:56 pm

Postby andrew » Sat Oct 25, 2008 4:45 pm

I'm afraid not. At this point scripting is mainly for adding entities based on parameters or calculations. Gathering information from a drawing is not yet possible.

QCAD 3 (2009) will feature a far more powerful scripting environment.
User avatar
andrew
Site Admin
 
Posts: 2528
Joined: Fri Mar 30, 2007 6:07 am

Postby chri » Sat Oct 25, 2008 4:59 pm

At the moment this would only be possible by writing a c++ program using qcadlib?

When I just skimmed over the links you posted, I found this interresting class: QSObjectFactory, http://doc.trolltech.com/qsa-1.2.2/qsobjectfactory.html. Is it possible to create RS_Text objects with this factory? But i guess coding c++ is way easier and calling the program with a script in qcad (if possible).
chri
Newbie Member
 
Posts: 6
Joined: Sat Oct 25, 2008 3:56 pm

Postby andrew » Mon Oct 27, 2008 11:14 am

With the QCAD Libraries, one could extend QCAD to provide a tool that calculates the sum of all texts in a drawing.

If the drawing is already available in DXF format, there is no need for the QCAD Libraries, but only for dxflib. With dxflib, you could relatively easily write a simple C++ console application, that reads all texts from a DXF file and processes them in whatever way required.
User avatar
andrew
Site Admin
 
Posts: 2528
Joined: Fri Mar 30, 2007 6:07 am


Return to QCAD 2.1/2.2 Developers

Who is online

Users browsing this forum: No registered users and 0 guests