pycatia.base_interfaces.context

class pycatia.base_interfaces.context.CATIADocHandler(file_name=None, new_document=None)

A context manager to open or create a CATIA document.

Warning

The CATIA document will be closed (and not automatically saved) upon exit.

Only file_name __or__ new_document are required as one document is handled at a time.

Example - Open a CATPart:
>>> from pycatia.base_interfaces.context import CATIADocHandler
>>> catia_part = 'tests//CF_catia_measurable_part.CATPart'
>>> with CATIADocHandler(catia_part) as handler:
>>>     # create the documents object.
>>>     documents = handler.documents
>>>     # create the document object.
>>>     document = handler.document
>>>     # do some stuff
>>>     # save document!
>>>     document.save()
Example - Create a new CATPart:
>>> from pycatia.base_interfaces.context import CATIADocHandler
>>> with CATIADocHandler(new_document='Part') as handler:
>>>     # create the CATIA() object.
>>>     catia = handler.catia
>>>     # create the documents object.
>>>     documents = handler.documents
>>>     # create the document object.
>>>     document = handler.document
>>>     # save document!
>>>     document.save()
Parameters:
  • file_name (str or Path) – (optional) path filename to file

  • new_document (str) – (optional) ‘Part’, ‘Product’ or ‘Drawing’.