GithubHelp home page GithubHelp logo

cadquery / cadquery Goto Github PK

View Code? Open in Web Editor NEW
2.8K 59.0 272.0 7.79 MB

A python parametric CAD scripting framework based on OCCT

Home Page: https://cadquery.readthedocs.io

License: Other

Shell 0.04% Python 99.86% Batchfile 0.01% Jinja 0.09%
python parametric cad 3d modeling brep opencascade occt step stl

cadquery's Introduction

CadQuery logo

CadQuery

Appveyor Build status Build Status codecov Documentation Status DOI


Quick Links

Documentation | Cheatsheet | Discord | Google Group | GUI Editor


What is CadQuery

CadQuery is an intuitive, easy-to-use Python module for building parametric 3D CAD models. Using CadQuery, you can write short, simple scripts that produce high quality CAD models. It is easy to make many different objects using a single script that can be customized.

CadQuery is often compared to OpenSCAD. Like OpenSCAD, CadQuery is an open-source, script based, parametric model generator. However, CadQuery stands out in many ways and has several key advantages:

  1. The scripts use a standard programming language, Python, and thus can benefit from the associated infrastructure. This includes many standard libraries and IDEs.
  2. CadQuery's CAD kernel Open CASCADE Technology (OCCT) is much more powerful than the CGAL used by OpenSCAD. Features supported natively by OCCT include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations, in addition to the standard CSG operations supported by CGAL
  3. Ability to import/export STEP and the ability to begin with a STEP model, created in a CAD package, and then add parametric features. This is possible in OpenSCAD using STL, but STL is a lossy format.
  4. CadQuery scripts require less code to create most objects, because it is possible to locate features based on the position of other features, workplanes, vertices, etc.
  5. CadQuery scripts can build STL, STEP, AMF and 3MF faster than OpenSCAD.

CadQuery was built to be used as a Python library without any GUI. This makes it great for use cases such as integration into servers, or creating scientific and engineering scripts. Options for visualization are also available including CQ-Editor and JupyterLab.

For those who are interested, the OCP repository contains the current OCCT wrapper used by CQ.

Key features

  • Build 3D models with scripts that are as close as possible to how you would describe the object to a human.
  • Create parametric models that can be very easily customized by end users.
  • Output high quality (loss-less) CAD formats like STEP and DXF in addition to STL, VRML, AMF and 3MF.
  • Provide a non-proprietary, plain text model format that can be edited and executed with only a web browser.
  • Offer advanced modeling capabilities such as fillets, curvilinear extrudes, parametric curves and lofts.
  • Build nested assemblies out of individual parts and other assemblies.

Why this fork

The original version of CadQuery was built on the FreeCAD API. This was great because it allowed for fast development and easy cross-platform capability. However, we eventually started reaching the limits of the API for some advanced operations and selectors. This 2.0 version of CadQuery is based directly on a Python wrapper of the OCCT kernel. This gives us a great deal more control and flexibility, at the expense of some simplicity and having to handle the cross-platform aspects of deployment ourselves. We believe this is a worthwhile trade-off to allow CadQuery to continue to grow and expand in the future.

Getting started

To learn more about designing with CadQuery, visit the documentation, examples, and cheatsheet.

To get started playing around with CadQuery and see its capabilities, take a look at the CQ-editor GUI. This easy-to-use IDE is a great way to get started desiging with CadQuery. The CQ-editor installer bundles both CQ-editor and CadQuery (recommended). See the CQ-editor installation instructions.

The CadQuery library (with or without CQ-editor) and its dependencies may be installed using conda, or pip. Note that conda (or the CQ-editor installer) is the better supported option.

See the documentation for detailed CadQuery installation instructions.

There are also videos covering installation:

CadQuery Installation Via Conda

To first install the Conda package manager see Install the Conda Package Manager, and Mambaforge for a minimal installer.

mamba install is recommended over conda install for faster and less memory intensive cadquery installation.

# Set up a new environment
conda create -n cadquery

# Activate the new environment
conda activate cadquery

# Install the latest released version
mamba install -c conda-forge cadquery

# Or install the dev version to get the latest changes
mamba install -c conda-forge -c cadquery cadquery=master

CadQuery Installation Via Pip

CadQuery has a complex set of dependencies including OCP, which is our set of bindings to the OpenCASCADE CAD kernel. OCP is distributed as binary wheels for Linux, MacOS and Windows. However, there are some limitations. Only Python 3.9 through 3.12 are currently supported, and some older Linux distributions such as Ubuntu 18.04 are not supported. If the pip installation method does not work for your system, you can try the conda installation method.

It is highly recommended that a virtual environment is used when installing CadQuery, although it is not strictly required. Installing CadQuery via pip requires a up-to-date version of pip, which can be obtained with the following command line (or a slight variation thereof).

