Skip to content

petitchamp/catia-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

catia-cli

Command line automation helpers for CATIA V5 using pycatia.

catia-cli is intentionally small: it gives you reliable shell commands for connecting to a running CATIA session, inspecting documents, and performing common document operations.

Requirements

  • Windows
  • CATIA V5 installed and running
  • Python 3.10+
  • pycatia

CATIA automation is COM based. Start CATIA before running commands that connect to it.

Install

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .[dev]

Usage

catia-cli --help
catia-cli app info
catia-cli api list start_command --limit 10
catia-cli api show pycatia.in_interfaces.application.Application
catia-cli get app.active_document.name
catia-cli call app.start_command Pad
catia-cli documents list
catia-cli documents new Part --save-as C:\work\example.CATPart
catia-cli documents open C:\work\example.CATPart
catia-cli documents save --name example.CATPart
catia-cli documents export C:\work\example.step --format stp
catia-cli documents close --name example.CATPart --save

Commands

app info

Prints basic information about the connected CATIA application and active document.

documents list

Lists open CATIA documents.

documents new TYPE

Creates a new CATIA document. TYPE must be one of Part, Product, or Drawing.

documents open PATH

Opens an existing CATIA document.

documents save

Saves the active document or a document selected by --name.

documents close

Closes the active document or a document selected by --name.

documents export PATH

Exports the active document or a document selected by --name.

Generic pycatia API access

The api command group exposes the installed pycatia package without requiring one hand-written CLI subcommand per CATIA interface.

Discover functions and properties

catia-cli api list pad --limit 25
catia-cli api show pycatia.mec_mod_interfaces.part.Part

api list searches all public classes, methods, and properties in the installed pycatia package. api show prints the public members of one class.

Inspect runtime CATIA objects

Runtime commands connect to the already-running CATIA V5 session.

catia-cli api inspect app
catia-cli api inspect app.active_document
catia-cli api inspect app.active_document.selection

Read, set, and call any reachable pycatia member

catia-cli get app.name
catia-cli get app.active_document.name
catia-cli set app.visible True
catia-cli call app.start_command Pad
catia-cli call app.active_document.save_as "C:\work\copy.CATPart"

The longer api get, api set, api call, and api inspect forms still work, but the top-level aliases are intended for day-to-day use.

Paths start at app, application, or catia. You can omit the root for application members, so active_document.name is equivalent to app.active_document.name.

Collection selection uses CATIA's item method when available:

catia-cli get app.documents[1].name
catia-cli get app.documents[example.CATPart].full_name

Arguments are parsed as Python literals when possible. For example, True, False, None, numbers, quoted strings, lists, and dictionaries are converted before invoking pycatia. Unquoted values remain strings.

Development

python -m pip install -e .[dev]
pytest

The unit tests use fakes instead of a live CATIA session. Manual CATIA testing still requires CATIA V5 to be running on Windows.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages