Page 1 of 1

Calling InfoDistancePP script from Library item script

Posted: Tue May 27, 2014 12:00 pm
by Taygete
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.

Re: Calling InfoDistancePP script from Library item script

Posted: Tue May 27, 2014 1:34 pm
by andrew
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

Re: Calling InfoDistancePP script from Library item script

Posted: Tue May 27, 2014 1:54 pm
by Taygete
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.