Hi fratink,
fratink wrote: ↑Mon Dec 31, 2018 3:09 am
Is there a way to add scripts that use the command line in the qcad GUI?
Simple answer: No
More involved answer: Yes
The simplest way to achieve this is to use the 'script shell' (Misc->Development->Script Shell). This allows you to load scripts containing functions, which you can then run in script shell's command line. (see the 'simple.js' file and others to see how this is done). You could even add your functions to the 'simple_create.js' file, so when the 'script shell' is started your functions will be loaded. However, you have to use script shell's command line rather than the standard command line.
If you need to use the standard command line, you could alter the 'commandline.js' file, which is in 'scipts/Widgets/commandLine'.
If you add the following code to 'commandLine.js' (line 253, just before the '// Handle direct distance entry;' line), you can then run functions by prefixing your function name with a 'greater than' symbol (>).
Code: Select all
// treat command as ecmascript
if (command.startsWith(">")) {
// remove leading '>'
command = command.slice(1);
if (eval(command)) {
// success
leCommand.clear();
return;
} else {
// failure
}
}
This is very simple, so you can alter it to suit your needs. You could also change the prefix to any other character. (I don't think this breaks anything, but you may know better).
So you could run your function like
I hope this helps to answer your question.
Regards
riverbuoy