python3 -m pip install --upgrade pip

Once a current version of pip is installed, CadQuery can be installed using the following command line.

pip install cadquery

It is also possible to install the very latest changes directly from CadQuery's GitHub repository, with the understanding that sometimes breaking changes can occur. To install from the git repository, run the following command line.

pip install git+https://github.com/CadQuery/cadquery.git

CQ-editor GUI

CQ-editor is an IDE that allows users to edit CadQuery model scripts in a GUI environment. It includes features such as:

  • A graphical debugger that allows you to step through your scripts.
  • A CadQuery stack inspector.
  • Export to various formats, including STEP and STL, directly from the menu.

More on CQ-editor:

CQ editor screenshot

Jupyter

CadQuery supports Jupyter out-of-the-box. Run your CadQuery code in the notebook and visualize the model by calling display(<CadQuery object>).

Getting help

You can find the full CadQuery documentation at cadquery.readthedocs.io.

We also have a Google Group to make it easy to get help from other CadQuery users. We want you to feel welcome and encourage you to join the group and introduce yourself. We would also love to hear what you are doing with CadQuery.

There is a Discord server as well. You can ask for help in the general channel.

Projects using CadQuery

Here are just a few examples of how CadQuery is being used.

FxBricks Lego Train System

FxBricks uses CadQuery in the product development pipeline for their Lego train system. FxBricks has also given back to the community by creating documentation for their CAD pipeline. They have also assembled cq-kit, a library containing utility classes and functions to extend the capabilities of CadQuery. Thanks to @michaelgale and @fx-bricks for this example.

FxBricks Pipeline Diagram

Hexidor Board Game Development

Hexidor is an expanded take on the Quoridor board game, and the development process has been chronicled here. CadQuery was used to generate the game board. Thanks to Bruce for this example.

Hexidor Board Game

Spindle assembly

Thanks to @marcus7070 for this example from here.

3D Printed Resin Mold

Thanks to @eddieliberato for sharing this example of an anti-kink resin mold for a cable.

3D printed resin mold

License

CadQuery is licensed under the terms of the Apache Public License, version 2.0.

Contributing

Contributions from the community are welcome and appreciated.

You do not need to be a software developer to have a big impact on this project. Contributions can take many forms including, but not limited to, the following:

  • Writing and improving documentation
  • Triaging bugs
  • Submitting bugs and feature requests
  • Creating tutorial videos and blog posts
  • Helping other users get started and solve problems
  • Telling others about this project
  • Helping with translations and internationalization
  • Helping with accessibility
  • Contributing bug fixes and new features

It is asked that all contributions to this project be made in a respectful and considerate way. Please use the Python Community Code of Conduct's guidelines as a reference.

Contributing code

If you are going to contribute code, make sure to follow this steps:

  • Consider opening an issue first to discuss what you have in mind
  • Try to keep it as short and simple as possible (if you want to change several things, start with just one!)
  • Fork the CadQuery repository, clone your fork and create a new branch to start working on your changes
  • Create a conda development environment with something like:
    • mamba env create -n cq-dev -f environment.yml
  • Activate the new conda environment:
    • conda activate cq-dev
  • If desired, install the master branch of cq-editor (Note; a release version may not be compatible with the master branch of cadquery):
    • mamba install -c cadquery -c conda-forge cq-editor=master Installing cq-editor adds another instance of cadquery which overrides the clone just added. Fix this by reinstalling cadquery using pip:
    • pip install -e .
  • Before making any changes verify that the current tests pass. Run pytest from the root of your cadquery clone, there should be no failures and the output will look similar to this:
    • ======= 215 passed, 57 warnings in 13.95s =======
  • Start with the tests! How should CadQuery behave after your changes? Make sure to add some tests to the test suite to ensure proper behavior
  • Make sure your tests have assertions checking all the expected results
  • Add a nice docstring to the test indicating what the test is doing; if there is too much to explain, consider splitting the test in two!
  • Go ahead and implement the changes
  • Add a nice docstring to the functions/methods/classes you implement describing what they do, what the expected parameters are and what it returns (if anything)
  • Update the documentation if there is any change to the public API
  • Consider adding an example to the documentation showing your cool new feature!
  • Make sure nothing is broken (run the complete test suite with pytest)
  • Run black from our fork to autoformat your code and make sure your code style complies with CadQuery's
  • Push the changes to your fork and open a pull-request upstream
  • Keep an eye on the automated feedback you will receive from the CI pipelines; if there is a test failing or some code is not properly formatted, you will be notified without human intervention
  • Be prepared for constructive feedback and criticism!
  • Be patient and respectful, remember that those reviewing your code are also working hard (sometimes reviewing changes is harder than implementing them!)

