Skip to content

Instantly share code, notes, and snippets.

View arnholm's full-sized avatar

Carsten Arnholm arnholm

View GitHub Profile
@arnholm
arnholm / scadx.cmd
Created December 16, 2021 20:51
scadx.cmd Create an STL file from OpenSCAD *.scad file REM Without using OpenSCAD boolean engine.
@echo off
REM
REM scadx.cmd
REM =========
REM Create an STL file from OpenSCAD *.scad file REM Without using OpenSCAD boolean engine.
REM Use AngelCADs xcsg instead
REM Note: Some OpenSCAD commands not supported: surface
REM
REM Author: Carsten Arnholm, August 2020
REM
// AngelCAD code.
shape@ main_shape(as_args@ args)
{
double l = 20.5; // mm
double w = 10.5; // mm
double diam = 16.0; // mm
double tol = 0.75; // mm
solid@ pipe = rotate_y(deg:-90)
// AngelCAD code.
// https://arnholm.github.io/angelcad-docs/
solid@ transfer_solid(double side, double height)
{
// lower square shape
solid@ lower = translate(0,0,-height/2)
*linear_extrude(square(side,center:true),1.0);
// upper circular shape
cylinder(r=30,h=30);
@arnholm
arnholm / test2.as
Last active April 9, 2021 13:46
Sweep along spline curve
// AngelCAD code.
shape@ main_shape(as_args@ args)
{
array<pos3d@> pts = {
{0.000000,0,10.593750}
,{0.000000,0,10.406250}
,{-0.003906,0,10.199219}
,{-0.011719,0,9.972656}
,{-0.023438,0,9.726562}

3d hull from an array of solids

// AngelCAD code.

shape@ main_shape(as_args@ args)
{
   array<solid@> spheres;
   for(int i=-1; i<=1; i+=2) 
 for(int j=-1; j&lt;=1; j+=2) 

Create polyhedron from point cloud

When a polyhedron is created from an array of points, it is interpreted as a convex hull

// AngelCAD code.
shape@ main_shape(as_args@ args)
{
   array<pos3d@> hull_points = { {-1,-1,0}, {-1,1,0}, {1,1,0}, {1,-1,0}, {1/2,1,2} };
 return polyhedron(hull_points);
// AngelCAD code: USB-winkeler.as
// https://arnholm.github.io/angelcad-docs/
// (Adapted from USB-Winkeler-bug.scad by Dietrich)

// calbe diameter
double d1 = 5;
// 90º Radius
double r1= 20;
//wall thickness

Original problem using OpenSCAD to import an STL fils

union()
{
  translate([0, 0, 6])
  scale([0.9842519685, 0.9842519685, 1])
  import("floor.stl");
  cube([50, 50, 6]);
}