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 - Lua Scripting"

From LibreCAD wiki
Jump to: navigation, search
(Created page with " == LibreCAD Scripting with lua == One of the scripting languages LibreCAD support's is //www.lua.org:Lua. Lua is the default scripting language and will be available for...")
 
Line 1: Line 1:
 +
Lua is a powerful, fast, lightweight, embeddable scripting language developed by a team at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil.
  
 
== LibreCAD Scripting with lua ==
 
== LibreCAD Scripting with lua ==
  
One of the scripting languages LibreCAD support's is [[//www.lua.org:Lua]]. Lua is the default scripting language and will be available for most simple scripting needs.
+
One of the scripting languages LibreCAD support's is [[//www.lua.org|Lua]]. Lua is the default scripting language and will be available for most simple scripting needs.
 
+
Lua is very powerful but at the same time provides a easy to understand programming language.
  
 
Example:
 
Example:
 
<pre>
 
<pre>
.. draw a line from coordinate 0,0 to coordinate 100,00
+
-- draw a line from coordinate 0,0 to coordinate 100,00
l=Line(Coord(0,0), Coord(100,100));
+
 
d=app.currentDocument()
+
-- get the current document
ce = CreateEntities(d, "0");
+
currentDocument=app.currentDocument()
ce:append(l)
+
 
 +
-- Use the Create operation to create new items within a drawing
 +
ce = Create(currentDocument, "0")
 +
 
 +
-- Append a line
 +
ce:append(Line(Coord(0,0), Coord(100,100)))
 +
 
 +
-- Append a circle
 +
ce:append(Circle(Coord(0,0), 12))
 +
 
 +
-- Execute within the document
 
ce:execute()
 
ce:execute()
 
</pre>
 
</pre>

Revision as of 03:20, 12 April 2014

Lua is a powerful, fast, lightweight, embeddable scripting language developed by a team at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil.

LibreCAD Scripting with lua

One of the scripting languages LibreCAD support's is [[1]]. Lua is the default scripting language and will be available for most simple scripting needs. Lua is very powerful but at the same time provides a easy to understand programming language.

Example:

-- draw a line from coordinate 0,0 to coordinate 100,00

-- get the current document
currentDocument=app.currentDocument()

-- Use the Create operation to create new items within a drawing
ce = Create(currentDocument, "0")

-- Append a line
ce:append(Line(Coord(0,0), Coord(100,100)))

-- Append a circle
ce:append(Circle(Coord(0,0), 12))

-- Execute within the document
ce:execute()