Package: partcad-cli
PartCADPartCAD is the first package manager for CAD models,
and a Python package to consume these packages in CAD scripts (cadqueryandbuild123d).
It brings the same power to CAD scripting
aspipto Python,npmto JavaScript,mavento Java etc.
Though it aims to achieve the integrity and security properties ofbazelwhich makes PartCAD quite distinct frompipandnpm.Join our Discord channel!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 toCadQueryfromSTEP) without the need to update
all of the consumers.
Find more documentationhere.InstallationBrowse models published to PartCADConsume PartCAD modelsPublish PartCAD modelsPartsAssembliesPackagesTroubleshootingRender your projectPublishingExport PartCAD modelsImagesPurchasing / Bill of materialsSecurityTools for mechanical engineeringHistoryInstallationThe recommended method to install PartCAD for most users is:pipinstallpartcad-cliFor contributors:gitclonehttps://github.com/openvmp/partcad.gitcdpartcad
python3-mpipinstall-e./partcad
python3-mpipinstall-e./partcad-cliPartCAD works best whencondais installed.
Moreover, on Windows it is recommended to use PartCAD from within acondaenvironment.Browse models published to PartCADTo browse the public PartCAD repository from the command line:$pcinit# to initialize new PartCAD package in the current folder$pclist# to list all available packages$pclist-parts-r# to list all parts in all available packages$pclist-assemblies-r# to list all assemblies in all available packagesThe web UI to browse the public PartCAD repository is not yet published.Consume PartCAD modelsAs 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$pcinitAlternatively, manually createpartcad.yamlwith the following content:# partcad.yamlimport:# Public PartCAD repository (reference it explicitly if required)partcad-index:type:giturl:https://github.com/openvmp/partcad-index.gitAfter this, all models in the public PartCAD repository are ready to be consumed.
If you want to use these models in a CAD Design GUI (like FreeCAD or its paid
alternatives), the best way to do it at the moment (before PartCAD plugins for
these apps are available) is to export the models to STEP or 3MF files and,
then, import them into the CAD Design GUI of your choice.# Some "export to a file" examples:$pcrender-p-tstl<part>[<package>]$pcrender-p-tstep-a<assembly>[<package>]If you want to use these models in a CAD-as-code framework, find below the
example how to do it in CadQuery. Examples for other frameworks arealso available.# Example: Consume PartCAD models in CadQueryimportcadqueryascqimportpartcadaspc...part=pc.get_part_cadquery(# Part name"fastener/hexhead-iso4014",# Package name"pc-std-metric-cqwarehouse",)...show_object(part)Publish PartCAD modelsEach project that produces or consumes PartCAD models is a separate PartCAD package.
Each package may export parts, assemblies and scenes.
A package is defined bypartcad.yaml.PartsPartCAD allows to define parts using any of the following methods:MethodExampleResultPython scripts:CadQuery,build123dPlace the following in "partcad.yaml":parts:src/cylinder:type: cadquery# type: build123dPlace the script in "src/cylinder.py".CAD files:STEP,STL,3MFPlace the following in "partcad.yaml":parts:screw:type: step# type: stl# type: 3mfStore the model in "screw.step", "screw.stl" or "screw.3mf" respectively.CAD scripts:OpenSCADPlace the following in "partcad.yaml":parts:cube:type: scadStore the model in "cube.scad".Other methods to define parts are coming soon (e.g.SDF).AssembliesAssemblies are defined as parametrized instructions how to put parts and other
assemblies together.Currently, PartCAD allows to define parts only using ASSY (Assembly YAML):ExampleResult# 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]PackagesPartCAD packages may import parts, assemblies and scenes from its dependencies
(other PartCAD packages). There are several methods to import other packages:MethodExampleLocal files(present inyour ownsource coderepository)import:other_directorytype: localpath: ../../otherGITrepository(HTTPS, SSH)import:other_directorytype: giturl:https://github.com/openvmp/partcadHosted tar ball(HTTPS)import:other_directorytype: tarurl:https://github.com/openv...090ca.tar.gzThe 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>revision:<(git only) the exact revision to import>web:<(optional) package or maintainer's url>poc:<(optional) maintainer's email>pythonVersion:<(optional) python version for sandboxing if applicable>TroubleshootingAt the moment, the best way to troubleshoot PartCAD is to use VS Code withOCP CAD Viewer.
Any part or assembly can be displayed inOCP CAD Viewerby runningpc show <part> [<package>]orpc show -a <assembly> [<package>]in a terminal view.# Create a temporary foldermkdir/tmp/test_show&&cd/tmp/test_show# Initialize a package with the default dependency on public PartCAD repositorypcinit# Show the part in 'OCP CAD Viewer'pcshowfastener/hexhead-iso4014pc-std-metric-cqwarehouseRender your projectUsepc renderto render PartCAD parts and assemblies
in the current package (the current directory).gitclonehttps://github.com/openvmp/partcad-cqwarehouse.gitcdpartcad-cqwarehouse
pcrenderSeean examplehow to configure package's
rendering settings.PublishingIt's very simple to publish your package to the public PartCAD repository.
First, publish your package (e.g. as a repo on GitHub).
Then create a pull request inthe public PartCAD repoto add a reference to your package.Export PartCAD modelsImagesIndividual parts, assemblies and scenes can be rendered and exported into the
following formats:SVGPNGSTEPSTL3MFThreeJSOBJ# Some "export to a file" examples:$pcrender-p-tstl<part>[<package>]$pcrender-p-tstep-a<assembly>[<package>]Expect more image formats to be added to the list of supported export formats in the future.Purchasing / Bill of materialsThe bill of materials for each assembly can be produced using the following
formats:CSV(not yet / in progress)Markdown(not yet / in progress)SecurityPartCAD is capable of rendering scripted parts
(CadQueryandbuild123duse 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 engineeringHere 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| gazeboHistoryPartCAD is the evolution of the modelling framework that was once used
internally inOpenVMP.
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 bothCadQuery/build123dand traditional CAD tools to
enable version control and other features required for effective collaboration.This framework currently usesbuild123dand, thus,OpenCASCADEunder the hood.
However this may change in the future.