partcad-cli 0.4.2__tar.gz → 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. partcad-cli-0.5.1/PKG-INFO +132 -0
  2. partcad-cli-0.5.1/README.md +111 -0
  3. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/pyproject.toml +1 -1
  4. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/requirements.txt +1 -1
  5. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/__init__.py +1 -1
  6. partcad-cli-0.5.1/src/partcad_cli/cli.py +153 -0
  7. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/cli_add.py +4 -4
  8. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/cli_info.py +32 -22
  9. partcad-cli-0.4.2/src/partcad_cli/cli_show.py → partcad-cli-0.5.1/src/partcad_cli/cli_inspect.py +35 -27
  10. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/cli_install.py +4 -0
  11. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/cli_list.py +53 -25
  12. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/cli_render.py +9 -6
  13. partcad-cli-0.5.1/src/partcad_cli/cli_status.py +86 -0
  14. partcad-cli-0.5.1/src/partcad_cli.egg-info/PKG-INFO +132 -0
  15. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli.egg-info/SOURCES.txt +2 -1
  16. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli.egg-info/requires.txt +1 -1
  17. partcad-cli-0.4.2/PKG-INFO +0 -459
  18. partcad-cli-0.4.2/README.md +0 -438
  19. partcad-cli-0.4.2/src/partcad_cli/cli.py +0 -141
  20. partcad-cli-0.4.2/src/partcad_cli.egg-info/PKG-INFO +0 -459
  21. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/setup.cfg +0 -0
  22. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli/cli_init.py +0 -0
  23. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli.egg-info/dependency_links.txt +0 -0
  24. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli.egg-info/entry_points.txt +0 -0
  25. {partcad-cli-0.4.2 → partcad-cli-0.5.1}/src/partcad_cli.egg-info/top_level.txt +0 -0
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.1
2
+ Name: partcad-cli
3
+ Version: 0.5.1
4
+ Summary: Command-line interface to PartCAD
5
+ Author-email: Roman Kuzmenko <openvmp@proton.me>
6
+ Maintainer-email: Roman Kuzmenko <openvmp@proton.me>
7
+ Project-URL: Homepage, https://github.com/openvmp/partcad
8
+ Project-URL: Issues, https://github.com/openvmp/partcad/issues
9
+ Keywords: cadquery,build123d,cad,design,openscad,step,stl
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: partcad==0.5.1
16
+ Requires-Dist: pycairo
17
+ Requires-Dist: renderlab
18
+ Requires-Dist: rlPyCairo
19
+ Requires-Dist: svglib
20
+ Requires-Dist: ocp_vscode
21
+
22
+ # PartCAD <!-- omit in toc -->
23
+
24
+ [![License](https://github.com/openvmp/partcad/blob/main/apache20.svg?raw=true)](./LICENSE.txt)
25
+
26
+ [![CI on Linux, MacOS and Windows](https://github.com/openvmp/partcad/actions/workflows/python-test.yml/badge.svg)](https://github.com/openvmp/partcad/actions/workflows/python-test.yml)
27
+ [![CD on Linux, MacOS and Windows](https://github.com/openvmp/partcad/actions/workflows/python-build.yml/badge.svg)](https://github.com/openvmp/partcad/actions/workflows/python-build.yml)
28
+ [![Deployment to PyPI](https://github.com/openvmp/partcad/actions/workflows/python-deploy.yml/badge.svg)](https://github.com/openvmp/partcad/actions/workflows/python-deploy.yml)
29
+ [![Documentation Status](https://readthedocs.org/projects/partcad/badge/?version=latest)](https://partcad.readthedocs.io/en/latest/?badge=latest)
30
+ <a href="https://discord.gg/AXbP47zYw5"><img alt="Discord" src="https://img.shields.io/discord/1091497262733074534?logo=discord&logoColor=white&label=Discord&labelColor=353c43&color=31c151"></a>
31
+
32
+ PartCAD is the first build system and package manager for CAD models,
33
+ and a framework for creating assemblies.
34
+
35
+ PartCAD allows to maintain information about mechanical parts,
36
+ how they come together to form larger assemblies,
37
+ and to reuse the same parts in multiple assemblies, multiple projects.
38
+ The implementation of parts can change over time
39
+ (e.g. optimize or migrate to [build123d] from [STEP]) without the need to update
40
+ all of the consumers.
41
+
42
+ Find [more documentation here](https://partcad.readthedocs.io/en/latest/?badge=latest).
43
+
44
+ ## Installation
45
+
46
+ The recommended method to install PartCAD for most users is:
47
+
48
+ ```shell
49
+ pip install partcad-cli
50
+ ```
51
+
52
+ For contributors:
53
+
54
+ ```shell
55
+ git clone https://github.com/openvmp/partcad.git
56
+ cd partcad
57
+ python3 -m pip install -e ./partcad
58
+ python3 -m pip install -e ./partcad-cli
59
+ ```
60
+
61
+ PartCAD works best when [conda](https://docs.conda.io/) is installed.
62
+ If that doesn't help (e.g. MacOS+arm64) then try ``mamba``.
63
+ On Windows, PartCAD requires at least a `conda` environment.
64
+
65
+ ## Architecture
66
+
67
+ ![Architecture](https://github.com/openvmp/partcad/blob/main/docs/source/architecture.png?raw=true)
68
+
69
+ ## Tools for mechanical engineering
70
+
71
+ Here is an overview of the open source tools to maintain
72
+ mechanical projects. It shows where does this framework fit
73
+ in the modern mechanical development workflows.
74
+
75
+ ```mermaid
76
+ flowchart TB
77
+
78
+ subgraph repo["Your project's GIT repository"]
79
+ subgraph custom_repo["Custom parts"]
80
+ direction TB
81
+ custom_part_internet["A STEP file\ndownloaded from Internet\nor the vendor site"]
82
+ custom_part_cad["A part exported as a solid\nfrom a CAD tool not\nsuitable for collaboration"]
83
+ custom_part_cq["An individual reusable part\nmaintained as a script\nunder a version control system"]
84
+ custom_part_os["Another reusable part\nmaintained as a script\nunder a version control system"]
85
+ end
86
+
87
+ model["Your project's model defined\nas ASSY or Python code\nfor version control\nand collaboration"]
88
+
89
+ subgraph scenes["Scenes"]
90
+ test1["Capability 1\ntest scene"]
91
+ test2["Capability 2\ntest scene"]
92
+ end
93
+ end
94
+
95
+ subgraph external_repos["Third-party GIT repositories,\nCDN-hosted files or OCCI servers"]
96
+ subgraph external_repo["Repository of standard\nor popular parts"]
97
+ end
98
+ end
99
+
100
+ subgraph external_tools["External tools"]
101
+ freecad["FreeCAD"]
102
+ cadquery["CadQuery / build123d"]
103
+ openscad["OpenSCAD"]
104
+ gazebo["Gazebo"]
105
+
106
+ partcad["PartCAD library"]
107
+ style partcad fill:#c00
108
+ end
109
+
110
+ custom_part_cad <--- |Individual\ncontributor|freecad
111
+ custom_part_cq <--- |Part design\nworkflow| cadquery
112
+ custom_part_os <--- |Part design\nworkflow| openscad
113
+
114
+ external_repo ---> |Import| model
115
+ custom_repo ---> |Import| model
116
+ model -.-> |Import| test1
117
+ model -.-> |Import| test2
118
+
119
+ custom_repo <-. Maintained\nusing\nPartCAD\nconvention .- partcad
120
+ external_repo <-. Maintained\nusing\nPartCAD\nconvention .- partcad
121
+ model <--- partcad
122
+ test1 <--- partcad
123
+ test2 <--- partcad
124
+
125
+ test1 -.-> |Export| gazebo
126
+ test2 -.-> |Export| gazebo
127
+ ```
128
+
129
+ [CadQuery]: https://github.com/CadQuery/cadquery
130
+ [build123d]: https://github.com/gumyr/build123d
131
+ [STEP]: https://en.wikipedia.org/wiki/ISO_10303
132
+ [OpenCASCADE]: https://www.opencascade.com/
@@ -0,0 +1,111 @@
1
+ # PartCAD <!-- omit in toc -->
2
+
3
+ [![License](https://github.com/openvmp/partcad/blob/main/apache20.svg?raw=true)](./LICENSE.txt)
4
+
5
+ [![CI on Linux, MacOS and Windows](https://github.com/openvmp/partcad/actions/workflows/python-test.yml/badge.svg)](https://github.com/openvmp/partcad/actions/workflows/python-test.yml)
6
+ [![CD on Linux, MacOS and Windows](https://github.com/openvmp/partcad/actions/workflows/python-build.yml/badge.svg)](https://github.com/openvmp/partcad/actions/workflows/python-build.yml)
7
+ [![Deployment to PyPI](https://github.com/openvmp/partcad/actions/workflows/python-deploy.yml/badge.svg)](https://github.com/openvmp/partcad/actions/workflows/python-deploy.yml)
8
+ [![Documentation Status](https://readthedocs.org/projects/partcad/badge/?version=latest)](https://partcad.readthedocs.io/en/latest/?badge=latest)
9
+ <a href="https://discord.gg/AXbP47zYw5"><img alt="Discord" src="https://img.shields.io/discord/1091497262733074534?logo=discord&logoColor=white&label=Discord&labelColor=353c43&color=31c151"></a>
10
+
11
+ PartCAD is the first build system and package manager for CAD models,
12
+ and a framework for creating assemblies.
13
+
14
+ PartCAD allows to maintain information about mechanical parts,
15
+ how they come together to form larger assemblies,
16
+ and to reuse the same parts in multiple assemblies, multiple projects.
17
+ The implementation of parts can change over time
18
+ (e.g. optimize or migrate to [build123d] from [STEP]) without the need to update
19
+ all of the consumers.
20
+
21
+ Find [more documentation here](https://partcad.readthedocs.io/en/latest/?badge=latest).
22
+
23
+ ## Installation
24
+
25
+ The recommended method to install PartCAD for most users is:
26
+
27
+ ```shell
28
+ pip install partcad-cli
29
+ ```
30
+
31
+ For contributors:
32
+
33
+ ```shell
34
+ git clone https://github.com/openvmp/partcad.git
35
+ cd partcad
36
+ python3 -m pip install -e ./partcad
37
+ python3 -m pip install -e ./partcad-cli
38
+ ```
39
+
40
+ PartCAD works best when [conda](https://docs.conda.io/) is installed.
41
+ If that doesn't help (e.g. MacOS+arm64) then try ``mamba``.
42
+ On Windows, PartCAD requires at least a `conda` environment.
43
+
44
+ ## Architecture
45
+
46
+ ![Architecture](https://github.com/openvmp/partcad/blob/main/docs/source/architecture.png?raw=true)
47
+
48
+ ## Tools for mechanical engineering
49
+
50
+ Here is an overview of the open source tools to maintain
51
+ mechanical projects. It shows where does this framework fit
52
+ in the modern mechanical development workflows.
53
+
54
+ ```mermaid
55
+ flowchart TB
56
+
57
+ subgraph repo["Your project's GIT repository"]
58
+ subgraph custom_repo["Custom parts"]
59
+ direction TB
60
+ custom_part_internet["A STEP file\ndownloaded from Internet\nor the vendor site"]
61
+ custom_part_cad["A part exported as a solid\nfrom a CAD tool not\nsuitable for collaboration"]
62
+ custom_part_cq["An individual reusable part\nmaintained as a script\nunder a version control system"]
63
+ custom_part_os["Another reusable part\nmaintained as a script\nunder a version control system"]
64
+ end
65
+
66
+ model["Your project's model defined\nas ASSY or Python code\nfor version control\nand collaboration"]
67
+
68
+ subgraph scenes["Scenes"]
69
+ test1["Capability 1\ntest scene"]
70
+ test2["Capability 2\ntest scene"]
71
+ end
72
+ end
73
+
74
+ subgraph external_repos["Third-party GIT repositories,\nCDN-hosted files or OCCI servers"]
75
+ subgraph external_repo["Repository of standard\nor popular parts"]
76
+ end
77
+ end
78
+
79
+ subgraph external_tools["External tools"]
80
+ freecad["FreeCAD"]
81
+ cadquery["CadQuery / build123d"]
82
+ openscad["OpenSCAD"]
83
+ gazebo["Gazebo"]
84
+
85
+ partcad["PartCAD library"]
86
+ style partcad fill:#c00
87
+ end
88
+
89
+ custom_part_cad <--- |Individual\ncontributor|freecad
90
+ custom_part_cq <--- |Part design\nworkflow| cadquery
91
+ custom_part_os <--- |Part design\nworkflow| openscad
92
+
93
+ external_repo ---> |Import| model
94
+ custom_repo ---> |Import| model
95
+ model -.-> |Import| test1
96
+ model -.-> |Import| test2
97
+
98
+ custom_repo <-. Maintained\nusing\nPartCAD\nconvention .- partcad
99
+ external_repo <-. Maintained\nusing\nPartCAD\nconvention .- partcad
100
+ model <--- partcad
101
+ test1 <--- partcad
102
+ test2 <--- partcad
103
+
104
+ test1 -.-> |Export| gazebo
105
+ test2 -.-> |Export| gazebo
106
+ ```
107
+
108
+ [CadQuery]: https://github.com/CadQuery/cadquery
109
+ [build123d]: https://github.com/gumyr/build123d
110
+ [STEP]: https://en.wikipedia.org/wiki/ISO_10303
111
+ [OpenCASCADE]: https://www.opencascade.com/
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "partcad-cli"
3
- version = "0.4.2"
3
+ version = "0.5.1"
4
4
  description = "Command-line interface to PartCAD"
5
5
  readme = "README.md"
6
6
  keywords = ["cadquery", "build123d", "cad", "design", "openscad", "step", "stl"]
@@ -1,4 +1,4 @@
1
- partcad==0.4.2
1
+ partcad==0.5.1
2
2
  pycairo
3
3
  renderlab
4
4
  rlPyCairo
@@ -4,4 +4,4 @@ __all__ = [
4
4
  "main_cli",
5
5
  ]
6
6
 
7
- __version__: str = "0.4.2"
7
+ __version__: str = "0.5.1"
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # OpenVMP, 2023
4
+ #
5
+ # Author: Roman Kuzmenko
6
+ # Created: 2023-12-22
7
+ #
8
+ # Licensed under Apache License, Version 2.0.
9
+ #
10
+
11
+ import argparse
12
+ import logging
13
+
14
+ import partcad as pc
15
+ import partcad.logging as pc_logging
16
+ from partcad.user_config import user_config
17
+
18
+ from .cli_add import *
19
+ from .cli_init import *
20
+ from .cli_info import *
21
+ from .cli_install import *
22
+ from .cli_list import *
23
+ from .cli_render import *
24
+ from .cli_inspect import *
25
+ from .cli_status import *
26
+
27
+
28
+ # Initialize plugins that are not enabled by default
29
+ pc.plugins.export_png = pc.PluginExportPngReportlab()
30
+
31
+
32
+ def main():
33
+ parser = argparse.ArgumentParser(
34
+ description="PartCAD command line tool",
35
+ )
36
+ parser.add_argument(
37
+ "-v",
38
+ help="Increase the level of verbosity",
39
+ dest="verbosity",
40
+ action="count",
41
+ default=0,
42
+ )
43
+ parser.add_argument(
44
+ "--no-ansi",
45
+ help="Plain logging output. Do not use colors or animations.",
46
+ dest="no_ansi",
47
+ action="store_true",
48
+ )
49
+ parser.add_argument(
50
+ "-p",
51
+ help="Package path (a YAML file or a directory with 'partcad.yaml')",
52
+ type=str,
53
+ default=None,
54
+ dest="config_path",
55
+ )
56
+ # TODO(clairbee): add a config option to change logging mechanism and level
57
+ subparsers = parser.add_subparsers(dest="command")
58
+ cli_help_add(subparsers)
59
+ cli_help_init(subparsers)
60
+ cli_help_info(subparsers)
61
+ cli_help_install(subparsers)
62
+ cli_help_list(subparsers)
63
+ cli_help_render(subparsers)
64
+ cli_help_inspect(subparsers)
65
+ cli_help_status(subparsers)
66
+
67
+ args = parser.parse_args()
68
+
69
+ # Configure logging
70
+ if not args.no_ansi:
71
+ pc.logging_ansi_terminal_init()
72
+ else:
73
+ logging.basicConfig()
74
+
75
+ if args.verbosity > 0:
76
+ pc.logging.setLevel(logging.DEBUG)
77
+ else:
78
+ pc.logging.setLevel(logging.INFO)
79
+
80
+ try:
81
+ # First, handle the commands that don't require a context or initialize it
82
+ # in their own way
83
+ if args.command == "init":
84
+ cli_init(args)
85
+ return
86
+ elif args.command == "status":
87
+ cli_status(args)
88
+ return
89
+
90
+ if args.command == "install" or args.command == "update":
91
+ user_config.force_update = True
92
+
93
+ # Initialize the context
94
+ if not args.config_path is None:
95
+ ctx = pc.init(args.config_path)
96
+ else:
97
+ ctx = pc.init()
98
+
99
+ # Handle the command
100
+ if args.command == "add":
101
+ with pc_logging.Process("Add", "this"):
102
+ cli_add(args, ctx)
103
+
104
+ elif args.command == "add-part":
105
+ with pc_logging.Process("AddPart", "this"):
106
+ cli_add_part(args, ctx)
107
+
108
+ elif args.command == "add-assembly":
109
+ with pc_logging.Process("AddAssy", "this"):
110
+ cli_add_assembly(args, ctx)
111
+
112
+ elif args.command == "info":
113
+ with pc_logging.Process("Info", "this"):
114
+ cli_info(args, ctx)
115
+
116
+ elif args.command == "install" or args.command == "update":
117
+ with pc_logging.Process("Install", "this"):
118
+ cli_install(args, ctx)
119
+
120
+ elif args.command == "list":
121
+ with pc_logging.Process("List", "this"):
122
+ cli_list(args, ctx)
123
+
124
+ elif args.command == "list-all":
125
+ with pc_logging.Process("ListAll", "this"):
126
+ cli_list_assemblies(args, ctx)
127
+ cli_list_parts(args, ctx)
128
+
129
+ elif args.command == "list-parts":
130
+ with pc_logging.Process("ListParts", "this"):
131
+ cli_list_parts(args, ctx)
132
+
133
+ elif args.command == "list-assemblies":
134
+ with pc_logging.Process("ListAssy", "this"):
135
+ cli_list_assemblies(args, ctx)
136
+
137
+ elif args.command == "render":
138
+ with pc_logging.Process("Render", "this"):
139
+ cli_render(args, ctx)
140
+
141
+ elif args.command == "inspect":
142
+ with pc_logging.Process("inspect", "this"):
143
+ cli_inspect(args, ctx)
144
+
145
+ else:
146
+ print("Unknown command.\n")
147
+ parser.print_help()
148
+ except:
149
+ pc.logging.exception("PartCAD CLI exception")
150
+
151
+
152
+ if __name__ == "__main__":
153
+ main()
@@ -37,7 +37,7 @@ def cli_help_add(subparsers):
37
37
  "kind",
38
38
  help="Type of the part",
39
39
  type=str,
40
- choices=["cadquery", "build123d", "step", "stl", "3mf"],
40
+ choices=["cadquery", "build123d", "scad", "step", "stl", "3mf"],
41
41
  )
42
42
  parser_add_part.add_argument(
43
43
  "path",
@@ -63,17 +63,17 @@ def cli_help_add(subparsers):
63
63
 
64
64
 
65
65
  def cli_add(args, ctx):
66
- prj = ctx.get_project(pc.THIS)
66
+ prj = ctx.get_project(pc.ROOT)
67
67
  prj.add_import(args.alias, args.location)
68
68
 
69
69
 
70
70
  def cli_add_part(args, ctx):
71
- prj = ctx.get_project(pc.THIS)
71
+ prj = ctx.get_project(pc.ROOT)
72
72
  if prj.add_part(args.kind, args.path):
73
73
  Path(args.path).touch()
74
74
 
75
75
 
76
76
  def cli_add_assembly(args, ctx):
77
- prj = ctx.get_project(pc.THIS)
77
+ prj = ctx.get_project(pc.ROOT)
78
78
  if prj.add_assembly(args.kind, args.path):
79
79
  Path(args.path).touch()
@@ -19,6 +19,16 @@ def cli_help_info(subparsers):
19
19
  "info",
20
20
  help="Show detailed info a part, assembly or scene",
21
21
  )
22
+
23
+ parser_info.add_argument(
24
+ "-P",
25
+ "--package",
26
+ help="Package to retrieve the object from",
27
+ type=str,
28
+ dest="package",
29
+ default=None,
30
+ )
31
+
22
32
  group_type = parser_info.add_mutually_exclusive_group(required=False)
23
33
  group_type.add_argument(
24
34
  "-a",
@@ -33,6 +43,12 @@ def cli_help_info(subparsers):
33
43
  action="store_true",
34
44
  )
35
45
 
46
+ parser_info.add_argument(
47
+ "object",
48
+ help="Part (default), assembly or scene to show",
49
+ type=str,
50
+ )
51
+
36
52
  parser_info.add_argument(
37
53
  "-p",
38
54
  "--param",
@@ -42,47 +58,41 @@ def cli_help_info(subparsers):
42
58
  action="append",
43
59
  )
44
60
 
45
- parser_info.add_argument(
46
- "object",
47
- help="Part (default), assembly or scene to show",
48
- type=str,
49
- )
50
- parser_info.add_argument(
51
- "package",
52
- help="Package to retrieve the object from",
53
- type=str,
54
- nargs="?",
55
- )
56
-
57
61
 
58
62
  def cli_info(args, ctx):
59
- if args.package is None:
60
- package = "this"
61
- else:
62
- package = args.package
63
-
64
63
  params = {}
65
64
  if not args.params is None:
66
65
  for kv in args.params:
67
66
  k, v = kv.split("=")
68
67
  params[k] = v
69
68
 
69
+ if args.package is None:
70
+ if ":" in args.object:
71
+ path = args.object
72
+ else:
73
+ path = ":" + args.object
74
+ else:
75
+ path = args.package + ":" + args.object
76
+
70
77
  if args.assembly:
71
- obj = ctx.get_assembly(args.object, package, params=params)
78
+ obj = ctx.get_assembly(path, params=params)
72
79
  else:
73
- obj = ctx.get_part(args.object, package, params=params)
80
+ obj = ctx.get_part(path, params=params)
74
81
 
75
82
  if obj is None:
76
83
  if args.package is None:
77
84
  pc_logging.error("Object %s not found" % args.object)
78
85
  else:
79
86
  pc_logging.error(
80
- "Object %s not found in package %s" % (args.object, args.package)
87
+ "Object %s not found in package %s"
88
+ % (args.object, args.package)
81
89
  )
82
90
  else:
83
91
  pc_logging.info("CONFIGURATION: %s" % pformat(obj.config))
84
- asyncio.run(obj.get_shape())
92
+ asyncio.run(obj.get_wrapped())
85
93
  pc_logging.info(
86
94
  "RUNTIME PROPERTIES: %s"
87
- % pformat({"Memory": "%.02f KB" % ((total_size(obj) + 1023) / 1024)})
95
+ % pformat(
96
+ {"Memory": "%.02f KB" % ((total_size(obj) + 1023) / 1024)}
97
+ )
88
98
  )
@@ -11,13 +11,23 @@ import partcad.logging as pc_logging
11
11
 
12
12
 
13
13
  # TODO(clairbee): fix type checking here
14
- # def cli_help_show(subparsers: argparse._SubParsersAction[argparse.ArgumentParser]):
15
- def cli_help_show(subparsers):
16
- parser_show = subparsers.add_parser(
17
- "show",
14
+ # def cli_help_inspect(subparsers: argparse._SubParsersAction[argparse.ArgumentParser]):
15
+ def cli_help_inspect(subparsers):
16
+ parser_inspect = subparsers.add_parser(
17
+ "inspect",
18
18
  help="Visualize a part, assembly or scene",
19
19
  )
20
- group_type = parser_show.add_mutually_exclusive_group(required=False)
20
+
21
+ parser_inspect.add_argument(
22
+ "-P",
23
+ "--package",
24
+ help="Package to retrieve the object from",
25
+ type=str,
26
+ dest="package",
27
+ default=None,
28
+ )
29
+
30
+ group_type = parser_inspect.add_mutually_exclusive_group(required=False)
21
31
  group_type.add_argument(
22
32
  "-a",
23
33
  help="The object is an assembly",
@@ -31,7 +41,13 @@ def cli_help_show(subparsers):
31
41
  action="store_true",
32
42
  )
33
43
 
34
- parser_show.add_argument(
44
+ parser_inspect.add_argument(
45
+ "object",
46
+ help="Path to the part (default), assembly or scene to inspect",
47
+ type=str,
48
+ )
49
+
50
+ parser_inspect.add_argument(
35
51
  "-p",
36
52
  "--param",
37
53
  metavar="<param_name>=<param_value>",
@@ -40,42 +56,34 @@ def cli_help_show(subparsers):
40
56
  action="append",
41
57
  )
42
58
 
43
- parser_show.add_argument(
44
- "object",
45
- help="Part (default), assembly or scene to show",
46
- type=str,
47
- )
48
- parser_show.add_argument(
49
- "package",
50
- help="Package to retrieve the object from",
51
- type=str,
52
- nargs="?",
53
- )
54
-
55
-
56
- def cli_show(args, ctx):
57
- if args.package is None:
58
- package = "this"
59
- else:
60
- package = args.package
61
59
 
60
+ def cli_inspect(args, ctx):
62
61
  params = {}
63
62
  if not args.params is None:
64
63
  for kv in args.params:
65
64
  k, v = kv.split("=")
66
65
  params[k] = v
67
66
 
67
+ if args.package is None:
68
+ if ":" in args.object:
69
+ path = args.object
70
+ else:
71
+ path = ":" + args.object
72
+ else:
73
+ path = args.package + ":" + args.object
74
+
68
75
  if args.assembly:
69
- obj = ctx.get_assembly(args.object, package, params=params)
76
+ obj = ctx.get_assembly(path, params=params)
70
77
  else:
71
- obj = ctx.get_part(args.object, package, params=params)
78
+ obj = ctx.get_part(path, params=params)
72
79
 
73
80
  if obj is None:
74
81
  if args.package is None:
75
82
  pc_logging.error("Object %s not found" % args.object)
76
83
  else:
77
84
  pc_logging.error(
78
- "Object %s not found in package %s" % (args.object, args.package)
85
+ "Object %s not found in package %s"
86
+ % (args.object, args.package)
79
87
  )
80
88
  else:
81
89
  obj.show()
@@ -13,6 +13,10 @@ def cli_help_install(subparsers):
13
13
  "install",
14
14
  help="Download and prepare all imported packages",
15
15
  )
16
+ parser_update = subparsers.add_parser(
17
+ "update",
18
+ help="Update all imported packages",
19
+ )
16
20
 
17
21
 
18
22
  def cli_install(args, ctx):