Coder Social home page Coder Social logo

mcad's Introduction

GitHub (master) CircleCI (master) Coverity Scan

Visit our IRC channel

What is OpenSCAD?

OpenSCAD is a software for creating solid 3D CAD objects. It is free software and available for Linux/UNIX, MS Windows and macOS.

Unlike most free software for creating 3D models (such as the famous application Blender), OpenSCAD focuses on the CAD aspects rather than the artistic aspects of 3D modeling. Thus this might be the application you are looking for when you are planning to create 3D models of machine parts but probably not the tool for creating computer-animated movies.

OpenSCAD is not an interactive modeler. Instead it is more like a 3D-compiler that reads a script file that describes the object and renders the 3D model from this script file (see examples below). This gives you, the designer, complete control over the modeling process and enables you to easily change any step in the modeling process or make designs that are defined by configurable parameters.

OpenSCAD provides two main modeling techniques: First there is constructive solid geometry (aka CSG) and second there is extrusion of 2D outlines. As the data exchange format for these 2D outlines Autocad DXF files are used. In addition to 2D paths for extrusion it is also possible to read design parameters from DXF files. Besides DXF files OpenSCAD can read and create 3D models in the STL and OFF file formats.

Contents

Getting started

You can download the latest binaries of OpenSCAD at https://www.openscad.org/downloads.html. Install binaries as you would any other software.

When you open OpenSCAD, you'll see three frames within the window. The left frame is where you'll write code to model 3D objects. The right frame is where you'll see the 3D rendering of your model.

Let's make a tree! Type the following code into the left frame:

cylinder(h = 30, r = 8);

Then render the 3D model by hitting F5. Now you can see a cylinder for the trunk in our tree. Now let's add the bushy/leafy part of the tree represented by a sphere. To do so, we will union a cylinder and a sphere.

union() {
  cylinder(h = 30, r = 8);
  sphere(20);
}

But, it's not quite right! The bushy/leafy are around the base of the tree. We need to move the sphere up the z-axis.

union() {
  cylinder(h = 30, r = 8);
  translate([0, 0, 40]) sphere(20);
}

And that's it! You made your first 3D model! There are other primitive shapes that you can combine with other set operations (union, intersection, difference) and transformations (rotate, scale, translate) to make complex models! Check out all the other language features in the OpenSCAD Manual.

Documentation

