Python module for parametric CAD [closed]
Asked Answered
C

6

29

I am looking for a CAD module for python. This is what i've found, correct me if I'm wrong:

  • PythonCAD:
    • file types: DWG,DXF,SVG
    • oriented: click in a window
    • last maintained: 2012-06-15
    • documented: poor and dirty
  • PythonOCC:
    • file types: STEP, IGES, STL (import/export)
    • oriented: scripts
    • last maintained: 2013-01-12
    • documented: good and clear
    • Installation is such a pain
  • FreeCAD (python wrapping)
    • file types: ?
    • oriented: click in a window and python scripting importable from python
    • last maintained: jan 2013
    • documented: very well

Well, it seems the python bindings for FreeCAD is the best but are there other things out there?

Cuspidor answered 25/1, 2013 at 9:40 Comment(2)
This question is a bit problematic since it's so hard to know the scope. You can probably find the best and most up-to-date answers by Googling for "Python parametric CAD". The software available for this sort of thing changes every so often, so any answer would be out of date pretty soon. If you have specific questions about the CAD modules you've found, you could ask those separately. Also, you could get better answers by asking on some mailing list for one of those projects you already listed.Mungovan
Things changed in the last 7 years I gues. From my last 3 hours with PythonOCC: installation is pretty trivial (basically cmake; make; make install), documentation of OCC itself is great indeed, but the usability of SWIG bindings varies from "good enough" to "pure pain and horror" when you encounter certain C++ constructions.Archeozoic
C
12

I found that FreeCAD is the best solution. The python bindings lets you design parts in a comprehensive way.

myShape = Part.makeBox(2,2,2)
myShape.translate(Base.Vector(2,0,0))

From simple geometries you can use boolean operations:

cylinder1 = Part.makeCylinder(3,10,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder2 = Part.makeCylinder(3,10,Base.Vector(5,0,-5),Base.Vector(0,0,1))
common = cylinder1.common(cylinder2)

The only downpoint is the installation with mac os, I could not compile it on snow leaopard (because too much dependencies on unsustained libraries).

But pythonocc has the same problem and what i don't like is the minimal documentation and the synthax which is too much opencascade like and not to much pythonistic.

Cuspidor answered 28/2, 2013 at 10:7 Comment(0)
F
7

CADquery is a plug currently for FreeCad that I have used and worked better than scripting OpenScad in Python. The developers are currently moving from FreeCad to Python OCC for Version 2 but I am currently plugging away with V1.

CQParts is a really important part of what makes cadquery useful. It is an analogue of procedure so you design one wheel etc.

Fishbowl answered 12/3, 2019 at 21:5 Comment(1)
As of 2021, this is what I use. Migration to PythonOCC (and then later to their own OpenCascade Python bindings, OCP) is finished since the release of CadQuery 2.0, and it is now a great (but little known) software ready for real-world parametric CAD usage.Therewithal
O
5

occmodel is a small self-contained library which gives a high level access to the OpenCASCADE modelling kernel.

Oxytetracycline answered 8/10, 2013 at 22:8 Comment(0)
G
3

PythonOCC is probably the most feature complete. Here are some more:

CADDD - uses PythonOCC, has GUI in Qt.

NURBS - Python module for working with NURBS.

lolcad - looks very good but it was not updated for quite some time.

And of cource, you can try to use Blender, which has build-in Python interpreter and there are plugins for architecture and precision modeling (like this)

Gavel answered 27/2, 2013 at 22:20 Comment(0)
D
2

have a view at Salome. The code looks like this:

import sys
import salome

salome.salome_init()
theStudy = salome.myStudy

import salome_notebook
notebook = salome_notebook.NoteBook(theStudy)
sys.path.insert( 0, r'/tmp')

###
### GEOM component
###

import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS


geompy = geomBuilder.New(theStudy)

O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
Vertex_1 = geompy.MakeVertex(0, 0, 0)
Vertex_2 = geompy.MakeVertex(0, 2, 0)
Vertex_3 = geompy.MakeVertex(2, 2, 0)
Line_1 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3)
Line_1_vertex_2 = geompy.GetSubShape(Line_1, [2])
Line_1_vertex_3 = geompy.GetSubShape(Line_1, [3])
Curve_1 = geompy.MakeInterpol([Line_1_vertex_2, Line_1_vertex_3, Vertex_1], True, False)
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
geompy.addToStudy( Vertex_1, 'Vertex_1' )
geompy.addToStudy( Vertex_2, 'Vertex_2' )
geompy.addToStudy( Vertex_3, 'Vertex_3' )
geompy.addToStudy( Line_1, 'Line_1' )
geompy.addToStudyInFather( Line_1, Line_1_vertex_2, 'Line_1:vertex_2' )
geompy.addToStudyInFather( Line_1, Line_1_vertex_3, 'Line_1:vertex_3' )
geompy.addToStudy( Curve_1, 'Curve_1' )
Diphtheria answered 3/5, 2016 at 9:16 Comment(0)
U
2

QSketchMetric is a Python module capable of generating 2D DXF drawings based on parametric descriptions. It comes with comprehensive documentation, including tutorials, explanations, how-to guides, and references.

Parametrization is quick and straightforward using QCAD Professional CAD software to describe a drawing with mathematical expressions, and then using Python to render it.

Urien answered 25/8, 2023 at 17:19 Comment(1)
I recently started using it and as I see the package is pretty new, modern and is well supported, and yep, I love the documentation, even though the package is rlly straightforward. It's just a small simple module, perfect for my needsCorley

© 2022 - 2024 — McMap. All rights reserved.