Skip to main content

pycatia currently only contains access to the CATIA API Measurable object and it’s methods without the need of visual basic / CATScripts. pycatia also provides easy to use python methods to loop through a product and it’s children.

Some of the methods can be accessed simply using the pywin32 module but further access to methods such as GetCOG do not seem to be accessible using pure python. There are several questions on stack overflow and the pywin32 mailing list regarding this. But, they fail to provide any working examples with the VB Measurable object in python.

pycatia accesses these methods by running VBA scripts using the Dispatch(‘CATIA.Application’).SystemService.Evaluate() function where required and passing a small public function to it. Otherwise, pycatia uses the VB method directly but exposes it within the same python class.

This has currently only been tested in CATIA V5 R21.

Requirements

  • python >= 3.6

  • CATIA V5/V6

  • see requirements.txt

Installation

with pip

pip install pycatia

with git

Clone the master branch from github into your working folder.

git clone https://github.com/evereux/pycatia.git

download zip

Download and unpack the master_branch.zip

Usage

This example shows how to get the first point in the geometrical set ‘Points’.

# initial set-up to get access to the CATIA COM objects.
import pycatia
catia = pycatia.CATIAApplication()
document = pycatia.Document(catia.catia)
part = pycatia.Part(document.document)
spa_workbench = pycatia.create_spa_workbench(document.document)

# find the geometrical set by name called 'Points'
hybrid_body = part.get_hybrid_body_by_name('Points')

# get the first point in the geometrical set.
point1 = hybrid_body.HybridShapes.Item(1)

# create the reference and measurable objects
point1_reference = pycatia.create_reference(part.part, point1)
point1_measurable = pycatia.create_measurable(spa_workbench, point1_reference)

# create the catia measurable object
measurable = pycatia.CATIAMeasurable(point1_measurable)

# run the get_point() method from CATIAMeasurable.
point_coordinate = measurable.get_point()
# point_coordinate is a tuple representing it's x, y, z values.
print(point_coordinate)

# outputs (0.0, 8.0, -4.0)
# print x
print(point_coordinate[0]
# output 0,0

For a complete list of methods available on a measurable object see the class CATIAMeasurable in measurable.py.

Examples

  1. Open the file catia_measurable.CATPart from the folder tests.

  2. Run the example scripts.

    example_1

    Shows how to access the CATIA COM object with a .CATPart open and get the center of gravity for the part body ‘PartBody’.

    example_2

    Shows how to get all the points in the geometrical set ‘Points’ and get the co-ordinate.

    example_3

    Shows how to search for all points in the document and return the co-ordinates.

    example_4

    Shows how to loop through a product and determine whether child is a CATProduct or CATPart.

    example_5

    Shows how to parse and csv file and create points in a CATIA part.

    example_6

    Examples of how to open, save as and close a CATIA file.

    example_7

    Example of how open a document using the context manager.

Running The Tests

To run the tests with coverage:

py.test -v --cov-report term-missing --cov=pycatia

Metadata

Release files for pycatia 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycatia 0.1.0
File Size Uploaded
pycatia-0.1.0.tar.gz 19.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycatia 0.1.0
File Interpreter ABI Platform
pycatia-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.9 kB

Release files / pycatia-0.1.0.tar.gz

Download URL pycatia-0.1.0.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
286e8d39a4d80499038c39eb612ab887e25062bd614c34c2fd13b4f8c067196c
BLAKE2b-256 checksum
How to use checksums
50a7d060e9615392d36751530719fc8a364e1b1b4a191f8984d5e58f344d0711
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release files / pycatia-0.1.0-py3-none-any.whl

Download URL pycatia-0.1.0-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8821209d51a02a060435f32bb1d3abf3367509df8c28c8e1b4a74d8a9afcad47
BLAKE2b-256 checksum
How to use checksums
0bf3bf5980af9ccdb189c1371bc3d80202d3b9acfed4b914e62b400e98d9b9fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release history Release notifications | RSS feed

0.10.0

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

1 release file

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page