Probably an advanced topic
Show you how to make your own python package that can be called in your CadQuery scripts.
- Setuptools - https://setuptools.pypa.io/en/latest/
- cqMore - https://github.com/JustinSDK/cqMore
pip install git+https://github.com/JustinSDK/cqMore
from cqmore import Workplane
result = (Workplane()
.rect(10, 10)
.makePolygon(((-2, -2), (2, -2), (2, 2), (-2, 2)))
.extrude(1)
)
show_object(part)
- cadqueryhelper - https://github.com/medicationforall/cadqueryhelper
pip install git+https://github.com/medicationforall/cadqueryhelper
from cadqueryhelper import shape
part = shape.arrow(length=10, inner_length=5, width=5, width_outset=2, height=3)
show_object(part)
- Create a directory cqlib
- Create a src directory
- Create project directory cqlib
- Create cylinder.py with the following contents:
import cadquery as cq def cylinder(radius = 2.5, height = 5 ): work = cq.Workplane().cylinder(height, radius) return work
- Make __init__.py with the following:
from .cylinder import cylinder
- Create cylinder.py with the following contents:
- Create project directory cqlib
- create pyproject.toml with the following contents:
[build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] name = "cqlib" version = "0.0.1" authors = [ { name="James Adams", email="inklink28@gmail.com" }, ] description = "Demo CadQuery library" readme = "README.md" license = { file="LICENSE" } requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ] dependencies = [ "cadquery==2.2.0b0", 'cqmore @ git+https://github.com/JustinSDK/cqMore' ] [project.urls] "Homepage" = "https://github.com/medicationforall/cqlib" "Bug Tracker" = "https://github.com/medicationforall/cqlib/issues"
- Create a src directory
- Create README.MD file
- create LICENSE file
- Initialize the repo
git init
- Stage changes
git add .
- Commit changes
git commit -m "initial commit"
- Install the package locally
pip install ./
- Run your package in CQ-Editor
from cqlib import cylinder result = cylinder() show_object(cylinder)