pycatia.in_interfaces.documents

class pycatia.in_interfaces.documents.Documents(com_object)

The Documents object is used to access multiple open documents in the catia session.

Usage:

>>> from pycatia import catia
>>> caa = catia()
>>> documents = caa.documents

.. note::
    :class: toggle

    CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)

        | System.IUnknown
        |     System.IDispatch
        |         System.CATBaseUnknown
        |             System.CATBaseDispatch
        |                 System.Collection
        |                     Documents
        |
        | A collection of all the Document objects currently managed by the
        | application.
        | These documents belong to one of the following types: PartDocument,
        | ProductDocument, and Drawing.
        |
        | See also:
        |     PartDocument, ProductDocument, DrawingDocument
add(document_type) Document

Note

CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
o Func Add(CATBSTR docType) As Document

Creates a Document object and adds it to the documents collection. This
document becomes the active one, and a window is created to accomodate it which
becomes the active window.

Parameters:

docType
The type of the document to create, chosen among:

Part
For PartDocument
Product
For ProductDocument
Drawing
For Drawing

Returns:
The created document
Example:
The following example creates a PartDocument document in the collection
retrieved in PartDoc.

Dim PartDoc As Document
Set PartDoc = Documents.Add(“Part”)
Parameters:

document_type (str) –

Return type:

Document

count_types(file_type_list: list_str) int
Returns the number of documents which presents special file extensions like:

‘catpart’, ‘catdrawing’, ‘catproduct’, ‘catmaterial’, ‘catalog’, ‘catfct’

Parameters:

file_type_list (list_str) – filetype(s) to count. can be list or string.

Returns:

int()

item(index: cat_variant) Document

Note

CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
o Func Item(CATVariant iIndex) As Document

Returns a document using its index or its name from the documents
collection.

Parameters:

iIndex
The index or the name of the document to retrieve frm the
collection of documents. As a numerics, this index is the rank of the document
in the collection. The index of the first document in the collection is 1, and
the index of the last document is Count. As a string, it is the name you
assigned to the document using the

AnyObject.Name property.
Returns:
The retrieved document
Example:
This example retrieves in ThisDoc the fifth document in the collection
and in ThatDoc the document named MyDoc.

Dim ThisDoc As Document
Set ThisDoc = Documents.Item(5)
Dim ThatDoc As Document
Set ThatDoc = Documents.Item(“MyDoc”)
Parameters:

index (cat_variant) –

Return type:

Document

new_from(file_name: str) Document

Note

CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
o Func NewFrom(CATBSTR iFileName) As Document

Creates a new document from a document stored in a file. Role: Reads a
document stored in a file and creates a new document containing the resulting
data, adds the new document to the document collection, displays it in a new
window, adds the window to the window collection and activates both the
document and the window.

Parameters:

The
name of the file containing the document.

Returns:
The created document.
Example:
The following example creates a new Doc document from the contents of
the FileToRead file.

FileToRead = “e:userspsrPartsThisIsANicePart.CATPart”
Dim Doc As Document
Set Doc = Documents.NewFrom(FileToRead)
Parameters:

file_name (str) –

Return type:

Document

num_open() int

Returns the number of open documents.

Warning

The COM object can return the incorrect number of documents open. After a document is closed CATIA can keep the linked document ABQMaterialPropertiesCatalog.CATfct open.

Return type:

int

open(file_name: str) Document

Note

CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
o Func Open(CATBSTR iFileName) As Document

Opens a document stored in a file. Reads a document stored in a file,
displays it in a new window, adds the document to the documents collection and
the window to the windows collection, and makes both the document and the
window the active ones.

Parameters:

iFileName
The name of the file containing the document

Returns:
The retrieved document
Example:
The following example opens the Doc document contained in the
FileToOpen file.

FileToOpen = “e:userspsrPartsThisIsANicePart.CATPart”
Dim Doc As Document
Set Doc = Documents.Open(FileToOpen)
Parameters:

file_name (str) –

Return type:

Document

read(file_name: str) Document

Note

CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
o Func Read(CATBSTR iFileName) As Document

Reads a document stored in a file. This method has to be used only for
Browse purpose, for instance to retrieve Product properties. Be careful, it
doesn’t open any editor (no visualization, no undo/redo capabilities…) As
soon as you want to modify the V5 document, you have to use the VB Open method
collection. If this solution is not satisfactory because it opens an editor for
every document, you have to move to C++ and use the CAA methods
CATDocumentServices::Open and CATDocumentServices::SaveAs with the same file
name as the initial one.

Parameters:

iFileName
The name of the file containing the document

Returns:
The retrieved document
Example:
The following example reads the Doc document contained in the
FileToOpen file.

FileToOpen = “e:userspsrPartsThisIsANicePart.CATPart”
Dim Doc As Document
Set Doc = Documents.Read(FileToOpen)
Parameters:

file_name (str) –

Return type:

Document