We have moved to https://dokuwiki.librecad.org/

Lots of content was already moved to the new wiki, but there is still work to do. If you want to contribute, please register a new account at https://dokuwiki.librecad.org/

This wiki will be kept for a while to keep search engine results valid. Moved sites may be deleted here in future.

Difference between revisions of "LibreCAD 3 - Document operations"

From LibreCAD wiki
Jump to: navigation, search
(Add EntityBuilder and other operations)
 
Line 5: Line 5:
  
 
This class is used to prevent the Document being in invalid state on undo/redo. All the operations added to Builder are undo-ed at the same time.
 
This class is used to prevent the Document being in invalid state on undo/redo. All the operations added to Builder are undo-ed at the same time.
 +
 +
== EntityBuilder ==
 +
The [http://wiki.librecad.org/lc3doc/lckernel/html/df/d23/classlc_1_1operation_1_1_document_operation.html EntityBuilder] is a class designed to insert entities in the document and modify them.
 +
 +
To use it, you have to add the entities using appendEntity() method.
 +
 +
If you need it, you can do [http://wiki.librecad.org/lc3doc/lckernel/html/dc/da9/classlc_1_1operation_1_1_base.html operations] on the entities before inserting them, with appendOperation() method.
 +
 +
If two operations are incompatible, you can use processStack() method, it will modify each entity and clear the Operation queue.
 +
 +
=== Push / SelectByLayer ===
 +
 +
Those are the most important operations and are required before doing anything else.
 +
 +
The operations use their own list of entities and not the one used by appendEntity(). The Push operation add every entity present in the EntityBuilder to the list, and SelectByLayer only add the ones from a specific layer.
 +
More selectors will be added in the future.
 +
 +
=== Loop ===
 +
 +
This will repeat each operation added before n times.
 +
 +
== Other operations ==
 +
 +
The other operations doesn't need explanations, this includes:
 +
* AddLayer
 +
* RemoveLayer
 +
* ReplaceLayer
 +
* AddBlock
 +
* RemoveBlock
 +
* ReplaceBlock
 +
* AddLinePattern
 +
* RemoveLinePattern
 +
* ReplaceLinePattern

Latest revision as of 21:12, 25 July 2017

LibreCAD 3 has many operations accessible in Lua. You can see the full up-to-date list here.

Builder

The Builder is a container for others Document operations (including Builder itself).

This class is used to prevent the Document being in invalid state on undo/redo. All the operations added to Builder are undo-ed at the same time.

EntityBuilder

The EntityBuilder is a class designed to insert entities in the document and modify them.

To use it, you have to add the entities using appendEntity() method.

If you need it, you can do operations on the entities before inserting them, with appendOperation() method.

If two operations are incompatible, you can use processStack() method, it will modify each entity and clear the Operation queue.

Push / SelectByLayer

Those are the most important operations and are required before doing anything else.

The operations use their own list of entities and not the one used by appendEntity(). The Push operation add every entity present in the EntityBuilder to the list, and SelectByLayer only add the ones from a specific layer. More selectors will be added in the future.

Loop

This will repeat each operation added before n times.

Other operations

The other operations doesn't need explanations, this includes:

  • AddLayer
  • RemoveLayer
  • ReplaceLayer
  • AddBlock
  • RemoveBlock
  • ReplaceBlock
  • AddLinePattern
  • RemoveLinePattern
  • ReplaceLinePattern