scripting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

scripting

ravas
Are we going to support scripting in v2?
If not, then I want to remove the following:

#ifdef RS_SCRIPTING
    // Scripts menu:
    //
    scriptMenu = new QMenu(tr("&Scripts"));
    scriptMenu->setObjectName("Scripts");
    scriptOpenIDE = AF.createAction("ScriptOpenIDE", this);
    scriptOpenIDE->addTo(scriptMenu);
    scriptRun = AF.createAction("ScriptRun", this);
    scriptMenu->addAction(scriptRun);
    menuBar()->addMenu(scriptMenu);
#else
    scriptMenu = 0;
    scriptOpenIDE = 0;
    scriptRun = 0;
#endif
Reply | Threaded
Open this post in threaded view
|

Re: scripting

dxli
I don't quite understand the qt scripting.

If it's useful, I think we should support it.

However, the probably solution is still a real scripting language: like Lua in v3, or python.

ravas wrote
Are we going to support scripting in v2?
If not, then I want to remove the following:

#ifdef RS_SCRIPTING
    // Scripts menu:
    //
    scriptMenu = new QMenu(tr("&Scripts"));
    scriptMenu->setObjectName("Scripts");
    scriptOpenIDE = AF.createAction("ScriptOpenIDE", this);
    scriptOpenIDE->addTo(scriptMenu);
    scriptRun = AF.createAction("ScriptRun", this);
    scriptMenu->addAction(scriptRun);
    menuBar()->addMenu(scriptMenu);
#else
    scriptMenu = 0;
    scriptOpenIDE = 0;
    scriptRun = 0;
#endif
Reply | Threaded
Open this post in threaded view
|

Re: scripting

Mike Hayes
I know it's the long term aim to incorporate proper scripting in V3, but it would be really neat to have something in V2 however simple.

For example, would it be possible to allow the contents of a plain text file to be redirected to the command prompt?

Obviously this would only be able to mimic a multiple list of commands as if they had been typed at the prompt. But it would still have uses such as demos and tutorials.

Mike
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
Yes it's possible.

I imagine an option to choose the scripts folder,
and a command like:
script test.txt
or
script test

The program loops through the lines
and passes them to the same function that reads the commandline input.

It's low on my priorities at the moment,
maybe in a few weeks,
or someone else could implement it.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
In reply to this post by dxli
QS_Scripter and qsproject.h do not exist;
therefore, it seems like the #ifdef RS_SCRIPTING blocks are junk code.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

LordOfBikes
Administrator
It's correct, that these files doesn't exist in LC repo. I suppose they were part of the commercial QCad version, not GPL licensed.

But I wouldn't say junk code. It gives an idea of the QCad implementation and maybe helpful for implementing our own solution.
It's okay to remove the code when implement scripting for LC, but I wouldn't remove it only because it's unused.

If we come to the decision to cancel scripting in V2, deleting this code is beyond debate.

Armin
investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
If I remove it all in one commit then that can serve (actually more efficiently) as a way to look at the code.
Honestly, I'm skeptical if this code would actually help a person capable of implementing scripting.

It would be nice to get things cleaned up so we could use Doxygen at some point;
and obviously we don't want dead code exposed.

Reducing the number of functions in qc_applicationwindow will also help make it easier to read and find things.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

dxli
let's try to handle this "Super long mainwindow" syndrome:

I'm thinking about moving your Gui work to another class:

conceptually:
class GuiHelper {

private:
/** all buttons, menus, toolbars managed here */

void createButtons();
void createMenus();
void connectActions();

public:
// set up Gui for appWin
GuiHelper(QC_ApplicationWindow* appWin);
};
ravas wrote
If I remove it all in one commit then that can serve (actually more efficiently) as a way to look at the code.
Honestly, I'm skeptical if this code would actually help a person capable of implementing scripting.

It would be nice to get things cleaned up so we could use Doxygen at some point;
and obviously we don't want dead code exposed.

Reducing the number of functions in qc_applicationwindow will also help make it easier to read and find things.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
In reply to this post by dxli
If you want to help I think there is the possibility of making a FileManager and/or PrintManager.
However, it would be appreciated if you wait until I have completed the aforementioned project to help avoid commit conflicts.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
In reply to this post by dxli
I think you unsubscribed from the repository.
I don't see you on the watchers list.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

dirkske
In reply to this post by dxli
Is there scripting support for a plug-in API?  Preferably using Python since coders with CAD interest would have both FreeCAD & LibreCAD using same scripting language. Plus, a wide set of usable libraries to access via Python.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
Reply | Threaded
Open this post in threaded view
|

Re: scripting

ravas
In reply to this post by Mike Hayes
"For example, would it be possible to allow the contents of a plain text file to be redirected to the command prompt?"

This is something I'm interested in working on after the release of 2.1.0

Could you provide me with something you would use this for?
I can imagine possibilities, but I'm interested in how people would use this.
Reply | Threaded
Open this post in threaded view
|

Re: scripting

Mike Hayes
A typical architectural use might be automatically drawing the side view of a staircase given the length, height, and number of steps.

I realise that such a use would not be achievable solely by redirecting a text file to the command prompt, which would be limited to replaying a fixed pre-written sequence.

A facility to pause and accept variable user input would also be necessary. Perhaps this could be combined with a suggestion I made in another thread about being able to use variables with the command line calculator <a href="http://">http://forum.librecad.org/Variables-in-command-line-calculator-tp5711464.html