pycatia.in_interfaces.document¶
Module initially auto generated using V5Automation files from CATIA V5 R28 on 2020-06-11 12:40:47.360445
Warning
The notes denoted “CAA V5 Visual Basic Help” are to be used as reference only. They are there as a guide as to how the visual basic / catscript functions work and thus help debugging in pycatia.
- class pycatia.in_interfaces.document.Document(com_object)¶
Note
CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
System.IUnknownSystem.IDispatchSystem.CATBaseUnknownSystem.CATBaseDispatchSystem.AnyObjectDocumentRepresents the document.The document is the object handled by the operating system as a whole thatstores your data in files and databases. It is assigned a type determined byits contents. It may contain other documents with a different type. Forexample, a PartDocument contains a part and can be contained in aProductDocument. A workshop is associated with a document to gather all thecommands that can be used to create, modify, and edit the objects making up thethe document. These commands are arranged in menus andtoolbars.See also:PartDocument, ProductDocument, DrawingDocument- activate() None ¶
Activates the document
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Sub Activate()Activates the document. Activating a document means that this document isthe one on which the end user is now working on. This document possiblyreconfigures the menu bar and toolbars with its own commands if its type isdifferent from the type of the previous active document. The first window inthe window collection which contains this document becomes the activeone.Example:This example activates the Doc document.Doc.Activate()
- Return type:
None
- property cameras: Cameras¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
- o Property Cameras() As Cameras (Read Only)Returns the document’s collection of cameras.Example:This example retrieves in CameraCollection the collection of camerasattached to the Doc document.Dim CameraCollection As CamerasSet CameraCollection = Doc.Cameras
- Return type:
- close() None ¶
Closes the current document.
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Sub Close()Closes the document. This closes all the windows displaying the document.If the document needs to be saved, the end user is prompted whether to save thedocument, or to close it anyway.Example:This example closes the Doc documentDoc.Close()
- create_filter(i_filter_name: str, i_filter_definition: str) None ¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Sub CreateFilter(CATBSTR iFilterName,CATBSTR iFilterDefinition)Creates a new visualization filter from a name and a definition. Fails ifthere is already a filter named iFilterName.Parameters:iFilterNameThe filter name.iFilterDefinitionThe filter definitionExample:This example creates the filter named “Filter001” and with “layer=2 & layer= 1” definition for the Doc document.Doc.CreateFilter (“Filter001”, “layer= 2 & layer=1”)
- Parameters:
i_filter_name (str) –
i_filter_definition (str) –
- Return type:
None
- create_reference_from_name(i_label: str) Reference ¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Func CreateReferenceFromName(CATBSTR iLabel) As ReferenceCreates a reference from a GenericNaming label. Each kind of documentprovides a specific implementation.Parameters:iLabelThe GenericNaming identification for an object.Returns:The reference to the object.
- Parameters:
i_label (str) –
- Return type:
- property current_filter: str¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
- o Property CurrentFilter() As CATBSTRReturns or sets the current visualization filter. CurrentFilter uses thefilter name and not its definition. The “All visible” filter means that alllayers are visible. For all filters, remind that the current layer is alwaysvisible.Example:This example makes the filter named “Filter001” as the currentvisualization filter for the Doc document.Doc.CurrentFilter = “Filter001”
- Return type:
str
- property current_layer: str¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
- o Property CurrentLayer() As CATBSTRReturns or sets the current layer. CurrentLayer uses the layer name and notits number. The “None” layer means that there is no currentlayer.Example:This example makes the layer named “Layer 3” as the current layer forthe Doc document.Doc.CurrentLayer = “Layer 3”
- Return type:
str
- export_data(file_name: Path, file_type: str, overwrite=False) None ¶
Note
CAA V5 Visual Basic help
Sub ExportData( CATBSTR fileName, CATBSTR format)
Exports the data contained in the document to another format.Parameters:fileNameThe name of the exported fileformatThe name of the formatExample:This example writes the Doc document in the IGES format under the IGESDoc name.Doc.ExportData(“IGESDoc”, “igs”)- Parameters:
file_name (Path) – file_name including full path.
file_type (str) – file_type is the extension of required file_type. The file_type must be supported by CATIA and the CATIA license.
overwrite (bool) – Files will not be overwritten unless is True.
- Returns:
- property full_name¶
Note
CAA V5 Visual Basic help
Property FullName( ) As CATBSTR (Read Only)
Returns the document’s full file name, including its path.Example:This example retrieves in DocFullName the Doc document’s full file name.DocFullName = Doc.FullNameThe returned value is like this:e://users//psr//Parts//MyNicePart.CATPart- Returns:
str - full path document name
- get_workbench(workbench_name: str) Workbench ¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Func GetWorkbench(CATBSTR workbenchName) As WorkbenchReturns one of the workbenches of the document.Parameters:workbenchNameThe name of the workbenchExample:This example retrieves the Structural workbench on the DocdocumentDoc.GetWorkbench(“Structural”)
- Parameters:
workbench_name (str) –
- Return type:
- indicate_2d(i_message: str) str ¶
Returns a tuple in the format (status: str, (x_2d: float, y_2d: float)) Status can be ‘Normal’, ‘Cancel’,
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Func Indicate2D(CATBSTR iMessage,CATSafeArrayVariant ioDocumentWindowLocation) As CATBSTRRuns an 2D interactive indication command.Role: Indicate2D asks to the user to select a location in the documentwindow. It can be used:When this document is a DrawingDocumentWhen this document is a PartDocument, and a sketch is being edited (Sketch.OpenEdition has been called and Sketch.CloseEdition has not been calledyet)See also: Selection.IndicateOrSelectElement2D which can, in particular,enable indication and not selection (positionning the iFilterType parameter toan empty string), whichs enables to subscribe to mouse move events,positionning the iTriggeringOnPreSelection to true.Note:If the scripting language is Visual Basic for Applications or VisualBasic 6 Development Studio, then, you have to know that during the execution ofan interactive selection method such as this one, no form (dialog box) must bedisplayed, otherwise it would lead to unpredictible results. In a form method,before calling an interactive selection method such as Document.Indicate2D, youmust hide all forms, and, after the call to the method, you must show theforms.Parameters:iMessageA string which instructs the user that he must select a location inthe document window. This string is displayed in the message area located atthe left of the power input area.oDocumentWindowLocationAn array made of 2 doubles: X, Y - coordinates array of thelocation the user specified in the document window.oOutputStateThe state of the indication command once Indicate2D returns. It canbe either “Normal” (the indication has succeeded), “Cancel” (the user wants tocancel the VB command, which must exit immediately, see the oOutputStateparameter of the Selection.SelectElement2 method), “Undo” or “Redo”. About the use of“Undo” and “Redo”, see the example of the Selection.SelectElement2 method.Example:The following example suppose a drawing document is currently edited.It asks the end user to select alocation in the current drawing window, and creates a text (seeDrawingText ) at the specified location:Set Document = CATIA.ActiveDocumentSet Selection = Document.SelectionSet DrawingSheets = Document.SheetsSet DrawingSheet = DrawingSheets.ActiveSheetSet DrawingViews = DrawingSheet.ViewsSet DrawingView = DrawingViews.ActiveViewSet DrawingTexts = DrawingView.Texts‘We propose to the user that he specify a location in the drawing windowDim DrawingWindowLocation(1)Status=Document.Indicate2D(“select a location into the drawingwindow”,DrawingWindowLocation)if (Status = “Cancel”) then Exit SubSet DrawingText=DrawingTexts.Add(“Helloworld”,DrawingWindowLocation(0),DrawingWindowLocation(1))
- Parameters:
i_message (str) –
- Returns:
tuple
- indicate_3d(i_planar_geometric_object: AnyObject, i_message: str) str ¶
Returns a tuple in the format (status: str, (x_2d: float, y_2d: float), (x_3d: float, y_3d: float, z_3d: float)) Status can be ‘Normal’, ‘Cancel’,
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Func Indicate3D(AnyObject iPlanarGeometricObject,CATBSTR iMessage,CATSafeArrayVariant ioWindowLocation2D,CATSafeArrayVariant ioWindowLocation3D) As CATBSTRRuns an 3D interactive indication command.Role: Indicate3D asks to the user to select a location in the documentwindow. It cannot be used:When this document is a DrawingDocumentWhen this document is a PartDocument, and a sketch is being edited (Sketch.OpenEdition has been called and Sketch.CloseEdition has not been calledyet)In these cases, Indicate2D must be used.See also: Selection.IndicateOrSelectElement3D which can, in particular,enable indication and not selection (positioning the iFilterType parameter toan empty string), which enables to subscribe to mouse move events,positioning the iTriggeringOnPreSelection to true.Note:If the scripting language is Visual Basic for Applications or VisualBasic 6 Development Studio, then, you have to know that during the execution ofan interactive selection method such as this one, no form (dialog box) must bedisplayed, otherwise it would lead to unpredictable results. In a form method,before calling an interactive selection method such as Document.Indicate2D, youmust hide all forms, and, after the call to the method, you must show theforms.Parameters:iPlanarGeometricObjectA planar geometric object.The following objects are supported:HybridShapeCircle, HybridShapeCircleExplicit, HybridShapeConic, Sketch,Circle2D, Ellipse2D, Hyperbola2D, Parabola2D and Spline2D.iMessageA string which instructs the user that he must select a location in thedocument window. This string is displayed in the message area located at theleft of the power input area.oWindowLocation2DAn array made of 2 doubles: X, Y - coordinates array of the locationthe user specified in the document window, in the input planar objectcoordinates systemoWindowLocation3DAn array made of 3 doubles: X, Y, Z - coordinates array of the locationthe user specified in the document windowoOutputStateThe state of the indication command once Indicate3D returns. It can beeither “Normal” (the indication has succeeded), “Cancel” (the user wants tocancel the VB command, which must exit immediately, see the oOutputStateparameter of the Selection.SelectElement2 method), “Undo” or “Redo”. About theuse of “Undo” and “Redo”, see the example of the Selection.SelectElement2method.Example:The following example asks the end user to select a location in thedocument window, on the Plane.1 plane, and creates aHybridShapePointOnPlane at the specified location:Set Document = CATIA.ActiveDocumentSet Part = Document.PartSet Selection = Document.SelectionSet HybridShapeFactory = Part.HybridShapeFactorySet HybridShapePlane = Part.Bodies.Item(“PartBody”).HybridShapes.Item(“Plane.1”)Set PlaneReference = Part.CreateReferenceFromObject(HybridShapePlane)‘We propose to the user that he select a location in thewindowReDim WindowLocation2D(1),WindowLocation3D(2)Status=Document.Indicate3D(HybridShapePlane,”select a location in thedocument window”, _WindowLocation2D,WindowLocation3D)if (Status = “Cancel”) then Exit SubSet HybridShapePointOnPlane = HybridShapeFactory.AddNewPointOnPlane( _PlaneReference,WindowLocation2D(0),WindowLocation2D(1))Part.Bodies.Item(“PartBody”).InsertHybridShapeHybridShapePointOnPlanePart.InWorkObject = HybridShapePointOnPlanePart.Update
- Parameters:
i_planar_geometric_object (AnyObject) –
i_message (str) –
- Returns:
str
- property is_part¶
Determine whether the active document is a CATPart.
- Returns:
bool
- property is_product¶
Determine whether the active document is a CATProduct.
- Returns:
bool
- property is_saved¶
Returns true if document is saved.
Note
CAA V5 Visual Basic help
Property Saved( ) As boolean (Read Only)
Returns whether the document has been modified, and thus needs to be saved. This happens when the document has changed since either its creation or its last save. True if the document has not been changed: the document doesn’t need to be saved. False if the document has been changed: the document needs to be saved.
Example:This example retrieves in HasChanged whether the Doc document needs to be saved.HasChanged = NOT Doc.Saved- Returns:
bool
- new_window()¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Func NewWindow() As WindowDuplicates the window which contains the active document. This impliescreating a window, displaying the active document in this window with the sameview point, making this window the active one, and adding the window to thecollection of windows.Example:This example creates the MyWindow new window for the Docdocument.Dim MyWindow As WindowSet MyWindow = Doc.NewWindow()
- Returns:
Window
- path()¶
Returns the pathlib.Path() object of the document fullname.
example e://users//psr//Parts//MyNicePart.CATPart >>> Document.path().name MyNicePart.CATPart >>> Document.path().parent e://users//psr//Parts// >>> Document.path().suffix .CATPart
- Returns:
Path()
- property read_only: bool¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
- o Property ReadOnly() As boolean (Read Only)Returns whether the file containing the document can be read only, on canbe read and written.True if the file is read-only.Example:This example retrieves in IsReadOnly the ability to read, and possiblyto write in, the file containing the Doc document.IsReadOnly = Doc.ReadOnly
- Return type:
bool
- remove_filter(i_filter_name)¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Sub RemoveFilter(CATBSTR iFilterName)Removes an existing visualization filter. Fails if the filter to be removedis the current filter.Parameters:iFilterNameThe filter name.Example:This example removes the filter named “Filter001” for the Docdocument.Doc.RemoveFilter (“Filter001”)
- Parameters:
i_filter_name (str) –
- Return type:
None
- save() None ¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Sub Save()Saves the document.Example:This example saves the Doc document.Doc.Save()
- Return type:
None
- save_as(file_name: Path, overwrite: bool = False) None ¶
Save the document to a new name.
If overwrite is True CAA.DisplayFileAlerts is set to False.
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
- o Sub SaveAs(CATBSTR fileName)Saves the document with another name.Parameters:fileNameThe name to assign to the documentExample:This example saves the Doc document with the NewNamename.Doc.SaveAs(“NewName”)
- Parameters:
file_name – full pathname to new file_name
overwrite (bool) – Files will not be overwritten unless is True.
- Returns:
None.
- Return type:
None
- search_for_items(selection_objects)¶
# todo: This search is currently restricted to GSD objects only. Selection objects is a list of items to search for. Example: selection_objects = [‘Point’, ‘Line’] Example query string to search for all lines and points “(‘Generative Shape Design’.Point + ‘Generative Shape Design’.Line),in” :param list selection_objects: :return Selected Automation Object:
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
- o Property SeeHiddenElements() As booleanReturns or sets the document’s hidden elements visibility.True if the document’s hidden elements are visible to theuser.Example:This example makes the Doc document’s hidden elementsvisible.Doc.SeeHiddenElements = True
- Returns:
bool
- property selection: Selection¶
Note
- CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445)
- o Property Selection() As Selection (Read Only)Returns the current selection. The current selection is the object or theset of objects the end user has selected, usually with the mouse, in the activedocument displayed in the active window.Example:This example returns in CurSel the current selection in the DocdocumentDim CurSel As SelectionSet CurSel = Doc.Selection
- Return type:
- spa_workbench()¶
- Returns:
- Return type: