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 DocumentCreates a Document object and adds it to the documents collection. Thisdocument becomes the active one, and a window is created to accomodate it whichbecomes the active window.Parameters:docTypeThe type of the document to create, chosen among:PartFor PartDocumentProductFor ProductDocumentDrawingFor DrawingReturns:The created documentExample:The following example creates a PartDocument document in the collectionretrieved in PartDoc.Dim PartDoc As DocumentSet PartDoc = Documents.Add(“Part”)
- Parameters:
document_type (str) –
- Return type:
- 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 DocumentReturns a document using its index or its name from the documentscollection.Parameters:iIndexThe index or the name of the document to retrieve frm thecollection of documents. As a numerics, this index is the rank of the documentin the collection. The index of the first document in the collection is 1, andthe index of the last document is Count. As a string, it is the name youassigned to the document using theAnyObject.Name property.Returns:The retrieved documentExample:This example retrieves in ThisDoc the fifth document in the collectionand in ThatDoc the document named MyDoc.Dim ThisDoc As DocumentSet ThisDoc = Documents.Item(5)Dim ThatDoc As DocumentSet ThatDoc = Documents.Item(“MyDoc”)
- Parameters:
index (cat_variant) –
- Return type:
- 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 DocumentCreates a new document from a document stored in a file. Role: Reads adocument stored in a file and creates a new document containing the resultingdata, adds the new document to the document collection, displays it in a newwindow, adds the window to the window collection and activates both thedocument and the window.Parameters:Thename of the file containing the document.Returns:The created document.Example:The following example creates a new Doc document from the contents ofthe FileToRead file.FileToRead = “e:userspsrPartsThisIsANicePart.CATPart”Dim Doc As DocumentSet Doc = Documents.NewFrom(FileToRead)
- Parameters:
file_name (str) –
- Return type:
- 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 DocumentOpens 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 andthe window to the windows collection, and makes both the document and thewindow the active ones.Parameters:iFileNameThe name of the file containing the documentReturns:The retrieved documentExample:The following example opens the Doc document contained in theFileToOpen file.FileToOpen = “e:userspsrPartsThisIsANicePart.CATPart”Dim Doc As DocumentSet Doc = Documents.Open(FileToOpen)
- Parameters:
file_name (str) –
- Return type:
- read(file_name: str) Document ¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Func Read(CATBSTR iFileName) As DocumentReads a document stored in a file. This method has to be used only forBrowse purpose, for instance to retrieve Product properties. Be careful, itdoesn’t open any editor (no visualization, no undo/redo capabilities…) Assoon as you want to modify the V5 document, you have to use the VB Open methodcollection. If this solution is not satisfactory because it opens an editor forevery document, you have to move to C++ and use the CAA methodsCATDocumentServices::Open and CATDocumentServices::SaveAs with the same filename as the initial one.Parameters:iFileNameThe name of the file containing the documentReturns:The retrieved documentExample:The following example reads the Doc document contained in theFileToOpen file.FileToOpen = “e:userspsrPartsThisIsANicePart.CATPart”Dim Doc As DocumentSet Doc = Documents.Read(FileToOpen)
- Parameters:
file_name (str) –
- Return type: