Skip to main content

A python module to access the CATIA Measurable object.

Project description

pycatia was primarily created to access the CATIA API Measurable object and it’s methods without the need of visual basic / CATScripts. There is further functionaliy available which can be seen by looking at the examples provided and reading the API at pycatia.readthedocs.io.

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

  • see requirements.txt

Installation

with pip

pip install pycatia

For more detailed instructions please refer to the installation instructions available at pycatia.readthedocs.io.

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

document.close()

See the examples provided for more pycatia goodness.

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, print the result to the console and write to a CSV file.

    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.

    example_8

    How traverse through a directory and convert all CATParts to IGS.

Running The Tests

To run the tests with coverage:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycatia-0.1.5.1.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycatia-0.1.5.1-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file pycatia-0.1.5.1.tar.gz.

File metadata

  • Download URL: pycatia-0.1.5.1.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pycatia-0.1.5.1.tar.gz
Algorithm Hash digest
SHA256 012a29b4045ea8a7ce4c5ebf3bdd68f17740a52ae0649a005a27b7e3da8010fe
MD5 7f0e4e3c18551fa3275548940207b480
BLAKE2b-256 931416c1a4ecbb357db5ab34e74e8414ec71f4b63d9173dcd037d65a29e506fd

See more details on using hashes here.

File details

Details for the file pycatia-0.1.5.1-py3-none-any.whl.

File metadata

  • Download URL: pycatia-0.1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pycatia-0.1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 989463f9b5752885fd9970c0f45d81a4c0556092a12b964d9334c2c3835e72aa
MD5 9c593d70e08afef5762516829bd2d880
BLAKE2b-256 20c818c590bcfc7db589ae0c004c3ba16e55efd7de318cd66cd80e6c36317e2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page