Login  Register

Re: Pseudo scripting with excel - add layer

Posted by dxli on Apr 05, 2025; 4:53pm
URL: https://forum.librecad.org/Pseudo-scripting-with-excel-add-layer-tp5726798p5726860.html

Just one more direction:

Please have a look at emanuel's work on scripting:

https://forum.librecad.org/VIDEO-progress-scripting-td5726821.html

He is working (independently and intrepidly) to grow LibreCAD into a scripting CAD.

I have a dream. Some day, LibreCAD can be a Web CAD.

Goran wrote
Thank you for your time and effort!
I will try to answer your questions.
sand1024 wrote
    Actually, by "last" - it is possible either to consider the entity that was created last. OR - it might be the entity that was last in user's operations i.e. - last selected, last edited... (say, editing, moving etc)

So this is a good question: what should be defined by "last".
The "last" command belongs to the selection category.
The original definition of the "last" command is: "Selects the most recently created visible object. The object must be in the current space (model space or paper space), and its layer must not be frozen or turned off."

However, considering the last edited, moved, etc. entity would likely be more practical.
sand1024 wrote
    Another thing - is the scope of this command. ...

However, the question of scope arises - in other words, what is the lifetime of the "last" and such entities.

If they exist only within the lifecycle of the command script being executed (accessible only by commands in the same script file) - implementation is straightforward, though I'm unsure if this is convenient.

If they could be shared between script files - this might cause confusion, be harder to implement, and I’m not convinced it’s necessary. Please share your thoughts.
IMHO, "last" is a temporary command for short-term use. As a script creator, I’m almost always focused on the last created entity. Everything else might be too complicated to implement.
sand1024 wrote
 > Is it possible to create reserved variables at the project file level

Well, I suggest reviewing these resources:

    MuParser (used by the command line widget):
    https://beltoforion.de/en/muparser/features.php (see "User-defined variables").

    LibreCAD Calculator Documentation:
    https://docs.librecad.org/en/latest/appx/calculator.html

    Check "Application Preferences" → Paths → Variable file.

This should align closely with your needs.
Thank you for your suggestions! I’ll experiment with variables.

Personally, the most important features for me are implementing "change current layer to layer X" or "Add new Layer" as script commands (in the command line).
 
Best regards, Goran