Calling InfoDistancePP script from Library item script

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.

Post Reply
Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Calling InfoDistancePP script from Library item script

Post by 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) 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.

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

Re: Calling InfoDistancePP script from Library item script

Post by 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

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: Calling InfoDistancePP script from Library item script

Post by 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.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”