Skip to content

Latest commit

 

History

History
251 lines (186 loc) · 7.77 KB

readme_en.md

File metadata and controls

251 lines (186 loc) · 7.77 KB

lua-cad

OpenSCAD for Lua, uses lua to create 3D models.

Contributors Forks Stargazers Issues GPLv3 License


Logo

Lua-cad

OpenSCAD for Lua, use lua to quickly create 3D models.
Explore this project's documentation »

Report a Bug · Propose new features · English

Table of contents

Features

Use datums to achieve accurate positioning

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.

Fast transplantation, reuse of existing code, compatible with openscad’s module calling statements

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.

Object-oriented

Adopting an object-oriented model, code can be reused efficiently, coding is more flexible, and maintainability is increased.

Example

Simple centrifugal fan housing

Example image1 image2

Reuse openscad
-- 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);
Basic operations
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);

document

Detailed documentation

Getting Started Guide

Source code compilation
  1. Install xmake
  2. Clone the repo
git clone https://github.com/SongZihui-sudo/lua-cad.git
  1. cd lua-cad
  2. Compile source code
xmake
Instructions for use
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. read_line

Architecture diagram

Architecture Diagram

File directory description

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.

Open source projects used

Contributors

How to participate in open source projects

Contributions make the open source community a great place to learn, inspire, and create. Any contribution you make is very much appreciated.

  1. Fork the Project
  2. Make some changes
  3. Commit your Changes (git commit -m 'Add some feature')
  4. Push to the Branch to your repo (git push)
  5. Open a Pull Request to feature Branch.

version control

This project uses Git for version management. You can see the currently available versions in the repository.

author

SongZihui-sudo

mail: [email protected]

Copyright statement

This project is licensed under GPLv3, please see LICENSE.txt for details

Acknowledgments

Star History Chart