How to Report a Bug

When filing a bug report issue, please be sure to answer these questions:

  1. What version of the software are you running?
  2. What operating system are you running the software on?
  3. What are the steps to reproduce the bug?

How to Suggest a Feature or Enhancement

If you find yourself wishing for a feature that does not exist, you are probably not alone. There are bound to be others out there with similar needs. Open an issue which describes the feature you would like to see, why you need it, and how it should work.

cadquery's People

Contributors

a-g-d avatar adam-urbanczyk avatar bragostin avatar bweissinger avatar cactrot avatar dcowden avatar fragmuffin avatar gandalfdg avatar greyltc avatar hecatron avatar huskier avatar hyozd avatar innovationstech avatar jdegenstein avatar jmwright avatar jojain avatar justbuchanan avatar lorenzncode avatar marcus7070 avatar martinbudden avatar mgreminger avatar moeb avatar nopria avatar pauljurczak avatar pavpen avatar peque avatar revolter avatar rubenrubens avatar sethfischer avatar winksaville avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cadquery's Issues

show_object does not support option parameter

In QC1.2 show_object allows to pass an option parameter, i. e. to set the color and transparency of the shape (show_object(result, options={"rgba":(128, 255, 128, 0.0)})). Unfortunately, this parameter is not available in cadquery-occ and the following error occurs:

TypeError: () got an unexpected keyword argument 'options'

I know, there are likely still a lot of incompatibilities yet between QC1.2 and QC-occ. Will they be solved in the future such as a direct upgrade without much code adjustments would be possible?

Create wire multisweep

Issue by dcowden
Friday Apr 06, 2018 at 13:28 GMT
Originally opened as dcowden/cadquery#250


Jean-Paul has created a cool function I'd like to integrate:

I've build a variant of the sweep function that alow to make a profile along multiple wires. It may be of interest for you. Cheers.

def pgSweepFromListOfWires(self, path, makeSolid=True, isFrenet=False,
                           combine=True, clean=True):
    """
    Use list of un-extruded wires in the parent chain to create a swept solid.
    It differs from sweep that creates multiple solid
    This creates one solid with shape following list of wires

    Usage example :
    path = cq.Workplane("XZ").moveTo(10, 0).threePointArc((0, 10), (-10, 0))
    s = cq.Workplane("XY").moveTo(10, 0).circle(3).moveTo(-10, 0).circle(1)
    s = s.sweepFromListOfWires(path)

    :param path: A wire along which the pending wires will be swept
    :param boolean combine: True to combine the resulting solid with parent solids if found.
    :param boolean clean: call :py:meth:`clean` afterwards to have a clean shape
    :return: a CQ object with the resulting solid selected.
    """

    # returns a Solid (or a compound if there were multiple)
    r = self._sweepFromListOfWires(path.wire(), makeSolid, isFrenet)

    if combine:
        newS = self._combineWithBase(r)
    else:
        newS = self.newObject([r])
    if clean:
        newS = newS.clean()
    return newS


def _sweepFromListOfWires(self, path, makeSolid=True, isFrenet=False):
    """
    Makes a swept solid from an existing set of pending wires.

    :param wires: A list of wire along which the pending wires will be swept
    :param path: A wire along which the pending wires will be swept
    :return:a FreeCAD solid, suitable for boolean operations
    """

    # group wires together into faces based on which ones are inside the others
    # result is a list of lists
    wireSets = cq.sortWiresByBuildOrder(list(self.ctx.pendingWires),
                                        self.plane, [])

    # now all of the wires have been used to create an extrusion
    self.ctx.pendingWires = []

    toFuse = []
    section = []
    for ws in wireSets:
        for i in range(0, len(ws)):
            section.append(ws[i])

    # implementation
    outW = cq.Wire(section[0].wrapped)
    inW = section[1:]
    thisObj = cq.Solid.sweep(outW, inW, path.val(), makeSolid, isFrenet)
    toFuse.append(thisObj)

    return cq.Compound.makeCompound(toFuse)


# link the plugin into cadQuery
cq.Workplane.pgSweepFromListOfWires = pgSweepFromListOfWires
cq.Workplane._sweepFromListOfWires = _sweepFromListOfWires

----------------------------------------------
and here is an example

    path = cq.Workplane("XZ").moveTo(-2, 9).lineTo(0, 9). \
        threePointArc((9, 0), (0, -9)).lineTo(-2, -9)
    s = cq.Workplane("YZ").workplane(offset=-2).moveTo(0, 9).circle(4). \
        workplane(offset=2).circle(4). \
        moveTo(0, -18).circle(2).workplane(offset=-2).circle(2)
    s = s.pgSweepFromListOfWires(path, True, False)

