PartCAD Documentation
repository·devel·Indexed 19 days ago
https://github.com/partcad/partcadPartCAD is a next-generation computer-aided design (CAD) system for managing the lifecycle of manufacturable physical products. It functions as a hardware package manager that integrates requirements, detailed designs, and implementation artifacts into deterministic specifications. The system includes a CLI (pc), support for various representations (build123d, cadquery, openscad, sdf), and vendor-neutral AI agent skills for automating part, assembly, and sketch generation.
What's inside PartCAD
- PartCAD is a package manager for CAD models and a framework for managing assemblies. It is designed to complement Git, providing the capabilities necessary to substitute commercial Product Lifecycle Management (PLM) tools. It manages information regarding mechanical parts and their relationships within larger assemblies, allowing for part reuse across multiple assemblies and projects while leveraging Git for versioning and collaboration.
What is PartCAD?
develPartCAD is a standard for documenting manufacturable physical products. Unlike traditional CAD tools used for drawing, PartCAD focuses on creating a clear and deterministic specification of a product. It acts as a package manager for hardware, allowing users to maintain product information, requirements, and implementation details (mechanical, PCB, and software) in a modular and reusable way. This enables building upon not just previous CAD files, but also previous manufacturing processes.Identify the correct PartCAD package for your needs
develPartCAD is distributed across several packages depending on your use case:
partcad: The core Python module for programmatic instantiation of parts, assemblies, and scenes.partcad-cli: The package containing PartCAD command-line tools.partcad-dev: Standalone PartCAD bundles.
Understand package identity and location
develIn PartCAD, a package is addressed by its location (the path at which it is loaded, derived from its parent). For example, a package in the
gobildasubfolder of//vendoris addressed as//vendor/gobilda.namefield: This declares the package's identity (the path it expects to be seen at). This only takes effect when the package is loaded as the root.- Vendoring: When you copy (vendor) a package into your own tree, it is loaded at its new location, not its declared
name. PartCAD automatically redirects any internal references the package makes to its ownnameto its new location, ensuring the vendored copy uses itself rather than pulling in the original upstream version.
Use Interfaces to connect parts and assemblies
develInterfaces define how parts and assemblies connect.
- Implementation: A part can implement one or more interfaces (and multiple instances of each).
- Inheritance: Interfaces can hierarchically inherit ports and properties.
- Mating: Compatibility information (mating) can be maintained within interfaces.
- Automatic Placement: If interfaces and mating are defined, PartCAD can often place parts and assemblies without user-provided coordinates.
Use the partcad Python module for CAD automation
develThe
partcadPython module serves as the core engine for programmatic CAD management. You can use it in Python scripts to:- Instantiate parts, assemblies, and scenes implemented as PartCAD packages.
- Integrate with [CadQuery] and [build123d] scripts.
- Power custom web, mobile, or desktop applications that render CAD models.
- Generate Bills of Materials (BoMs) and assembly instructions.
Note: If you need command-line tools, use the
partcad-clipackage instead of this module.Configure port matching and orientation
develPorts are matched based on their logical center coordinates and their direction (orientation).
Matching Rules:
- For direct connections (e.g., male/female connectors) without offsets, coordinates should match and directions should be opposite (rotated 180 degrees around
[1, 1, 0]). - Convention: Use the Z-axis (blue) as the main direction.
- Male ports: Z-axis points outwards.
- Female ports: Z-axis points inwards.
Interchangeable Ports: To allow multiple ports to connect to any other (like NEMA-17 mounting holes), orient the ports in a circular direction. For example, set the X-axis (red) to point to the next port clockwise using the right-hand rule.
- For direct connections (e.g., male/female connectors) without offsets, coordinates should match and directions should be opposite (rotated 180 degrees around
Define 3D parts by sweeping 2D sketches
develThe sweep operation in PartCAD allows you to create complex 3D geometries by taking a 2D sketch (such as a circle, a DXF file, or a custom clock sketch) and sweeping it along a path to produce a 3D part.
Common use cases demonstrated in this example include:
- clock: Sweeping a clock sketch to create a 3D clock.
- dxf: Sweeping a DXF sketch to create a 3D part.
- pipe: Sweeping a circle sketch to create a pipe.
Access configuration parameters in providers using get_from_config()
develTo avoid hardcoding sensitive or reusable values (like API keys or URLs) multiple times, you can reference parameters dynamically within the
providerssection of your configuration. Use theget_from_config()function within a parameter definition to pull values from theparameterssection of~/.partcad/config.yaml.# ~/.partcad/config.yaml parameters: my_api_url: "https://api.example.com" providers: my_provider: type: store parameters: url: type: string default: {{ get_from_config() }}Implement supply chain operations using providers
develPartCAD uses
providersto implement supply chain operations. Common provider types include:- store: Used to buy off-the-shelf parts by SKU.
- manufacturer: Used to manufacture parts following specific instructions.
To list existing providers in the PartCAD public repository, use the
pc list providerscommand with the-rflag pointing to the commerce service.pc init pc list providers -r //pub/svc/commerceScripting conventions for Python-based CAD
develWhen authoring scripts for
build123d,cadquery, orsdf, follow these conventions:- Imports: Import everything you use, including
mathand the specific CAD library. - Exposing the part: Call
show_object(<result>)to make the part visible in the renderer. - Exports: Do not use
exportstatements. - CadQuery specific: Avoid using
tetrahedronorhexahedronprimitives.
OpenSCAD Convention:
- Provide a complete script defining all functions and constants.
- Do not use external modules.
- Do not use
exportstatements.
- Imports: Import everything you use, including
Author a PartCAD ASSY file
develAn
.assyfile is a YAML tree of nodes under alinks:key. You must choose exactly one placement method for each part node:location,connectPorts, orconnect.Container Node
Used for the top level or grouping nodes.
name: <optional> description: <the description> location: <optional [[x,y,z], [ax,ay,az], angle_deg]> links: - <node>Part Node Placement Methods
1. Explicit Placement (Translation + Rotation): Use this when parts do not have defined ports or interfaces.
- part: <part-path> name: <instance-name> location: [[x, y, z], [ax, ay, az], angle_deg]2. Connect by Ports (No interface mating): Use this to connect specific ports between instances.
- part: <part-path> connectPorts: with: <this part's port> name: <target instance name> to: <target port>3. Connect by Interfaces (Universal mating): Use this for parts that define compatible interfaces.
- part: <part-path> connect: with: <this part's interface> name: <target instance name> to: <target interface>Note:
withnames the interface/port on the part being added;tonames it on the part already in the assembly. Use millimeters and degrees.Sub-assembly Node
Identical to a part node, but uses the
assembly:key instead ofpart:and can contain its own nestedlinks:.# Example Part Node with explicit placement - part: //package:part_name name: my_instance location: [[10, 0, 0], [0, 0, 1], 90] # Example Part Node with port connection - part: //package:part_name connectPorts: with: port_a name: existing_part_instance to: port_b