A python module to access the CATIA Measurable object.
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.
- python >= 3.6
- CATIA V5/V6
- see requirements.txt
pip install pycatia
Clone the master branch from github into your working folder.
git clone https://github.com/evereux/pycatia.git
Download and unpack the master branch zip into your working folder.
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) >>> (0.0, 8.0, -4.0) # print x print(point_coordinate >>> 0,0
For a complete list of methods available on a measurable object see
the class CATIAMeasurable in
Open the file catia_measurable.CATPart from the folder tests.
Run the example scripts.
Shows how to access the CATIA COM object with a .CATPart open and get the center of gravity for the part body 'PartBody'.
Shows how to get all the points in the geometrical set 'Points' and get the co-ordinate.
Shows how to search for all points in the document and return the co-ordinates.
Shows how to loop through a product and determine whether child is a CATProduct or CATPart.
Running The Tests
- CATIA must be running the the part catia_measurable_part.CATPart open.
- Run the command:
py.test -v --cov-report term-missing --cov=pycatia tests/
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pycatia-0.0.2-py3-none-any.whl (14.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size pycatia-0.0.2.tar.gz (12.5 kB)||File type Source||Python version None||Upload date||Hashes View|