I'm currently working with Jean-Paul to make a PR

Implement Feature Tree

Issue by dcowden
Sunday Dec 11, 2016 at 21:02 GMT
Originally opened as dcowden/cadquery#163


CQ 2.0 should have a feature tree, which stores operations and their results in a way that can be searched and referenced by later steps.

Each branch in the tree should have an id, and an associated operation.

The tree will be stored in the modelling context.

Implement Selection by Operation ID

Issue by dcowden
Sunday Dec 11, 2016 at 21:03 GMT
Originally opened as dcowden/cadquery#164


We need to be able to select geometry by the operationID that created it. This could require fingerprinting or other fancy tricks, since OCC does not provide an out-of-the-box way to identify which faces, edges, etc, were created by a given operation.

Shell Broken for Loft Objects

Issue by jmwright
Wednesday May 09, 2018 at 14:55 GMT
Originally opened as dcowden/cadquery#263


This issue began over on the Google Group here. I'm posting it here so we can keep track of it.

Shelling works fine with the cube example in the documentation.

result = cq.Workplane("XY").box(2, 2, 2) \
    .faces(">Z") \
    .shell(-0.2)

But no combination of face selections or shell thicknesses seems to be able to make this work.

import cadquery as cq
from Helpers import show

result = cq.Workplane("front").circle(1.5) \
.workplane(offset=3.0).rect(0.75, 0.5).loft(combine=True) \
.faces("-Z").shell(-0.1)

show(result)

I used the old show function in that example because it provides a stack trace, whereas CQGI's show_object function does not.

Here's the main error I get.

BRep_API: command not doneRunning the Python command 'CadQueryExecuteScript' failed:
Traceback (most recent call last):
  File "/home/jwright/.FreeCAD/Mod/cadquery_module/CQGui/Command.py", line 226, in Activated
    imp.load_source('temp_module', tempFile.name)
  File "/tmp/tmphTKlY4", line 6, in <module>
    .faces("-Z").shell(-0.1)
  File "/home/jwright/.FreeCAD/Mod/cadquery_module/Libs/cadquery/cadquery/cq.py", line 820, in shell
    s = solidRef.shell(self.objects, thickness)
  File "/home/jwright/.FreeCAD/Mod/cadquery_module/Libs/cadquery/cadquery/freecad_impl/shapes.py", line 1009, in shell
    return Shape.cast(self.wrapped.makeThickness(nativeFaces, thickness, tolerance))

BRep_API: command not done

suppress_stdout_stderr seems to suppress to much

Issue by gntech
Wednesday May 16, 2018 at 17:40 GMT
Originally opened as dcowden/cadquery#267


When exporting a STEP-file cadquery swallows some of the things written to stdout.

Consider the following script. Run from terminal with python.

import cadquery as cq

print("before creating model")

m = cq.Workplane("XY").box(10, 10, 10)

print("after creating model and before exporting model")

with open("testfile.step", "w") as f:
    cq.exporters.exportShape(m, "STEP", f)

print("after exporting model")

I would expect to get to get 3 print statements but I only get the last one after exporting model

I suspect that this has something to with the function suppress_stdout_stderr that is designed to suppress some messages from freecad regarding the step-export.

If I run the script like so instead I get all 3 print statments but also some messages from freecad regarding step creation. Using this form of the export I bypass the suppress_stdout_stderr()

import cadquery as cq

print("before creating model")

m = cq.Workplane("XY").box(10, 10, 10)

print("after creating model and before exporting model")

m.val().exportStep("out.step")

print("after exporting model")

My suggestion for how to fix this issue is to contact freecad upstream to see if we can get a clean step output from freecad to get rid of suppress_stdout_stderr. Because, seriously, the suppress_stdout_stderr() is not the ideal solution. :)

Threads API and Tutorial?

Issue by fragmuffin
Monday Sep 18, 2017 at 05:45 GMT
Originally opened as dcowden/cadquery#195


A tutorial on how to make a solid geometry thread would be very helpful.

I've (sort of) succeeded by using a few back doors in this gist (more information on implementation there)
However, it takes a very long time to generate (~15sec), and it's not perfect.

Any advice on the best way to generate a thread?
Perhaps make it into one of the example scripts.

Update README

Current README is not very informative - ideally it should explain what is the purpose of this fork of cadquery etc.

Getting Cadquery to work on Windows 10

Hey you guys.

I'm trying to figure out a way to use CadQuery on Windows 10. But as far as I can see, CadQuery only supports Python2.6, a version that is no longer possible to get using Anaconda.

Therefore I thought to use Bash on Ubuntu on Windows, but I cannot for the life of me get cadquery to find my Freecad.