Have a look at the OpenSCAD Homepage (https://www.openscad.org/documentation.html) for documentation.

Building OpenSCAD

To build OpenSCAD from source, follow the instructions for the platform applicable to you below.

Prerequisites

To build OpenSCAD, you need some libraries and tools. The version numbers in brackets specify the versions which have been used for development. Other versions may or may not work as well.

If you're using a newer version of Ubuntu, you can install these libraries from aptitude. If you're using Mac, or an older Linux/BSD, there are build scripts that download and compile the libraries from source. Follow the instructions for the platform you're compiling on below.

For the test suite, additional requirements are:

  • Python3 (3.8 -> )

Getting the source code

Install git (https://git-scm.com/) onto your system. Then run a clone:

git clone https://github.com/openscad/openscad.git

This will download the latest sources into a directory named openscad.

To pull the various submodules (incl. the MCAD library), do the following:

cd openscad
git submodule update --init --recursive

Building for macOS

Prerequisites:

  • Xcode
  • automake, libtool, cmake, pkg-config, wget, meson, python-packaging (we recommend installing these using Homebrew)

Install Dependencies:

After building dependencies using one of the following options, follow the instructions in the Compilation section.

  1. From source

    Run the script that sets up the environment variables:

     source scripts/setenv-macos.sh
    

    Then run the script to compile all the dependencies:

     ./scripts/macosx-build-dependencies.sh
    
  2. Homebrew (assumes Homebrew is already installed)

     ./scripts/macosx-build-homebrew.sh
    

Building for Linux/BSD

First, make sure that you have git installed (often packaged as 'git-core' or 'scmgit'). Once you've cloned this git repository, download and install the dependency packages listed above using your system's package manager. A convenience script is provided that can help with this process on some systems:

sudo ./scripts/uni-get-dependencies.sh

After installing dependencies, check their versions. You can run this script to help you:

./scripts/check-dependencies.sh

Take care that you don't have old local copies anywhere (/usr/local/). If all dependencies are present and of a high enough version, skip ahead to the Compilation instructions.

Building for Linux/BSD on systems with older or missing dependencies

If some of your system dependency libraries are missing or old, then you can download and build newer versions into $HOME/openscad_deps by following this process. First, run the script that sets up the environment variables.

source ./scripts/setenv-unibuild.sh

Then run the script to compile all the prerequisite libraries above:

./scripts/uni-build-dependencies.sh

Note that huge dependencies like gcc, qt, or glib2 are not included here, only the smaller ones (boost, CGAL, opencsg, etc). After the build, again check dependencies.

./scripts/check-dependencies.sh

After that, follow the Compilation instructions below.

Building for Windows

OpenSCAD for Windows is usually cross-compiled from Linux. If you wish to attempt an MSVC build on Windows, please see this site: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows

To cross-build, first make sure that you have all necessary dependencies of the MXE project ( listed at https://mxe.cc/#requirements ). Don't install MXE itself, the scripts below will do that for you under $HOME/openscad_deps/mxe

Then get your development tools installed to get GCC. Then after you've cloned this git repository, start a new clean bash shell and run the script that sets up the environment variables.

source ./scripts/setenv-mingw-xbuild.sh 64

Then run the script to download & compile all the prerequisite libraries above:

./scripts/mingw-x-build-dependencies.sh 64

Note that this process can take several hours, and tens of gigabytes of disk space, as it uses the https://mxe.cc system to cross-build many libraries. After it is complete, build OpenSCAD and package it to an installer:

./scripts/release-common.sh mingw64

For a 32-bit Windows cross-build, replace 64 with 32 in the above instructions.

Building for WebAssembly

We support building OpenSCAD headless for WebAssembly w/ Emscripten, using a premade Docker image built in openscad/openscad-wasm (which also has usage examples):

docker run --rm -it -v $PWD:/src:rw --platform=linux/amd64 openscad/wasm-base:latest \
  emcmake cmake -B build -DEXPERIMENTAL=ON -DCMAKE_BUILD_TYPE=Release && \
docker run --rm -it -v $PWD:/src:rw --platform=linux/amd64 openscad/wasm-base:latest \
  cmake --build build -j10

This creates openscad.wasm & openscad.js in the build/ folder.

openscad/openscad-playground uses the WASM build to provide a Web UI with a subset of features of OpenSCAD.

Compilation

First, run cmake -B build -DEXPERIMENTAL=1 to generate a Makefile in the build folder.

Then run cmake --build build -j. Finally, on Linux you might run cmake --install build as root.

If you had problems compiling from source, raise a new issue in the issue tracker on the github page.

This site and it's subpages can also be helpful: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_OpenSCAD_from_Sources

Once built, you can run tests with ctest from the build directory.

Note: Both cmake --build and ctest accepts a -j N argument for distributing the load over N parallel processes.

Running CI workflows locally

  • Install circleci-cli (you'll need an API key)

    Note: we also use GitHub Workflows, but only to run tests on Windows (which we cross-build for in the Linux-based CircleCI workflows below). Also, act doesn't like our submodule setup anyway.

  • Run the CI jobs

    # When "successful", these will fail to upload at the very end of the workflow.
    circleci local execute --job  openscad-mxe-64bit
    circleci local execute --job  openscad-mxe-32bit
    circleci local execute --job  openscad-appimage-64bit

    Note: openscad-macos can't be built locally.

  • If/when GCC gets randomly killed, give docker more RAM (e.g. 4GB per concurrent image you plan to run)

  • To debug the jobs more interactively, you can go the manual route (inspect .circleci/config.yml to get the actual docker image you need)

    docker run --entrypoint=/bin/bash -it openscad/mxe-x86_64-gui:latest

    Then once you get the console:

    git clone https://github.com/%your username%/openscad.git workspace
    cd workspace
    git checkout %your branch%
    git submodule init
    git submodule update
    
    # Then execute the commands from .circleci/config.yml:
    #    export NUMCPU=2
    #    ...
    #    ./scripts/release-common.sh -snapshot -mingw64 -v "$OPENSCAD_VERSION"

mcad's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcad's Issues

dev branch: fasteners/threads triggers CGAL error

Specifically, if you just load and run fasteners/threads in the 2017/11/12 snapshot (7cb1e93), you'll get these among your errors:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: ss_plane.has_on(sv_prev->point()) File: /opt/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h Line: 294 
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: ss_plane.has_on(sv_prev->point()) File: /opt/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h Line: 294 
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: ss_plane.has_on(sv_prev->point()) File: /opt/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h Line: 294 
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: ss_plane.has_on(sv_prev->point()) File: /opt/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h Line: 294 
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: ss_plane.has_on(sv_prev->point()) File: /opt/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/polygon_mesh_to_nef_3.h Line: 294 

OpenSCAD issue associated: openscad/openscad#1081

Interestingly it works in 2015.03-2. (Testing on Windows using the official x64 builds)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Other gear profiles

For gear or involute_gear, Add cycloidal, triangle, saw tooth, and microgear gear tooth profiles. Cycloidal and microgear tooth profiles are used in clock/watch mechanisms. Saw tooth gears are used in clock/watch escapements. triangle gears are largely historic, i.e. Antikythera mechanism.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Are you looking for a maintainer?

I just threw up a trivial pull request (#31) only to realize that there's 4 years of outstanding pull requests against this repo. At least the ones I looked at look reasonable. Is someone maintaining this code? If not, I'm happy to volunteer to do so...

Just let me know and thanks.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

[dev] Integrating scad-utils

The following files are unusable as is. They seem to depend on a third party library [1]. Current MCAD distribution is self contained as far as I know and doesn't depend on others. And that's, in my mind, the way it should be, since it is distributed with the very own OpenSCAD. It should stay the same way on 'dev' for future releases. Would you consider a PR to integrate 'scad-utils' into MCAD?

array/polar.scad:use <scad-utils/transformations.scad>
array/translations.scad:use <scad-utils/transformations.scad>
fasteners/threads.scad:use <scad-utils/transformations.scad>
general/sweep.scad:use <scad-utils/linalg.scad>
general/sweep.scad:use <scad-utils/transformations.scad>
general/sweep.scad:use <scad-utils/lists.scad>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

CGAL error found in bevel_gear

When using bevel_gear with these other values, any pressure_angle > 38 seems to cause a CGAL error. I have reduced the error example down to this one line, but it may be possible to further reduce it and identify the specific parameter combination which causes this error. The problem appears to be the gear teeth, as the model will finish rendering but will not have any gear teeth.

  bevel_gear (
    number_of_teeth=36,
    pressure_angle=40,
    outside_circular_pitch=240,
    gear_thickness = 2,
    bore_diameter=9,
    cone_distance=24.001,
    finish=bevel_gear_back_cone);

ERROR: CGAL error in CGALUtils::applyBinaryOperator union: CGAL ERROR: assertion violation! Expr: G.mark(v1,0)==G.mark(v2,0)&& G.mark(v1,1)==G.mark(v2,1) File: /Users/kintel/code/OpenSCAD/libraries/install/include/CGAL/Nef_S2/SM_overlayer.h Line: 304


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Gears not producing involute gears

MCAD/gear.scad is not producing involute gears as claimed - the teeth look very boxy.
image

For comparison: gears.scad quotes a cartertools web page on gear construction. That page works through an example that corresponds to
gear(number_of_teeth=20, diametral_pitch=16, pressure_angle=14.5, clearance=0.009860625);
That cartertools gets this:
image
which looks a credible tooth profile, when compared to wikipedia

I tried this in 2015.3 and 2016.09.18 (git a5e4def) on windows 10, using both F5 and F6 and both appear to have the problem. I have not dug around to figure out if it's gears.scad or openscad at fault.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Proposal to integrate OpenSCAD ISO metric thread library / functions into MCAD

Hi,

I've just got permission from TrevM that it is public domain code (source: https://www.thingiverse.com/thing:311031/comments#comment-6423499)

I've been finding myself using this module quite often to implement simple ISO standard screw threading on various models.

I think this will be a good addition to include into MCAD, however I would like to know if there is any changes that should be done to his implementation to keep it to the same quality and interfacing standard for MCAD, so that it is of good enough quality for inclusion into the next OpenSCAD standard library.

If it make sense to do so, I can then clean it up and then do a pull request.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

UX of MCAD/involute_gears.scad gear(), having difficulties in figuring out how to create a simple gear without inner hub

Currently trying to just make a simple flat gear using MCAD lib used in OpenSCAD version 2019.05

Not sure if the latest lib already fixed this, but I've found difficulties with just creating a simple flat gear without a spoke for decorative purpose.

I ended up just copying the gear() module and manually modifying it to throw away the inner hub.

Is this something that can already be done with the right setting, if so is this documented yet?

The other approach is to include a simple_gear() module like below for those who don't want to fiddle with extra features like the hub.

use <MCAD/involute_gears.scad>

module simple_gear (
	number_of_teeth=15,
	circular_pitch=false, 
    diametral_pitch=false,
	pressure_angle=28,
	clearance = 0.2,
	backlash=0,
	twist=0,
	involute_facets=0,
	flat=false)
{
    pi=3.1415926535897932384626433832795;
    
	if (circular_pitch==false && diametral_pitch==false)
		echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch");

	//Convert diametrial pitch to our native circular pitch
	circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch);

	// Pitch diameter: Diameter of pitch circle.
	pitch_diameter  =  number_of_teeth * circular_pitch / 180;
	pitch_radius = pitch_diameter/2;
	echo ("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius);

	// Base Circle
	base_radius = pitch_radius*cos(pressure_angle);

	// Diametrial pitch: Number of teeth per unit length.
	pitch_diametrial = number_of_teeth / pitch_diameter;

	// Addendum: Radial distance from pitch circle to outside circle.
	addendum = 1/pitch_diametrial;

	//Outer Circle
	outer_radius = pitch_radius+addendum;

	// Dedendum: Radial distance from pitch circle to root diameter
	dedendum = addendum + clearance;

	// Root diameter: Diameter of bottom of tooth spaces.
	root_radius = pitch_radius-dedendum;
	backlash_angle = backlash / pitch_radius * 180 / pi;
	half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4;

    linear_exturde_flat_option(flat=flat, height=rim_thickness, convexity=10, twist=twist)
    gear_shape (
        number_of_teeth,
        pitch_radius = pitch_radius,
        root_radius = root_radius,
        base_radius = base_radius,
        outer_radius = outer_radius,
        half_thick_angle = half_thick_angle,
        involute_facets=involute_facets);
}

simple_gear(number_of_teeth=20, circular_pitch=200, rim_thickness = 2);

Which gives what I want

image

If i use gear(number_of_teeth=20, circular_pitch=200, rim_thickness = 2) then i get an unexpected extra hub

image


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

lathe change gears

I would like to add a feature for making involute change gears which are used on lathes, which are similar to the gear function in this file, but generally are symmetric about the plane of rotation instead of having the hub offset, and generally have spokes rather than a flat disk or disk with circular holes. I think many will find this useful. I have the code working, and could simply add the features into the existing gear function with the addition of some spoke parameters and a symmetric flag. Otherwise I could have a separate function altogether. I am not sure who is maintaining the involute gear library and want to tread lightly as I go since I am new to this environment. If anyone has advise, please respond.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

List of Deprecation Warnings

Maybe others could add to this list instead of creating separate issues.

  1. When using hexagon_tube() from regular_shapes.scad:

WARNING: Ignoring unknown module 'test_square_pyramid', in file Documents/SCAD/lib/MCAD/regular_shapes.scad, line 262.
ECHO: " DEPRECATED: function 'reg_polygon' is now deprecated please use 'regular_polygon' instead"
ECHO: " DEPRECATED: function 'reg_polygon' is now deprecated please use 'regular_polygon' instead"


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

[dev] Identical male and female threads generated

The comments on file fasteners/threads.scad claim a difference will be made between external and internal threads, so different clearances will be applied to be able to fit male with female threads.

// ----------------------------------------------------------------------------
// internal - true = clearances for internal thread (e.g., a nut).
// false = clearances for external thread (e.g., a bolt).
// (Internal threads should be "cut out" from a solid using
// difference()).

However that's not true and the clearance defined is not used to generate the profiles. Therefore the two threads, male and female, are generated identically and are therefore unable to fit one into the other if printed as is.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

involute_gears.scad has improper pitch check

Somehow the check got broken or out of order. The if statement would probably work fine if it were below the ternary operator setting the circular_pitch, or it should check for the diametral_pitch being undef as well.

MCAD/involute_gears.scad

Lines 321 to 325 in bd0a7ba

if (circular_pitch==undef)
echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch");
//Convert diametrial pitch to our native circular pitch
circular_pitch = (circular_pitch!=undef?circular_pitch:pi/diametral_pitch);

Deprecated error - square_pyramid

//WARNING: variable triangles not specified as parameter, in file regular_shapes.scad, line 249
//DEPRECATED: polyhedron(triangles=[]) will be removed in future releases. Use polyhedron(faces=[]) instead.

//Old code

module square_pyramid(base_x, base_y,height)
{
w=base_x/2;
h=base_y/2;
polyhedron(points=[[-w,-h,0],[-w,h,0],[w,h,0],[w,-h,0],[0,0,height]],triangles=[[0,3,2,1], [0,1,4], [1,2,4], [2,3,4], [3,0,4]]);
}

//My fix?

module square_pyramid(base_x, base_y,height)
{
w=base_x/2;
h=base_y/2;
polyhedron(points=[[-w,-h,0],[-w,h,0],[w,h,0],[w,-h,0],[0,0,height]],faces=[[0,3,2,1], [0,1,4], [1,2,4], [2,3,4], [3,0,4]]);
}

// Tests:

Also removed...

// Tests:

test_square_pyramid(){square_pyramid(10, 20, 30);}

Because...

//WARNING: Ignoring unknown module 'test_square_pyramid', in file regular_shapes.scad, line 262


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.