Git Product home page Git Product logo

openscad-makefile's Introduction

openscad-multivariants-python-makefile

This is a build system that uses python to automatically generates a list of different variations. In addition it will autogenerate a html download page of all your model variations for easy web sharing.

Click here for a live example of an autogenerated html download page

This is suitable for openscad users who is creating a singular scad projects with lots of variations or parts.

  • make all - Make all png previews and stl files
  • make clear - Clear all build files

Tip:

  • make -j8 all - Same as make all but runs up to 8 jobs at the same time, leading to faster compilation. This is called Parallel Execution as explained in gnu make manual.

This is a community supported build system so feel free to suggest change or put in a pull request for consideration.

Below is an example screenshot of the html download page generation output used for an actual project (creating small challenge coins), which should give you an idea of it's capability in the field:

Minimum support

This is intented to be used by windows users and linux users.

You need at least minimum:

  • OpenSCAD installed
  • makefile support
  • Python 3.6 or higher

Features

  • changes to models/*.json does not always kick off all the stl builds if there is no changes to source code or the variation in file.

How does this build system works

graph TD
    paramGen(["parameter_generator.py"])     -- generates if missing  --> paramSettings
    paramSettings["models/*.json"]           -- used by    --> paramVariants
    paramVariants(["parameter_variants.py"]) -- updates on change  --> variants
    variants["variants/*.json"]              -- settings   --> scadGen
    sourcecode["models/*.scad"]              -- sourcecode --> scadGen
    scadGen(["openScad"])
    scadGen                                  --> png
    scadGen                                  --> stl
    png["png/*.png"]                         -- used for image preview --> paramHTML
    stl["stl/*.stl"]                         -- used for download link --> paramHTML
    paramSettings                            -- used for documentation --> paramHTML
    paramHTML(["parameter_html.py"])         -- generates  --> html
    html["index.html"]

Adapting to your project

  • Run make clean to clean out any existing generated stls
  • Change parameter_generator.py to match your needs then delete models/*.json file
  • Adapt models/*.scad to include your code
  • Update makefile changing these below settings to match your source name
# Model Details
PROJNAME = test
SCAD_PATH = models/$(PROJNAME).scad
JSON_PATH = models/$(PROJNAME).json
  • Run make all to autogenerate the missing parameter setting list models/*.json and kick off the variations

Let me know if instructions does not make sense and we can update it to make it clearer

Tips

Compiling multiple makefile folders

SUBDIRS = $(sort $(dir $(wildcard ./*/))) #folders to look for

# OS DETECT https://stackoverflow.com/questions/714100/os-detecting-makefile
isWindows=
ifeq ($(OS),Windows_NT)
ifeq (, $(shell uname))
	isWindows=Yes
endif
endif
ifeq ($(isWindows),Yes)
    SPLITCOMMAND = &
else
    SPLITCOMMAND = ;
endif

# Stackoverflow: How to write a loop in a makefile https://stackoverflow.com/a/1491012/2850957
.PHONY: all clean $(SUBDIRS)
all:
	$(foreach var,$(SUBDIRS),$(MAKE) --directory=$(var) all $(SPLITCOMMAND))
clean:
	$(foreach var,$(SUBDIRS),$(MAKE) --directory=$(var) clean $(SPLITCOMMAND))

openscad-makefile's People

Contributors

mofosyne avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

loudej

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.