Getting Started

Before proceeding with this introduction to pycatia you should have already have pycatia installed. Visit the Installation page.

Before going through the introductory examples on this page you need to have CATIA V5 running and a CMD terminal open with the environment that has pycatia installed activated prior to starting the python interpreter.

Opening A New CATPart

You will almost always want to import the catia Application object or the CATIADocHandler [1].

from pycatia import catia
# initialise the catia automation appliction. CATIA V5 should already be running.
caa = catia()
documents = caa.documents

documents is an instance of the Documents class.

documents.add('Part')

the add method of the documents class expects the string ‘Part’, ‘Product’ or ‘Drawing’. documents.add('Part') adds a new CATPart to the documents collection.

We want to work on this new document. Since this has just been added it’s the active document.

document = caa.active_document

The document object Document has a number of properties that can be accessed.

document.name
# returns the name of the new document.
document.path
# returns the pathlib.Path object of the document.

Creating A Geometrical Set

A geometrical set created using the HybridBodies collection. Your CATIA configuration may by default create a geometrical set in a new CATPart but we’ll create one here anyway.

part = document.part()
hybrid_bodies = part.hybrid_bodies
new_set = hybrid_bodies.add()
new_set.name
# returns the name of your new set.
# to rename the set.
new_set.name = 'Construction Geometry'

For more detailed examples on how to interact with pycatia see the Examples page. There contain several scripts that can be run in the terminal.

Footnotes