Skip to content
forked from tazjel/declaracad

A declarative 3D modeling application built using Open Cascade and python

License

Notifications You must be signed in to change notification settings

ylwb/declaracad

 
 

Repository files navigation

declaracad

Build Status Build status codecov

A declarative parametric 3D modeling program built using OpenCASCADE and enaml.

See the new website at declaracad.com

Warning: This is a very early in development and unstable application!

DeclaraCAD

It's similar to OpenSCAD in that everything is intended to be defined programatically. However the language being used is enaml (a superset of python) instead of javascript. Python users/developers will find this very easy and intuitive.

It's intended to be used along side of an OCC python binding (either pythonocc or pyOCCT) using either OCC apis directly or the declarative abstractions. You can easily combind parts from various sources into assemblies.

Now uses pyOCCT but was originally based on pythonocc (and I highly recommend pyOCCT!),

See the project site.

Features

Modeling

Currently the following 3D features can be used declaratively:

  1. Basic shapes (Box, Sphere, Cylinder, Wedge, Torus) see shapes
  2. Boolean operations (Cut, Fuse, Common) see algo
  3. Fillet and Chamfer edges see algo
  4. 3D Drawing (Lines, Arcs, BSplines, Beziers, Circles, etc...) see draw
  5. Pipes algo
  6. Extrude (Prism), LinearForm, RevolutionForm algo
  7. ThickSolid, ThroughSections algo

See the examples and the occ package.

You can also embed any shape built using pythonocc directly via a RawShape. See the sprocket example

Viewer

Declaracad uses pythonocc's Qt Viewer and supports basic rotate, pan, zoom. Each view is rendered in a separate process.

Clipping planes are now supported.

declaracad-3d-view-clip-planes

Editor

Multiple editor views are supported. Basic error checking hinting is implemented.

Import / export

Currently there is no import support from other 3d types into editable code, but models can be loaded for display and exported to STL, STEP, or images.

DeclaraCAD - loading models

Importing 2D paths from SVG (ex Adobe Illustrator, Inkscape, etc..) is possible

DeclaraCAD import from svg

Models can be exported to STL or STEP formats for use in other programs (ex Simplify3D, FreeCAD, etc..)

DeclaraCAD export to stl

Example

This is generates a turners cube of a given number of levels.

from enaml.core.api import Looper
from declaracad.occ.api import Box, Sphere, Cut, Part

enamldef TurnersCube(Part):
    name = "Turners Cube"

    attr levels: int = 3
    Looper:
        iterable << range(1,1+levels)
        Cut:
            Box:
                position = (-loop_item/2.0,-loop_item/2.0,-loop_item/2.0)
                dx = loop_item
                dy = loop_item
                dz = loop_item
            Sphere:
                radius = loop_item/1.5

Docs

The goal is for the building blocks or components to be self documenting.

It's partially there... suggestions are welcome!

DeclaraCAD - Docs and Toolbox

Installing

There is currently no installer as it's in pre-alpha state. It runs on windows and linux (have not yet tested osx). To use it:

#: Install conda or miniconda
#: See https://conda.io/miniconda.html

#: Create a conda env
conda create -n declaracad

#: Activate it (on windows just do `activate declaracad`)
source activate declaracad

#: Install it OCCT and dependencies
conda install -c trelau -c conda-forge pyocct

#: Clone the repo
git clone https://github.com/codelv/declaracad.git

#: Go inside the cloned repo
cd declaracad

#: Install declaracad
pip install -e .

See running section.

Running

To run the full application just run declaracad.

declaracad

If you want to use your own editor you can run only a view using

declaracad view <path/to/model.enaml>

Use declaracad -h and declaracad <cmd> -h to see more cli options.

License

The application is released under the GPL v3 (due to the use of PyQt5 and QScintilla).

Special thanks to

This project relies on the groundwork laid out by these projects:

Please share your appreciation to them for all the hard work creating these projects!

About

A declarative 3D modeling application built using Open Cascade and python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%