Command-line interface to PartCAD
Project description
PartCAD
PartCAD is the first package manager for CAD models,
and a Python package to consume these packages in CAD scripts (cadquery
and build123d
).
It brings the same power to CAD scripting
as pip to Python,
npm to JavaScript,
maven to Java etc.
Though it aims to achieve the integrity and security properties of
bazel which makes PartCAD quite distinct from pip
and npm
.
PartCAD allows to maintain information about mechanical parts, how they come together to form larger assemblies, and to reuse the same parts in multiple assemblies, multiple projects. The implementation of parts can change over time (e.g. optimize or migrate to CadQuery from STEP) without the need to update all of the consumers.
- Installation
- Browse models published to PartCAD
- Consume PartCAD models
- Create PartCAD models
- Export
- Security
- Tools for mechanical engineering
- History
Installation
The recommended method to install PartCAD for most users is:
pip install partcad-cli
For contributors:
git clone https://github.com/openvmp/partcad.git
cd partcad
python3 -m pip install -e ./partcad
python3 -m pip install -e ./partcad-cli
PartCAD works best when conda is installed.
Moreover, on Windows it is recommended to use PartCAD from within a conda
environment.
Browse models published to PartCAD
To browse the public PartCAD repository from the command line:
$ pc init # to initialize new PartCAD package in the current folder
$ pc list # to list all available packages
$ pc list-parts -r # to list all parts in all available packages
$ pc list-assemblies -r # to list all assemblies in all available packages
The web UI to browse the public PartCAD repository is not yet published.
Consume PartCAD models
As PartCAD has no implicit dependencies built in, the current directory needs to be initialized as a PartCAD package and a dependency on the public PartCAD repository needs to be registered.
# Initialize new PartCAD package in the current folder
$ pc init
Alternatively, manually create partcad.yaml
with the following content:
# partcad.yaml
import:
partcad-index: # Standard public PartCAD repository (needs to be explicitly referenced to be used)
type: git
url: https://github.com/openvmp/partcad-index.git
After this, PartCAD python module can be used to retrieve any model. The exact way to do this depends on the CAD framework used in your project:
# CadQuery
import cadquery as cq
import partcad as pc
part = pc.get_part(
# Part name
"fastener/screw-buttonhead",
# Package name
"standard-metric-cqwarehouse",
).get_cadquery()
...
show_object(part)
|
# build123d
import build123d as b3d
import partcad as pc
part = pc.get_part(
# Part name
"fastener/screw-buttonhead",
# Package name
"standard-metric-cqwarehouse",
).get_build123d()
...
show_object(part)
|
Create PartCAD models
This frameworks allows to create large models and scenes, one part at a time, while having parts and assemblies often maintained by third parties.
Parts
PartCAD allows to define parts using any of the following methods:
Method | Example | Result |
---|---|---|
CadQuery |
# partcad.yaml
parts:
cube:
type: cadquery
Place the CadQuery script in "cube.py" |
|
build123d |
# partcad.yaml
parts:
cube:
type: build123d
Place the build123d script in "cube.py" |
|
STEP |
# partcad.yaml
parts:
bolt:
type: step
Store the model in "bolt.step" |
|
STL |
# partcad.yaml
parts:
cube:
type: stl
Store the model in "cube.stl" |
|
3MF |
# partcad.yaml
parts:
cube:
type: 3mf
Store the model in "cube.3mf" |
|
OpenSCAD |
# partcad.yaml
parts:
cube:
type: scad
Store the model in "cube.scad" |
Other methods to define parts are coming in soon (e.g. SCAD).
Assemblies
Assemblies are defined as parametrized instructions how to put parts and other assemblies together.
Currently, PartCAD allows to define parts only using ASSY (Assembly YAML):
Example | Result |
---|---|
# partcad.yaml
assemblies:
logo:
type: assy
# logo.assy
links:
- part: bone
package: example_part_cadquery_logo
location: [[0,0,0], [0,0,1], 0]
- part: bone
package: example_part_cadquery_logo
location: [[0,0,-2.5], [0,0,1], -90]
- part: head_half
package: example_part_cadquery_logo
name: head_half_1
location: [[0,0,27.5], [0,0,1], 0]
- part: head_half
package: example_part_cadquery_logo
name: head_half_2
location: [[0,0,25], [0,0,1], -90]
- part: bolt
package: example_part_step
location: [[0,0,7.5], [0,0,1], 0]
|
|
Packages
Each project that produces or consumes PartCAD models is a separate PartCAD package. Each package may export parts, assemblies and scenes. Each package may import parts, assemblies and scenes from its dependencies (other PartCAD packages).
Method | Example |
---|---|
Local files (present in your own source code repository) |
import: other_directory type: local path: ../../other |
External GIT repository (HTTPS, SSH) |
import: other_directory type: git url: https://github.com/openvmp/partcad |
External tar ball (HTTPS) |
import: other_directory type: tar url: https://github.com/openv...090ca.tar.gz |
The full syntax is below:
import:
<package-name>:
desc: <(optional) textual description>
type: <git|tar|local>
path: <(local only) relative-path>
url: <(git|tar only) url-of-the-package>
relPath: <(git|tar only) relative-path-within-the-repository>
web: <(optional) package or maintainer's url>
poc: <(optional) maintainer's email>
pythonVersion: <(optional) python version for sandboxing if applicable>
Troubleshooting
At the moment, the best way to troubleshoot PartCAD is to use VS Code with OCP CAD Viewer
.
Any part or assembly can be displayed in OCP CAD Viewer
by running pc show <part> [<package>]
or pc show -a <assembly> [<package>]
in a terminal view.
# Create a temporary folder
mkdir /tmp/test_show && cd /tmp/test_show
# Initialize a package with the default dependency on public PartCAD repository
pc init
# Show one of available parts in 'OCP CAD Viewer'
pc show fastener/screw-buttonhead standard-metric-cqwarehouse
Render your project
Use pc render
to render PartCAD parts and assemblies
in the current package (the current directory).
git clone https://github.com/openvmp/partcad-cqwarehouse.git
cd partcad-cqwarehouse
pc render
Publishing
It is very simple to publish your package to the public PartCAD repository.
First, you need to publish your own package which defines the models you want to publish. Then create a pull request in the public PartCAD repo to add a reference to your package.
Export
Images
Individual parts, assemblies and scenes can be rendered and exported into the following formats:
Expect more image formats to be added to the list of supported export formats in the future.
Purchasing / Bill of materials
The bill of materials for each assembly can be produced using the following formats:
Security
PartCAD is capable of rendering scripted parts (CadQuery and build123d use Python) in sandboxed environments.
While at the moment it is only useful from dependency management perspective, in the future PartCAD aims to achieve security isolation of the sandboxed environments. That will fundamentally change the security implications of using scripted models shared online.
Tools for mechanical engineering
Here is an overview of the open source tools to maintain mechanical projects. It shows where does this framework fit in the modern mechanical development workflows.
flowchart TB
subgraph repo["Your project's GIT repository"]
subgraph custom_repo["Custom parts"]
direction TB
custom_part_internet["A STEP file\ndownloaded from Internet\nor the vendor site"]
custom_part_cad["A part exported as a solid\nfrom a CAD tool not\nsuitable for collaboration"]
custom_part_cq["An individual reusable part\nmaintained as a script\nunder a version control system"]
custom_part_os["Another reusable part\nmaintained as a script\nunder a version control system"]
end
model["Your project's model defined\nas ASSY or Python code\nfor version control\nand collaboration"]
subgraph scenes["Scenes"]
test1["Capability 1\ntest scene"]
test2["Capability 2\ntest scene"]
end
end
subgraph external_repos["Third-party GIT repositories,\nCDN-hosted files or OCCI servers"]
subgraph external_repo["Repository of standard\nor popular parts"]
end
end
subgraph external_tools["External tools"]
freecad["FreeCAD"]
cadquery["CadQuery / build123d"]
openscad["OpenSCAD"]
gazebo["Gazebo"]
partcad["PartCAD library"]
style partcad fill:#c00
end
custom_part_cad <--- |Individual\ncontributor|freecad
custom_part_cq <--- |Part design\nworkflow| cadquery
custom_part_os <--- |Part design\nworkflow| openscad
external_repo ---> |Import| model
custom_repo ---> |Import| model
model -.-> |Import| test1
model -.-> |Import| test2
custom_repo <-. Maintained\nusing\nPartCAD\nconvention .- partcad
external_repo <-. Maintained\nusing\nPartCAD\nconvention .- partcad
model <--- partcad
test1 <--- partcad
test2 <--- partcad
test1 -.-> |Export| gazebo
test2 -.-> |Export| gazebo
History
PartCAD is the evolution of the modelling framework that was once used internally in OpenVMP. It is now being maintained separately as a generic tool.
The motivation behind this framework is to build a packaging and dependency tracking layer on top of both CadQuery/build123d and traditional CAD tools to enable version control and other features required for effective collaboration.
This framework currently uses build123d and, thus, OpenCASCADE under the hood. However this may change in the future, if the python C bindings for OpenCASCADE remain a blocker for unlocking multithreaded performance.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file partcad-cli-0.3.62.tar.gz
.
File metadata
- Download URL: partcad-cli-0.3.62.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c79c0884067126ed048039ec9f943390780c41b5c94ac75b64b929e930fd2c88 |
|
MD5 | 5dde23fe5a2763c473ecf3d867ecea00 |
|
BLAKE2b-256 | a842744cb4ebddf6abf30729d7e3e004380b425e071fc1a518780ab9af3d6f6b |
Provenance
File details
Details for the file partcad_cli-0.3.62-py3-none-any.whl
.
File metadata
- Download URL: partcad_cli-0.3.62-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b0adde5fcdf59204220ab7e46dbb9dc1f012df1dc15854b8afba491f65f4816 |
|
MD5 | b5c526af93ccaefef2f222f03fd3c457 |
|
BLAKE2b-256 | 0087c7ea3b2a2d39f72b9ac81b7fcca0bf9ee4c32d862b7afa244cc956658857 |