Page 1 of 1

introduce script variable content in command line

Posted: Sat Mar 31, 2018 1:01 pm
by dfriasb
Hello all,

I would like to write a script that works like this:

1.- Ask me in command line to introduce a string.
2.- Use this string to find certain layer names.
3.- Set specific properties to this layers, like freezing, locking, etc.

I know how to do steps 2. and 3., but I never succeed on step 1. I've found the way to ask a coordinate via command line, but not a string to fill a variable content of the script. Any help with that would be appreciated.

Regards! David

Re: introduce script variable content in command line

Posted: Tue Apr 03, 2018 2:43 pm
by dfriasb
Here I attach the script. It is working, but just for one specific string: ".v1"
isolate.js
(1.68 KiB) Downloaded 842 times
I would like to be able to define the variable

Code: Select all

subs
that contains this string, from QCAD.

Thanks,

David

Re: introduce script variable content in command line

Posted: Mon Apr 09, 2018 9:34 pm
by andrew
Actions in QCAD are event based. Whenever something occurs (mouse moved, mouse clicked, key pressed, command entered in command line, action begins, action ends, etc.) an event is triggered.

If you want to stop everything and wait for the user to enter something, you need to show a dialog.

The command line can be used at any time while the action is running. If the user enters a value, that value is passed to commandEvent of the action:

Code: Select all

MyAction.prototype.commandEvent = function(event) {
    var cmd = event.getCommand();
    // user entered the contents of cmd in command line
};