Do you guys have any solutions to this issue? Or can I expect to use a newer version of Python in the near future?

Best regards.

Implement subtractive features

Issue by adam-urbanczyk
Monday May 21, 2018 at 10:28 GMT
Originally opened as dcowden/cadquery#269


For now only additive features are implemented. If we need to make a subtractive feature two additional calls are needed (combine=False and an explicit cut op)

obj = cq.Workplane('XY').circle(dia_out).circle(dia_in).extrude(tube_h)
groove= obj.faces('<Z').workplane(offset=-3.0).circle(dia_out).\
    circle(dia_out-groove_depth).extrude(groove_h,combine=False)

result = obj.cut(groove)

What would be nice:

result = cq.Workplane('XY').circle(dia_out).circle(dia_in).extrude(tube_h).\
    faces('<Z').workplane(offset=-3.0).circle(dia_out).\
    circle(dia_out-groove_depth).extrude(groove_h,subtract=True)

The idea of adding a sketchlet function into the 2D operations

Issue by huskier
Friday Nov 18, 2016 at 05:59 GMT
Originally opened as dcowden/cadquery#155


The idea is that we could store some useful sketches in data files( maybe a special formatted file), and we could re-use them. The sketchlet function could parse the special formatted files or just strings, and draw them.

With sketchlet function, we could significantly simplify the example "Panel With Various Connector Holes", and make the code elegant.

The following code is just a simple demo, no any parsing function. The current problem is that we could only add one complete wire into the sketchlet wire, otherwise Wire.assembleEdges complaint that "command not done". In the following code, I commented the second circle code.

`

def sketchlet(self):
    def makeSketchletWire(pnt):
        p0 = pnt
        p1 = p0.add(Vector(-23.5,0,0))
        e1 = Edge.makeCircle(1.6,p1)
        #p2 = p0.add(Vector(23.5,0,0))
        #e2 = Edge.makeCircle(1.6,p2)
        listOfEdges = []
        listOfEdges.append(e1)
        #listOfEdges.append(e2)
        sketchWire = Wire.assembleEdges(listOfEdges)
        sketchWire.forConstruction = False
        return sketchWire       
    return self.eachpoint(makeSketchletWire, useLocalCoordinates=True)

To call sketchlet:

result = cadquery.Workplane("XY").pushPoints( [ (25, 25),(50, 50)] ).sketchlet().extrude(50)
show(result)

`

create examples contrib repo

Issue by dcowden
Wednesday May 23, 2018 at 15:56 GMT
Originally opened as dcowden/cadquery#271


I agree. I'm going to create a new repo for examples, with a very open contribution policy. These will be community authored and reviewed.

I think Jeremy's suggested breakdown is perfect-- i'll move the ones listed as 'contributed examples' into the new repo.

This will provide a side benefit that the new rep will get its own README-- so i can put pictures of examples there, which are currently cluttering the main repo readme.

Suggested examples to move are:

Core Examples (stays in main CadQuery repo)
Ex001_Simple_Block.py
Ex002_Block_With_Bored_Center_Hole.py
Ex003_Pillow_Block_With_Counterbored_Holes.py
Ex004_Extruded_Cylindrical_Plate.py
Ex005_Extruded_Lines_and_Arcs.py
Ex006_Moving_the_Current_Working_Point.py
Ex007_Using_Point_Lists.py
Ex008_Polygon_Creation.py
Ex009_Polylines.py
Ex010_Defining_an_Edge_with_a_Spline.py
Ex011_Mirroring_Symmetric_Geometry.py
Ex012_Creating_Workplanes_on_Faces.py
Ex013_Locating_a_Workplane_on_a_Vertex.py
Ex014_Offset_Workplanes.py
Ex015_Rotated_Workplanes.py
Ex016_Using_Construction_Geometry.py
Ex017_Shelling_to_Create_Thin_Features.py
Ex018_Making_Lofts.py
Ex019_Counter_Sunk_Holes.py
Ex020_Rounding_Corners_with_Fillets.py
Ex021_Splitting_an_Object.py
Ex025_Revolution.py
Ex031_Sweep.py
Ex034_Sweep_Along_List_Of_Wires.py
Ex033_Shelled_Cube_Inside_Chamfer_With_Logical_Selector_Operators.py
Ex024_Using_FreeCAD_Solids_as_CQ_Objects.py
Ex026_Lego_Brick.py
Contributed Examples (Separate Repo)
Ex022_Classic_OCC_Bottle.py
Ex023_Parametric_Enclosure.py
Ex027_Remote_Enclosure.py
Ex028_Numpy.py
Ex029_Braille.py
Ex030_Panel_with_Various_Holes_for_Connector_Installation.py
Ex032_3D_Printer_Extruder_Support.py

