OpenSCAD for Lua, uses lua to create 3D models.
OpenSCAD for Lua, use lua to quickly create 3D models.
Explore this project's documentation »
Report a Bug
·
Propose new features
·
English
- lua-cad
Using datum
in lua-cad can accurately determine the datum plane of 3D objects, so as to achieve accurate positioning based on the geometric relationship between objects.
local datum1 = d3object.datum(cube1, 1);
Use the d3object.datum(obj, index)
function to obtain the position of the datum center, and use the datum
library to process geometric relationships.
Quickly reuse modules you create in openscad
in lua-cad.
local shoulder_screw1 = $shoulder_screw( "english", 1/2, length = 20 )$;
Use $
in Lua-cad to create the module you want to define in the openscad file, which will convert it into a variable of type table
. In the user_define_obj
library you can manipulate it further. User-defined object library.
Adopting an object-oriented model, code can be reused efficiently, coding is more flexible, and maintainability is increased.
-- The directory is specified according to the actual situation
package.path = package.path ..';../../../../?.lua';
user_obj = require("src.user_object.user_obj")
--test1
test1 = $shoulder_screw( "english", 1/2, length = 20 )$;
test1.postion(test1, {10, 10, 10});
print("offset");
print("x: ".. test1._offset[1]);
print("x: ".. test1._offset[2]);
print("x: ".. test1._offset[3]);
print("test1");
test1.print(test1);
--test2
test2 = $screw( "#6-32", head="flat undercut",length=12)$;
print("test2")
test2.print(test2);
d3object = require("d3object")
boolean = require("boolean")
transform = require("transform")
local cube1 = d3object.cube({ 10, 10, 10 }, true);
local cube2 = d3object.cube({ 10, 10, 10 }, false);
local difference1 = boolean.difference({cube1, cube2});
local difference2 = boolean.difference({difference1, cube1});
local difference3 = boolean.difference({cube1, cube2, difference2});
local union1 = boolean.union({difference1, difference2});
local intersection1 = boolean.intersection({union1, difference3});
print("difference1 code1 : \n" .. code(intersection1));
export("./export.scad", intersection1);
- Install
xmake
- Clone the repo
git clone https://github.com/SongZihui-sudo/lua-cad.git
- cd lua-cad
- Compile source code
xmake
lua-cad [filepath]
If the parameter filepath
is entered, the file pointed to by the script filepath
is run directly. Otherwise the input is read from the terminal.
eg:
filetree
├── doc
│ └── English
├── lua
│ ├── manual
│ └── tests
│ └── libs
│ └── P1
├── port
│ └── openscad
├── src
│ ├── base_object
│ └── user_object
└── test
/doc document. /lua lua source code, individual files have been modified. /port file export and rendering interface. /src source code. /src/base_object base object source code. /src/user_object User-defined object source code.
Contributions make the open source community a great place to learn, inspire, and create. Any contribution you make is very much appreciated.
- Fork the Project
- Make some changes
- Commit your Changes (
git commit -m 'Add some feature'
) - Push to the Branch to your repo (
git push
) - Open a Pull Request to
feature
Branch.
This project uses Git for version management. You can see the currently available versions in the repository.
SongZihui-sudo
mail: [email protected]
This project is licensed under GPLv3, please see LICENSE.txt for details