Calling InfoDistancePP script from Library item script

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Calling InfoDistancePP script from Library item script

Postby Taygete » Tue May 27, 2014 12:00 pm

Hello, me again :)

I am struggling trying to call InfoDistancePP from my Library item script (like MyRectangle.js).

I would like to let the user drop the library script onto the drawing but before the item is drawn I would like to call InfoDistancePP to get a distance then use this to draw the actual item into the drawing (in this case MyRectangle.js), is this possible?

I found this post (#6) http://www.qcad.org/rsforum/viewtopic.php?f=30&t=1927&hilit=export where Andrew is calling OpenFile from a script and thought I might be able to use it as a base to call InfoDistancePP.

Code: Select all
include("scripts/File/OpenFile/OpenFile.js");
var open = new OpenFile();
open.openFile("/path/to/my/file.dwg");
open.finishEvent();


If I try this code in my MyRectangle.js script it fails in the debugger with the error "TypeError: Result of expression 'open.openFile' [undefined] is not a function."

Where is the call to openFile defined, I cannot find it in OpenFile.js script (or NewFile.js for that matter)?

Hope someone can shed some light, I am struggling with the scripting side of things.

Thanks,

Andrew.
Taygete
Active Member
 
Posts: 29
Joined: Wed May 14, 2014 8:53 am

Re: Calling InfoDistancePP script from Library item script

Postby andrew » Tue May 27, 2014 1:34 pm

Did you consider to create a new script tool instead of a library item?

Library items are typically generated based on user interface input and placed in a user specified position with a user defined angle, scale, etc.

If your item depends on existing drawing entities, a script tool might offer a more flexible approach. A script tool can advance from one state to another, enforcing a workflow. For example:
- user picks 1st coordinate
- user picks 2nd coordinate
- user clicks an existing line, arc, ...
- user adjusts parameters in user interface if desired
- tool creates some entities based on all that user input
User avatar
andrew
Site Admin
 
Posts: 2568
Joined: Fri Mar 30, 2007 6:07 am

Re: Calling InfoDistancePP script from Library item script

Postby Taygete » Tue May 27, 2014 1:54 pm

Hi Andrew,

To be honest at the moment I am finding my away around the system.

I take it we cannot call the InfoDistancePP from a library item script and it has to be script tool?

Thanks,

Andrew.
Taygete
Active Member
 
Posts: 29
Joined: Wed May 14, 2014 8:53 am


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 2 guests