introduce script variable content in command line

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

Post Reply
User avatar
dfriasb
Full Member
Posts: 74
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

introduce script variable content in command line

Post by dfriasb » Sat Mar 31, 2018 1:01 pm

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
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

User avatar
dfriasb
Full Member
Posts: 74
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: introduce script variable content in command line

Post by dfriasb » Tue Apr 03, 2018 2:43 pm

Here I attach the script. It is working, but just for one specific string: ".v1"
isolate.js
(1.68 KiB) Downloaded 70 times
I would like to be able to define the variable

Code: Select all

subs
that contains this string, from QCAD.

Thanks,

David
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

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

Re: introduce script variable content in command line

Post by andrew » Mon Apr 09, 2018 9:34 pm

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
};

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”