Reliability of created solids, cleanup utilities?

Issue by fragmuffin
Monday Oct 02, 2017 at 11:57 GMT
Originally opened as dcowden/cadquery#199


I've spent the last week making threads in cadquery, and I feel I'm learning some hard truths about OCC's ability to reliably make a solid.

At the time of writing this, a FreeCAD forum discussion is still ongoing.

Problems include:

  • Faces aren't connected properly (require sewShape() to fix)
  • Face edges aren't connected (ie: not "closed")
  • Face is an Unorientable shape (I'm still trying to figure out what this means)
  • (and I'm expecting more as I continue testing)

Some can be fixed, some are "show stoppers" and I'm still learning how to fix the solid I've created so I can reliably use it for boolean operations.

A Solution?
Ideally cadquery's users shouldn't have to worry about the nuances of FreeCAD and OCC to make their creations.

Should cadquery host "cleanup" utilities to increase reliability of model creation?
Perhaps if reliability is paramount for a particular use then "cleanup" could be automatically performed after each operation, or for select operations, such as sweep, extrude, and other similar functions.

Root Cause of the Problem(s)
I'm still identifying causes, but the root cause is not cadquery, but OCC itself... ideally these "cleanup" algorithms would also link to a relevant bug raised in OCC so it may be promoting growth of the overall platform.

Personal Validation
Does the above sound right?... I feel like I'm going crazy, like perhaps I'm just using it incorrectly...
Have you experienced the same (or similar) problems I have?
If so, please list them here so we can attempt to address them all.

Implement Feature Tree

Issue by dcowden
Sunday Dec 11, 2016 at 21:02 GMT
Originally opened as dcowden/cadquery#163


CQ 2.0 should have a feature tree, which stores operations and their results in a way that can be searched and referenced by later steps.

Each branch in the tree should have an id, and an associated operation.

The tree will be stored in the modelling context.

Documentation missing

We need to create documentation for the PythonOCC version of cadquery / cadquery 2

Implement existing CQ operations as Operation Objects

Issue by dcowden
Sunday Dec 11, 2016 at 21:13 GMT
Originally opened as dcowden/cadquery#170


Each operation should be implemented as a new object.

Step 1: design the base operation interface, which much support an operationID

Step 2: implement the existing operations:
extrude
split
combine
rotate
transform
mirror
translate
shell
fillet
chamfer

question - organic modeling

I am new to CAD world, zero experience, but as a programmer, cadquery makes sense to me.

I understand the basic features of cadquery and CAD in general as the CSG operations, edge operations, chamfering.. etc
I was looking for a code way to create more organic models.
The result is not meant to be created in life, just displayed.
I learned also a term used in CAD that is "generative design".

Does cadquery allows me to achieve this kind of design?

Can I have things like:
blending between forms?
sweeps with multiple lines controls?

Merge changes from dcowden/cadquery

After sending #8, I realized that there are a lot of improvements and fixes in the main cadquery repo that haven't yet been merged into this one. While we could cherry-pick some of the most important changes, I think the best thing to do would be to merge dcowden/master into this repo (minus freecad_impl changes and any other freecad-related stuff) so we don't miss anything and preserve the git history. This is probably something to consider doing on a regular basis to avoid diverging too much.

If we do the merge, it will supersede #8 (which I've closed) as well as #1 and #6, in addition to adding many more improvements that have been contributed to the main repo since the pythonocc fork.

I'm happy to do the merge, but @adam-urbanczyk probably has better judgement on how to handle many of the merge conflicts (there are a lot - I have gotten about half way through them). Let me know what I can do to help and if you'd like me to send a PR with an attempt at the merge.

Workplane orientation breaks when "Locating workplane on a vertex".

Issue by sander76
Saturday Aug 11, 2018 at 10:15 GMT
Originally opened as dcowden/cadquery#289


Comparable to the example displayed at http://dcowden.github.io/cadquery/examples.html#locating-a-workplane-on-a-vertex I am trying to draw a cilinder on a cube with the center located at one of the cube's vertices. However when I do that the workplane changes orientation unexpectedly.

Two examples below.

  1. with cilinder on cube's face at the center
  2. identical to above, but now trying to put it at one of the vertices of the cube.

Example 1

import cadquery as cq

result = cq.Workplane("XY").rect(10.0,10.0).extrude(10)

# Draws a cilinder on the center of the XZ face of the cube
result = result.faces("<Y").workplane().circle(2.0).extrude(10)

show_object(result)

image

Example Two

import cadquery as cq

result = cq.Workplane("XY").rect(10.0,10.0).extrude(10)

# Should draw the cilinder on the same face as above but with its center placed
# at the lower XZ coordinate of that face
# But instead the workplane orientation changes too.
result = result.faces("<Y").vertices("<XZ").workplane().circle(2.0).extrude(10)

show_object(result)

image

CQGI: require explicit cadquery and show_object imports

Issue by dcowden
Monday May 21, 2018 at 21:09 GMT
Originally opened as dcowden/cadquery#270


after discussions with @fragmuffin and others, we'd like to change cqgi to require scripts to import show_object, debug, and cadquery itself.

The consensus was that there is just too much magic in scripts that use show_object when it appears out of nowhere.

This will require changing cqgi itself, as well as changing all of the examples to do this import. It probably also means that cqgi.show_object should be promoted to a real function, not injected during the ast phase.

@jmwright before i start these changes, do you agree? What is the impact on cqfm?

Sweep Buggy for Sharp Paths (polylines)

Issue by shivams
Saturday Jul 08, 2017 at 02:51 GMT
Originally opened as dcowden/cadquery#186


If the sweep path has sharp edges (e.g. sweep path is a poly-line), then sweep behaves in a buggy manner, and the object that is being swept doesn't turn correctly with the sweep path.

In the following example, you can see that the "polyline" sweep is very thin after the "turn".

import cadquery as cq
from Helpers import show

pts = [(0,1), (0,20), (10,25)]

poly_path = cq.Workplane("YZ").polyline(pts)
spline_path = cq.Workplane("YZ").spline(pts)

sweep_poly = cq.Workplane("XY").circle(0.3).sweep(poly_path)
sweep_spline = cq.Workplane("XY").transformed(offset=(0, -3, )).circle(0.3).sweep(spline_path)

show(sweep_poly, (204, 100, 50, 0.2))
show(sweep_spline, (50, 204, 80, 0.2))

sweep-bug

toLocalCoords for shapes transforms in the wrong direction

Issue by fredizzimo
Wednesday Jul 04, 2018 at 18:56 GMT
Originally opened as dcowden/cadquery#284


Consider the following example

import cadquery as cq

box = cq.Workplane("XY").box(50, 10, 10, centered=[False, False, False])
vertex = box.vertices(">X and >Y and >Z").first().val()
workplane = cq.Workplane("XY").center(5, 10)
vector = cq.Vector(50, 10, 10)
print("The original vertex is",
    vertex.X,
    vertex.Y,
    vertex.Z)
print("The converted vertex is",
    workplane.plane.toLocalCoords(vertex).X,
    workplane.plane.toLocalCoords(vertex).Y,
    workplane.plane.toLocalCoords(vertex).Z)
print("The converterd vector is", workplane.plane.toLocalCoords(vector))

which outputs

The original vertex is 50.0 10.0 10.0
The converted vertex is 55.0 20.0 10.0
The converterd vector is Vector (45.0, 0.0, 10.0)

As you can see the vertex is moved in the wrong direction, while the vector version works correctly.

The bug seems to be pretty obvious here

    def toLocalCoords(self, obj):
        if isinstance(obj, Vector):
            return Vector(self.fG.multiply(obj.wrapped))
        elif isinstance(obj, cadquery.Shape):
            return obj.transformShape(self.rG)
        else:
            raise ValueError(
                "Don't know how to convert type {} to local coordinates".format(
                    type(obj))) 

As you can see it's using the wrong transformation matrix (self.rG) for the shape, while self.fG is used for vectors.

Create a compelling, online-only CQ 2.0 experience

When we moved cadquery from to its new home, we lost a lot of stars. But the good news is that we have more to offer-- we just have to get people excited.

I believe the most important thing we can do is to provide an online (no-install) solution, which lets people try cq via a hosted GUI. This GUI should allow people to try it with no work, play with samples, and (ideally) pull in all of the libraries in the eco-system ( cqparts, cadquery-contrib).

The result should be fire-up-your browser, and run any of the samples in cadquery-contrib, or cqparts.

I believe the closest we had to his is tryQA, based on jupyter. It was cool, but it was too slow.

I believe the 'right' direction long-term is to build a javascript-based frontend and a server backend, and then deploy that on a hosted platform. With these two components, we can then make native apps for all the important platforms using electron/nativify, while using the same GUI code to support hosted installations AND native. We could even have a mobile app, and the ability for others to easily host.

I'm not long on time, but i'm willing to contribute capital. If we find a solution that works, but just needs a small amount of $ per month for servers, i will do that.

travis-ci doesn't automatically push builds to conda

Not sure if this is intentional, but I noticed that the linux builds on anaconda.org are ~3 months old, while the builds for Windows reflect the latest successful build on the master branch. Appveyor automatically pushes a build for each passing commit, while travis-ci only seems to push a build for "tagged" commits.

The latest travis-ci build log shows this message: "Skipping a deployment with the script provider because this is not a tagged commit". Maybe there's a setting for pushing builds on all commits, rather than just ones with tags?

Conda download page: https://anaconda.org/CadQuery/cadquery-occ/files.

Comment in Patreon Update About PyOCCT Support

tl;dr Kurt makes a quick case for using PyOCCT in CadQuery instead of PythonOCC in this post ("cadquery" section).

There's also a "PyOCCT" section a ways below that that gives a little more background.

I'm not pushing for changing course at this point, but I've had an email conversation with Kurt about his work and about CadQuery. He really seems to be tied in with what's going on in the open source science and engineering software world. I appreciate him adding CadQuery to his packaging wishlist and for giving thoughtful feedback. I think it's good to have all information and viewpoints in front of us, even if we don't do anything different. Depending on the situation, maybe it doesn't have to be an either-or thing anyway? I'm not sure how different PythonOCC and PyOCCT are in implementation.

Implement Parametric 2d sketching

Issue by dcowden
Sunday Dec 11, 2016 at 21:59 GMT
Originally opened as dcowden/cadquery#172


Currently, sketching is not parametric. Sketches explicitly define geometry, rather than the design intent.

For example, instead of defining a square as four lines between points 0,10, 10,10, 10,0, and 0,10, we should define four lines with these constraints:
each of the ends co-incident
length of each line equal
one line equal to 10
one point co-incident with the origin

To do this, we will need to integrate a constraint solver.

CQGI: displaying cqparts components

Issue by fragmuffin
Saturday May 26, 2018 at 13:28 GMT
Originally opened as dcowden/cadquery#273


displaying objects created in cqparts using cqparts.cqgi at the moment involves extracting the cadquery.Workplane instance from the Component, and passing it to show_object.

from cqparts_misc.basic.primatives import Cube
cube = Cube(size=10)
show_object(cube.local_obj)

Problem
Displaying a cqparts.Component with editable parameters currently requires the workaround described in cqparts/cqparts#95 (comment)

from cqparts_misc.basic.primatives import Cube
g_size = 10
cube = Cube(size=g_size)
show_object(cube.local_obj)

Solution?
The display of a cqparts component would be much more intuitive with cadquery.cqgi if the parameters to be modified are picked up from the cqparts.Component instance itself.

The idea of adding a sketchlet function into the 2D operations

Issue by huskier
Friday Nov 18, 2016 at 05:59 GMT
Originally opened as dcowden/cadquery#155


The idea is that we could store some useful sketches in data files( maybe a special formatted file), and we could re-use them. The sketchlet function could parse the special formatted files or just strings, and draw them.

With sketchlet function, we could significantly simplify the example "Panel With Various Connector Holes", and make the code elegant.

The following code is just a simple demo, no any parsing function. The current problem is that we could only add one complete wire into the sketchlet wire, otherwise Wire.assembleEdges complaint that "command not done". In the following code, I commented the second circle code.

`

def sketchlet(self):
    def makeSketchletWire(pnt):
        p0 = pnt
        p1 = p0.add(Vector(-23.5,0,0))
        e1 = Edge.makeCircle(1.6,p1)
        #p2 = p0.add(Vector(23.5,0,0))
        #e2 = Edge.makeCircle(1.6,p2)
        listOfEdges = []
        listOfEdges.append(e1)
        #listOfEdges.append(e2)
        sketchWire = Wire.assembleEdges(listOfEdges)
        sketchWire.forConstruction = False
        return sketchWire       
    return self.eachpoint(makeSketchletWire, useLocalCoordinates=True)

To call sketchlet:

result = cadquery.Workplane("XY").pushPoints( [ (25, 25),(50, 50)] ).sketchlet().extrude(50)
show(result)

`

Implement Selection by Operation ID

Issue by dcowden
Sunday Dec 11, 2016 at 21:03 GMT
Originally opened as dcowden/cadquery#164


We need to be able to select geometry by the operationID that created it. This could require fingerprinting or other fancy tricks, since OCC does not provide an out-of-the-box way to identify which faces, edges, etc, were created by a given operation.

object_show does not work

Issue by totyped
Monday Aug 13, 2018 at 11:24 GMT
Originally opened as dcowden/cadquery#290


On Ubuntu, jupyter-notebook, python 2

When I type

import cadquery as cq
result = cq.Workplane("front").box(2.0, 2.0, 0.5)
show_object(result)

I get the following error:
NameError Traceback (most recent call last)
in ()
1 result = cq.Workplane("front").box(2.0, 2.0, 0.5)
----> 2 show_object(result)

NameError: name 'show_object' is not defined

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.