Coder Social home page Coder Social logo

codecad's Introduction

CodeCad: A programming CAD based on signed distance functions

The project is dead

Some good points:

  • The modeling API turned out to be surprisingly comfortable. Might be worth reusing in some later project.
  • OpenCL and Python is an awesome combination.

... and some bad points ..

  • SDF is a neat way to represent geometry, but there are some serious drawbacks
    • It's hard to make them robust. Things like s.offset(-1).offset(1) tend to break the invariants create weird glitches. This becomes extra visible when using the distance function value for shading, but is hard to avoid even when just working for surface export.
    • While physical objects are mostly comprised of their insides, the surface is where the interesting things happen and it is a bit wastefull to have to find the surface agin for every rendering operation, physics query...
  • Only code for modelling is not good enough. While some things are easier than with GUI clickery, most are more difficult and I'm still looking for a way that is bettern than either of these.

Now you can enjoy the old description:

Inspired by OpenSCAD and ImplicitCad, implemented in Python using OpenCL for computing power.

CodeCad cube logo

Currently CodeCad consists mostly of an API for representing and manipulating geometry using CSG operations and exports to STL and image. There is also a simple part/assembly model and BOM generator.

Goals

At this stage the main goal is to have usability on par with OpenSCAD. We're not there yet, although some useable models can already be created.

In the long term this should have a working GUI and parametric sketch tools.

Who knows what's next. Maybe turning this into a slicer?

Requirements

The main requirement to run CodeCad is a working OpenCL implementation. Your GPU should provide one, or try POCL.

CodeCad might work on Windows, but it hasn't been tested.

Example Code

The cube at the beginning of this file was generated by the following piece of code:

import codecad
from codecad.shapes import *

width = 0.6
stroke = 0.2

# Build the C shape  1 unit high
c = (rectangle(width, 1 - width + stroke / 2)
     + circle(d=width).translated_y((1 - width) / 2)
     + circle(d=width).translated_y(-(1 - width) / 2))
c = c.shell(stroke)
c -= rectangle(width, 1 - width).translated_x(width / 2)

# Scale it to 1 unit sized cube and prepare for adding
c = (c
     .scaled(0.6)
     .extruded(0.12)
     .rotated_x(90)
     .translated_y(-0.5))

# Put the logo together
logo = box() + c + c.rotated_z(90)
logo = (logo
        .scaled(100)
        .rotated_z(-45)
        .rotated_x(15))

codecad.commandline_render(logo)

codecad's People

Contributors

bluecube avatar dependabot[bot] avatar

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.