Introduction to Scripting

LuminiCAD’s scripting interface lets you create precise models using text commands. It’s especially useful for:

  • Creating patterns and arrays
  • Building complex shapes from simple ones
  • Making parametric designs
  • Automating repetitive tasks

Using Variables

Commands can be assigned to variables for later use:

base = CREATE RECTANGLE ORIGIN 0 0 0 SIZE 100 50
CREATE PRISM SECTION $base LENGTH 200

edge1 = CREATE LINE FROM 0 0 0 TO 100 0 0
arc1 = CREATE ARC CENTER 100 0 0 START 100 10 0 NORMAL 0 0 1 ANGLE 90

Use the $ prefix when referencing variables in subsequent commands

Basic Commands

Creating Simple Shapes

CREATE BOX ORIGIN x y z SIZE dx dy HEIGHT dz

# Example
CREATE BOX ORIGIN 0 0 0 SIZE 100 50 HEIGHT 75

Advanced Operations

Extrusion and Sweeping

CREATE PRISM SECTION [section-command] LENGTH length

# Example
CREATE PRISM SECTION [CREATE CIRCLE CENTER 0 0 0 RADIUS 25 NORMAL 0 0 1] LENGTH 100

Boolean Operations

CREATE FUSE BOTTOM [bottom-command] TOP [top-command]

# Example
CREATE FUSE BOTTOM [CREATE BOX ORIGIN 0 0 0 SIZE 50 50 HEIGHT 20] 
TOP [CREATE CYLINDER CENTER 25 25 20 RADIUS 15 HEIGHT 30]

Creating Complex Shapes

Wire Creation

CREATE WIRE EDGES [edge-command] AND [edge-command]

# Example - Creating a rectangular wire
CREATE WIRE EDGES 
[CREATE LINE FROM 0 0 0 TO 100 0 0] AND
[CREATE LINE FROM 100 0 0 TO 100 100 0] AND
[CREATE LINE FROM 100 100 0 TO 0 100 0] AND
[CREATE LINE FROM 0 100 0 TO 0 0 0]

Organization with Folders

CREATE FOLDER NAME "My Components"

Practical Examples

Creating a Patterned Cylinder

// Create base cylinder
CREATE CIRCLE CENTER 0 0 0 RADIUS 25 NORMAL 0 0 1
CREATE PRISM SECTION [previous-circle] LENGTH 100

// Create a single hole
CREATE CIRCLE CENTER 20 0 0 RADIUS 5 NORMAL 1 0 0
CREATE PRISM SECTION [previous-circle] LENGTH 60

// Pattern the hole around the cylinder
CREATE REVOLVE PROFILE [previous-hole] 
AXIS ORIGIN 0 0 0 DIRECTION 0 0 1 ANGLE 360

Building a Flanged Connection

// Create the base flange
CREATE CIRCLE CENTER 0 0 0 RADIUS 50 NORMAL 0 0 1
CREATE PRISM SECTION [previous-circle] LENGTH 10

// Add the pipe
CREATE CIRCLE CENTER 0 0 10 RADIUS 25 NORMAL 0 0 1
CREATE PRISM SECTION [previous-circle] LENGTH 100

// Add bolt holes
CREATE CIRCLE CENTER 40 0 0 RADIUS 6 NORMAL 0 0 1
CREATE PRISM SECTION [previous-circle] LENGTH 10
CREATE REVOLVE PROFILE [previous-hole] 
AXIS ORIGIN 0 0 0 DIRECTION 0 0 1 ANGLE 360

When creating complex models, break down your design into simple shapes first, then combine them using boolean operations.

Best Practices

  1. Organization

    • Use folders to group related components
    • Follow a consistent naming convention
    • Break complex shapes into manageable parts
  2. Efficiency

    • Create patterns using REVOLVE or SWEEP when possible
    • Use boolean operations to combine shapes
    • Reuse common components through folders
  3. Troubleshooting

    • Check your coordinates and measurements
    • Verify normal directions for circles and profiles
    • Ensure boolean operations have valid shapes

Remember that all measurements are in millimeters (mm) and angles in degrees.