pycatia.in_interfaces.selection¶
Module initially auto generated using V5Automation files from CATIA V5 R28 on 2020-07-03 17:02:05.216737
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.selection.Selection(com_object, child_object=<class 'pycatia.in_interfaces.selected_element.SelectedElement'>)¶
Note
CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737)
System.IUnknownSystem.IDispatchSystem.CATBaseUnknownSystem.CATBaseDispatchSystem.AnyObjectSelectionRepresents the selection.The Selection object contains the features the end user selected, usually withthe mouse, and which are candidates as subjects for the nextaction.A feature possess parent objects in the specification tree (hierarchy). Forexample, the Pad below possess parent objects in the specificationtree:+——–+!Product3!+——–+!+- Product2 (Product2.1)! !! +- Product1 (Product1.1)! !! +- Part1 (Part1.1)! !! +- Part1! !! +- PartBody! !+——————+! +- Pad.1 ! Selected feature!! !+——————+! +- Sketch.1+- Part2 (Part2.1)For a given selected feature, its parent objects which are exposed toautomation can be accessed through a recursive call to the AnyObject.Parentproperty. When a given feature is selected, there are threepossibilities:The feature is exposed to automation (a Pad for example, this is the commoncase): the feature can be accessed by all Selection objectmethodsThe feature is not exposed to automation, but at least one of its parentobjects is exposed to automation (a DMU Navigator URL for example: theHyperlink is not exposed to automation, but the root Product, which containsthe Hyperlink, is exposed to automation):no access is given to the feature through the Count2 and Item2 methodsof the Selection objectnevertheless, the first parent object of the feature, which is exposedto automation (the root Product in our example) can be accessed through theItem2 and Count2 methodsThe Search, Delete, VisProperties, Copy, Cut, Paste and PasteSpecialmethods of the Selection object, take into account thefeature.For example, if the user:Puts a DMU Navigator URL in the clipboardRuns a script calling the PasteSpecial methodthen, during the paste, the DMU Navigator URL will bepastedThe feature is not exposed to automation, and he has no parent object whichis exposed to automation (a ResourcesList object of a .CATProcess forexample):no access is given to the feature through the Count2 and Item2 methodsof the Selection objectno access is given neither to any parent object of the feature throughthe Item2 and Count2 methodsThe Search, Delete, VisProperties, Copy, Cut, Paste and PasteSpecialmethods of the Selection object take into account thefeature.For example, if the user:Go to the “DPM - Process and Resource Definition”workshopPuts a ResourcesList object in the clipboardRuns a script calling the Selection.PasteSpecialmethodthen, during the paste, the ResourcesList object will bepasted.Note: The Selection object can be accessed through the Document.Selectionproperty . However, when the active window contains the tree described above,the Selection object to use is the one associated to the Product3 Document ,which can be accessed through the application of the Document.Selection to thisdocument. You will, for example, determine the Selection object the followingway:Set ActiveProductDocument = CATIA.ActiveDocumentSet Product3 = ActiveProductDocument.ProductSet Product3Products = Product3.ProductsSet Product2Dot1 = Product3Products.Item(“Product2.1”) : Set Product2 = Product2Dot1.ReferenceProductSet ProductDocument2 = Product2.ParentSet Product2Products = Product2.ProductsSet Product1Dot1 = Product2Products.Item(“Product1.1”) : Set Product1 = Product1Dot1.ReferenceProductSet ProductDocument1 = Product1.ParentSet Product1Products = Product1.ProductsSet Part1Dot1 = Product1Products.Item(“Part1.1”) : Set Part1 = Part1Dot1.ReferenceProductSet PartDocument1 = Part1.ParentSet Selection = ActiveProductDocument.SelectionAnother Selection object, such as:Set ProductDocument2Selection = ProductDocument2.SelectionSet ProductDocument1Selection = ProductDocument1.SelectionSet PartDocument1Selection = PartDocument1.Selection(lets take ProductDocument2Selection for example) can only be used if, amongthe different Window , there is at least one whose root Document isProductDocument2 . Otherwise, results are unpredictable.- add(i_object: AnyObject) None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub Add(AnyObject iObject)Creates a SelectedElement object which Value property is the givenautomation object, and adds it to the selection.Note: In a product structure aggregating a “Part1 (Part1.1)” Part document,if you double-clic Part1 in the spectification tree:the “Part Design” workbench becomes activethe Part1 node is inside a blue buttonHere, Part1 is the UI Active Object.Some editors, such as CatalogDocument editors, do not possess any UI ActiveObject.When this method is used in a CATAnalysis context, a CATPart (such as Part1in our example) must be UI active. Otherwise, Selection.Add does not workcorrectly (the 3D is not highlighted properly).Role: Creates a SelectedElement object and adds it to the currentselection. Depending on the type of the parent Document of the Selectionobject:if it is one of the following:CATIAPartDocumentCATIADrawingDocumentCATIAMaterialDocumentCATIAAnalysisDocumentCATIAFunctionalDocumentthen, regarding the created SelectedElement , the SelectedElement.Valueproperty will be equal to iObjectOtherwise:first case: the specification tree contains apath:whose leaf node is iObjectthe UI Active Object belongs to the paththen, the method will create a SelectedElement object correspondingto this path.Otherwise: the method will create a SelectedElement objectcorresponding to the first path, in the specification tree, whose leaf node isiLeafNodeExample:This example creates a SelectedElement object, which Value property isthe ObjectToAdd automation object, the SelectedElement being added to thecurrent selection.CATIA.ActiveDocument.Selection.Add(ObjectToAdd)
- Parameters:
i_object (AnyObject) –
- Return type:
None
- clear() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub Clear()Clears the selection.Example:This example clears the selection. The selection is thenempty.CATIA.ActiveDocument.Selection.Clear()
- Return type:
None
- copy() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub Copy()Copies, in a copy and paste operation.Role: Puts the contents of the selection in the clipboard, but leaves theselected elements in the document, and clears the selection. This is theprogramming equivalent of the Copy command from the Editmenu.Note: The method (and the script execution) fails if one of the followingerrors occurs:The CSO is empty. The Copy operation could not beperformed.No CSO element remains after the filtering through the UI activeobject. The Copy operation could not be performed.Note: If a selected feature is not exposed to automation, it will be copiedinto the clipboard all the way.Example:This example copies, in a copy and paste operation. A selected DMUNavigator URL will be put into the clipboard although it is not exposed toautomation.CATIA.ActiveDocument.Selection.Copy()
- Return type:
None
- property count: int¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384)
- o Property Count() As long (Read Only)Deprecated:V5R16 #Count2 . The Count and Item Methods have been replaced by theCount2 and Item2 methods because they did not process correctly features whichare not exposed to automation (such as a ResourcesList feature of a .CATProcessdocument).
- Return type:
int
- property count2: int¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384)
- o Property Count2() As long (Read Only)Returns the number of SelectedElement objects contained by the currentselection.Role: This method returns the number of SelectedElement objects containedby the Selection. The Value property of a given SelectedElement object is anautomation object associated to a selected feature.
- Return type:
int
- cut() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub Cut()Cuts, in a cut and paste operation.Role: Puts the contents of the selection in the clipboard, and removes theselected elements from the document, and clears the selection. This is theprogramming equivalent of the Cut command from the Editmenu.Note: The method (and the script execution) fails if one of the followingerrors occurs:The CSO is empty. The Cut operation could not beperformed.No CSO element remains after the filtering through the UI activeobject. The Cut operation could not be performed.Note: If a selected feature is not exposed to automation, it will be copiedinto the clipboard and removed from the document all theway.Example:This example cuts, in a cut and paste opertation. A selected DMUNavigator URL will be put into the clipboard and removed from the document,although it is not exposed to automation.CATIA.ActiveDocument.Selection.Cut()
- Return type:
None
- delete() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub Delete()Deletes all selected objects.Role: For all the SelectedElement objects contained by the selection, theSelectedElement.Value automation object is deleted from thedocument.Note: If a selected feature is not exposed to automation, it will deletedall the way.Example:This example deletes all the selected objects. A selected DMU NavigatorURL will be removed from the document, although it is not exposed toautomation.CATIA.ActiveDocument.Selection.Delete()
- Return type:
None
- filter_correspondence(i_filter_type: tuple) bool ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func FilterCorrespondence(CATSafeArrayVariant iFilterType) AsbooleanSpecifies if the automation objects appearing as Value property ofSelectedElement objects fit a given filter.Role: FilterCorrespondence filters the selection with respect to providedautomation types. The use of this method coupled with the use of theSelectElement2 will enable to offer a multi-selection written programmatically,which is the common way to write multi-selection is CATIA.It will enable, for example, to write a script reproducing thefunctionalities of the “Fillet” command of the “Part Design”workbench.This method, called before a loop onto SelectElement2 calls, will enable ifall the selection objects correspond to the filter (which will be the same asthe filter given to SelectElement2 ), to take them into account, and,otherwise, to clear the selection.This multi-selection written programmatically will generally be usedcoupled with the fact that already selected elements remain selected during theselections.Parameters:iFilterTypeAn array of strings constants to be used as a filter for the kindof element to which current selection object must correspond. See theiFilterType parameter of theSelectElement2 method.oAllFitAll current selection objects fit the iFilterType filter, i.e.regarding each of the current selection objects, they all fit one of theiFilterType string constant.Example:The following example scripts an edge fillet creation command. Itsupposes that a part is currently edited,containing a Pad. It loops onto the following:it asks the end user to select an edge (seeTriDimFeatEdge ). If the selected edge has not already been selected, theselected edge is added to the selection, otherwise it is removed from theselectionit asks the end user if another edge has to be selecteduntil the answer of the user to the preceding question isno.Then, it creates an edge fillet (see ConstRadEdgeFillet ) taking intoaccount all the selected edges as fillet specifications.Note: The edges which were selected before the script execution are takeninto account. Nevertheless, if, before the script execution, the selectioncontained an object which was not a TriDimFeatEdge element, the selection iscleared before the first selection proposal.Note: During the selection of a given edge, the edges already selectedremain highlighted.Dim Document,Part,Selection,ShapeFactory,EdgeSaveAllocatedCount,EdgeIndex,AllEdgesHaveBeenSelected,AllFitDim EdgeSaveCount,SelectedEdge,SelectedElementBelongsToSaveVariables,AlreadySelectedEdgeIndexDim OtherEdgeAnswer,FilletSet Document = CATIA.ActiveDocument : Set Part = Document.Part: Set Selection = Document.SelectionSet ShapeFactory = Part.ShapeFactoryReDim InputObjectType(0) : InputObjectType(0)=”TriDimFeatEdge” : EdgeSaveCount = 0‘We determine if the selection contains an object which is not aTriDimFeatEdge elementAllFit = Selection.FilterCorrespondence(InputObjectType)‘If the selection contains an object which is not a TriDimFeatEdge element,we clear the selectionif (Not AllFit) then Selection.ClearEdgeSaveAllocatedCount = Selection.Count+10 : ReDim EdgeSave(EdgeSaveAllocatedCount-1)‘We loop onto interactive selectionsAllEdgesHaveBeenSelected = falsedo while (Not AllEdgesHaveBeenSelected)‘ We save the selection content in save variables.‘ This corresponds to the fact that:‘ - we want that, during the following call to SelectElement2, theTriDimFeatEdge elements previously selected‘ remain highlighted‘ - this is done using the False value for theiObjectSelectionBeforeCommandUsePossibility‘ parameter of the SelectElement2 method, the selection containing theTriDimFeatEdge elements. It requires that‘ the selection content be savedif (EdgeSaveAllocatedCount < Selection.Count) thenEdgeSaveAllocatedCount = EdgeSaveAllocatedCount + 10: ReDim EdgeSave(EdgeSaveAllocatedCount-1)end iffor EdgeIndex = 0 to Selection.Count2-1Set EdgeSave(EdgeIndex) = Selection.Item2(EdgeIndex+1).ValuenextEdgeSaveCount = Selection.Count‘ We propose to the user that he select an edgeStatus=Selection.SelectElement2(InputObjectType,”Select anedge”,false)if (Status=”Cancel”) thenSelection.Clear : Exit Subend if‘ We save the selected edge in a dedicated variableSet SelectedEdge = Selection.Item2(1).Value‘ We merge the selected element with the save variables, and put theresult in the selection.‘ At first, we determine if the selected edge already belongs to theEdgeSave arrayEdgeIndex = 0 : SelectedElementBelongsToSaveVariables = Falsedo while ((EdgeIndex < EdgeSaveCount) And (NotSelectedElementBelongsToSaveVariables))if (EdgeSave(EdgeIndex).Name=SelectedEdge.Name)thenSelectedElementBelongsToSaveVariables = TrueAlreadySelectedEdgeIndex = EdgeIndexend ifEdgeIndex = EdgeIndex + 1loop‘ Effective mergeif (Not SelectedElementBelongsToSaveVariables) then‘ The selected element does not belong to the save variables. We addthe save variables to the selectionfor EdgeIndex = 0 to EdgeSaveCount-1Selection.Add EdgeSave(EdgeIndex)nextelse‘ We remove the selected element from the savevariablesfor EdgeIndex = AlreadySelectedEdgeIndex to EdgeSaveCount-2Set EdgeSave(EdgeIndex) = EdgeSave(EdgeIndex+1)nextEdgeSaveCount = EdgeSaveCount - 1‘ We clear the selectionSelection.Clear‘ We add the save variables to the selectionfor EdgeIndex = 0 to EdgeSaveCount -1Selection.Add EdgeSave(EdgeIndex)nextend if‘ We ask the end user if another edge has to be selectedOtherEdgeAnswer = msgbox (“do you want to select another edge?”,3,”Edge Fillet Definition”)if (OtherEdgeAnswer = 2) then Exit Subif (OtherEdgeAnswer = 7) then AllEdgesHaveBeenSelected = trueloop‘We create an edge fillet taking into account all the selected edges asfillet specificationsif (Selection.Count > 0) thenSet Fillet = ShapeFactory.AddNewEdgeFilletWithConstantRadius(Selection.Item(1).Value, 1, 5.0)Fillet.EdgePropagation = 1for EdgeIndex = 2 to Selection.CountFillet.AddObjectToFilletSelection.Item(EdgeIndex).ValuenextPart.Update : Selection.Clear : Selection.Add Filletend if
- Parameters:
i_filter_type (tuple) –
- Return type:
bool
- find_object(i_object_type: str) AnyObject ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func FindObject(CATBSTR iObjectType) As AnyObjectFinds an object in the current selection and deletes it from theselection.Role: Determines the first automation object specified inSelectedElement.Value (for the SelectedElement objects contained in the currentselection), or which is a Parent (see AnyObject.Parent ) of the automationobject specified in SelectedElement.Value , which type is equal to the typespecified in input. It returns directly the automation object and deletes thecorresponding SelectedElement object from the currentselection.Note: If the string specified in input is he “CATIAProduct” string, thepossible automation object specified in SelectedElement.LeafProduct is alsolooked at.Example:This example searches a Pad object in the current selection and puts itinto FoundObject.Dim FoundObject As AnyObjectSet FoundObject = CATIA.ActiveDocument.Selection.FindObject(“CATIAPad”)
- Parameters:
i_object_type (str) –
- Return type:
- indicate_or_select_element_2d(i_message: str, i_filter_type: tuple, i_object_selection_before_command_use_possibility: bool, i_tooltip: bool, i_triggering_on_mouse_move: bool) str ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func IndicateOrSelectElement2D(CATBSTR iMessage,CATSafeArrayVariant iFilterType,boolean iObjectSelectionBeforeCommandUsePossibility,boolean iTooltip,boolean iTriggeringOnMouseMove,boolean oObjectSelected,CATSafeArrayVariant oDocumentWindowLocation) As CATBSTRRuns an interactive command enabling both indication and selection, 2Dversion.Role: IndicateOrSelectElement2D asks the end user to select either alocation into the window, or a feature (in the geometry or in the specificationtree).During execution, when entering this method, the active document must be a2D document. See Document.Indicate2D and SelectElement3Parameters:iMessageA string which instructs the user that he must select a locationinto the document window or select an object.iFilterTypeAn array of strings constants defining the automation object typeswith which the selection will be filtered.iObjectSelectionBeforeCommandUsePossibilityEnables the script to support the possibility, for the user, toselect a required object before running the script. SeeSelectElement2 .iTooltipDisplays a tooltip as soon as an object is located under the mousewithout being selected.iTriggeringOnMouseMoveTriggers as soon as a mouse move event is detected. This option beeingset, oOutputState may be valued to “MouseMove”.oObjectSelectedFlag précising if the user choosed the selection or the indication.oDocumentWindowLocationAn array made of 2 doubles: X, Y - coordinates array of the locationthe user specified in the document window. This parameter is valuated only ifoObjectSelected equals to false.oOutputStateThe state of the interactive command once IndicateOrSelectElement2Dreturns. The possible values are the same than the values described regardingthe oOutputState parameter of the SelectElement2 method, except that the“MouseMove” value can also be returned.Example:The following example suppose a drawing is currently edited. Itcreates a point (seePoint2D ), and asks the end user to click to define the circlecenter.When it is done, as the mouse moves without clicking the left button, thescript determines the location into the drawing window, and the script createsa temporary circle as a feedback.A click into the document window or the selection of a point createsdefinitively the circle (see Circle2D ) located at the specified location(whether the location is a location into the drawing window or whether it isthe existing point location).Dim Document,Selection,DrawingSheets,DrawingSheet,DrawingViews,WindowLocation(1),DrawingView,Factory2D,Radius,Circle2DDim HardCodedPoint,Status,XCenter,YCenter,InputObjectType(0),TempCircleHasBeenCreatedAtLeastOnce,ExistingPointDim ObjectSelectedSet Document = CATIA.ActiveDocument : Set Selection = Document.Selection: Set DrawingSheets = Document.SheetsSet DrawingSheet = DrawingSheets.ActiveSheet : Set DrawingViews = DrawingSheet.ViewsSet DrawingView = DrawingViews.ActiveView : Set Factory2D = DrawingView.Factory2D‘We create a pointSet HardCodedPoint = Factory2D.CreatePoint(700.,400.)HardCodedPoint.ReportName = 1 : HardCodedPoint.Construction = False‘We propose to the user to click to define the circlecenterStatus=Document.Indicate2D(“click to define the circlecenter”,WindowLocation)if (Status = “Cancel” Or Status = “Undo” Or Status = “Redo”) then Exit SubXCenter = WindowLocation(0) : YCenter = WindowLocation(1)‘We propose to the user that he specify a location into the drawing windowor a pointInputObjectType(0)=”Point2D”Status = “MouseMove” : TempCircleHasBeenCreatedAtLeastOnce = 0Status=Selection.IndicateOrSelectElement2D(“select a point or click to locate the circle radius point”, _InputObjectType,false,false,true, _ObjectSelected,WindowLocation)‘ We loop onto mouse moves without clickdo while (Status = “MouseMove”)if (TempCircleHasBeenCreatedAtLeastOnce) thenSelection.Add Circle2D : Selection.Deleteend ifRadius = Sqr(((WindowLocation(0)-XCenter)*(WindowLocation(0)-XCenter))+ _((WindowLocation(1)-YCenter)*(WindowLocation(1)-YCenter)))Set Circle2D = Factory2D.CreateClosedCircle(XCenter,YCenter,Radius)TempCircleHasBeenCreatedAtLeastOnce = 1Status=Selection.IndicateOrSelectElement2D(“select a point or click tolocate the circle radius point”, _InputObjectType,false,false,true, _ObjectSelected,WindowLocation)loop‘We go out if necessaryif (Status = “Cancel” Or Status = “Undo” Or Status = “Redo”) thenif (TempCircleHasBeenCreatedAtLeastOnce) thenSelection.Add Circle2D : Selection.Add HardCodedPoint : Selection.Deleteend ifExit Subend if‘We determine the possible selected point coordinatesif (ObjectSelected) thenSet ExistingPoint = Selection.Item2(1).Value : ExistingPoint.GetCoordinates WindowLocation: Selection.Clearend if‘We clean-up the temporary circleif (TempCircleHasBeenCreatedAtLeastOnce) thenSelection.Add Circle2D : Selection.Deleteend if‘We create the circleRadius = Sqr(((WindowLocation(0)-XCenter)*(WindowLocation(0)-XCenter))+ _((WindowLocation(1)-YCenter)*(WindowLocation(1)-YCenter)))Set Circle2D = Factory2D.CreateClosedCircle(XCenter,YCenter,Radius) : Selection.Add Circle2D
- Parameters:
i_message (str) –
i_filter_type (tuple) –
i_object_selection_before_command_use_possibility (bool) –
i_tooltip (bool) –
i_triggering_on_mouse_move (bool) –
o_object_selected (bool) –
o_document_window_location (tuple) –
- Return type:
str
- indicate_or_select_element_3d(i_planar_geometric_object: AnyObject, i_message: str, i_filter_type: tuple, i_object_selection_before_command_use_possibility: bool, i_tooltip: bool, i_triggering_on_mouse_move: bool) tuple ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func IndicateOrSelectElement3D(AnyObjectiPlanarGeometricObject,CATBSTR iMessage,CATSafeArrayVariant iFilterType,boolean iObjectSelectionBeforeCommandUsePossibility,boolean iTooltip,boolean iTriggeringOnMouseMove,boolean oObjectSelected,CATSafeArrayVariant oWindowLocation2D,CATSafeArrayVariant oWindowLocation3D) As CATBSTRRuns an interactive command enabling both indication and selection, 3Dversion.Role: IndicateOrSelectElement3D asks the end user to select either alocation into the window, or a feature (in the geometry or in the specificationtree).During execution, when entering this method, the active document must be a3D document. See Document.Indicate3D and SelectElement3Parameters:iPlanarGeometricObjectA planar geometric object.iMessageA string which instructs the user that he must select a locationinto the document window or select an object.iFilterTypeAn array of strings constants defining the automation object typeswith which the selection will be filtered.iObjectSelectionBeforeCommandUsePossibilityEnables the script to support the possibility, for the user, toselect a required object before running the script. SeeSelectElement2 .iTooltipDisplays a tooltip as soon as an object is located under the mousewithout being selected.iTriggeringOnMouseMoveTriggers as soon as a mouse move event is detected. This option beingset, oOutputState may be valued to “MouseMove”.oObjectSelectedFlag precising if the user chose the selection or the indication.oWindowLocation2DX, Y - coordinates array of the location the user specified into thedocument window. This parameter is valuated only if oObjectSelected equals tofalse.oWindowLocation3DX, Y, Z - coordinates array of the location the user specified in thedocument window. This parameter is valuated only if oObjectSelected equals tofalse.oOutputStateThe state of the interactive command once IndicateOrSelectElement3Dreturns. The possible values are the same than the values described regardingthe oOutputState parameter of the SelectElement2 method, except that the“MouseMove” value can also be returned.Example:The following example suppose a part is currently edited, containinga plane. It creates a point(seeHybridShapePointOnPlane ), asks the end user to select a location into thepart window, onto the Plane.1 plane, or to select a point.As the mouse moves without clicking the left button, the location into thedrawing window is determined, and the script creates a temporary point as afeedback.A click into the document window or the selection of a point createsdefinitively the point (see HybridShapePointOnPlane ) located at the specifiedlocation (whether the location is a location into the part window or whether itis the existing point location).Dim Document,Part,HybridShapeFactory,Selection,Body,HybridShapePlane,PlaneReference,HardCodedPoint,PointDim InputObjectType(0),WindowLocation2D(1),WindowLocation3D(2),TempPointHasBeenCreatedAtLeastOnce,StatusDim ObjectSelected,ExistingPointSet Document = CATIA.ActiveDocument : Set Part = Document.PartSet HybridShapeFactory = Part.HybridShapeFactory : Set Selection = Document.SelectionSet Body = Part.Bodies.Item(“PartBody”)Set HybridShapePlane = Body.HybridShapes.Item(“Plane.1”)Set PlaneReference = Part.CreateReferenceFromObject(HybridShapePlane)‘We create a pointSet HardCodedPoint = HybridShapeFactory.AddNewPointOnPlane(PlaneReference,30.,30.)Body.InsertHybridShape HardCodedPoint : Part.InWorkObject = HardCodedPoint : Part.Update‘We propose to the user that he specify a location into the part window ora pointInputObjectType(0)=”HybridShapePointOnPlane”Status = “MouseMove” : TempPointHasBeenCreatedAtLeastOnce = 0 : Selection.ClearStatus=Selection.IndicateOrSelectElement3D(HybridShapePlane,”select apoint or click to locate the point”, _InputObjectType,false,false,true, _ObjectSelected,WindowLocation2D,WindowLocation3D)‘ We loop onto mouse moves without clickdo while (Status = “MouseMove”)if (TempPointHasBeenCreatedAtLeastOnce) thenSelection.Add Point : Selection.Deleteend ifSet Point = HybridShapeFactory.AddNewPointOnPlane(PlaneReference,WindowLocation2D(0),WindowLocation2D(1))Body.InsertHybridShape Point : Part.InWorkObject = Point : Part.UpdateTempPointHasBeenCreatedAtLeastOnce = 1Status=Selection.IndicateOrSelectElement3D(HybridShapePlane,”select apoint or click to locate the point”, _InputObjectType,false,false,true, _ObjectSelected,WindowLocation2D,WindowLocation3D)loop‘We go out if necessaryif (Status = “Cancel” Or Status = “Undo” Or Status = “Redo”) thenif (TempPointHasBeenCreatedAtLeastOnce) thenSelection.Add Point : Selection.Add HardCodedPoint : Selection.Delete : Part.Updateend ifExit Subend if‘We determine the possible selected point coordinatesif (ObjectSelected) thenSet ExistingPoint = Selection.Item2(1).ValueWindowLocation2D(0) = ExistingPoint.XOffset.ValueWindowLocation2D(1) = ExistingPoint.YOffset.ValueSelection.Clearend if‘We clean up the temporary pointif (TempPointHasBeenCreatedAtLeastOnce) thenSelection.Add Point : Selection.Deleteend if‘We create the pointSet Point = HybridShapeFactory.AddNewPointOnPlane(PlaneReference,WindowLocation2D(0),WindowLocation2D(1))Body.InsertHybridShape Point : Part.InWorkObject = Point : Part.Update
- Parameters:
i_planar_geometric_object (AnyObject) –
i_message (str) –
i_filter_type (tuple) –
i_object_selection_before_command_use_possibility (bool) –
i_tooltip (bool) –
i_triggering_on_mouse_move (bool) –
- Return type:
str
- item(i_index: int) SelectedElement ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func Item(long iIndex) As SelectedElementDeprecated:V5R16 #Item2 . The Count and Item Methods have been replaced by theCount2 and Item2 methods because they did not process correctly features whichare not exposed to automation (such as a ResourcesList feature of a .CATProcessdocument).
- Parameters:
i_index (int) –
- Return type:
- item2(i_index: int) SelectedElement ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Func Item2(long iIndex) As SelectedElementReturns the iIndex-th SelectedElement object contained by the currentselection.Role: Returns the iIndex-th SelectedElement object contained by the currentSelection. The Value property of the SelectedElement object is an automationobject associated to a selected feature.Parameters:iIndexThe index of theSelectedElement object to return, 1≤iIndex≤Selection.Count2 .oSelectedElementThe SelectedElement objectExample:See theSelectElement3 method first example.
- Parameters:
i_index (int) –
- Return type:
- items()¶
- Returns:
[self.child_object()]
- paste() None ¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))
- o Sub Paste()Puts the contents of the clipboard in the document at the indicatedlocation.Role: After the execution of the Paste method, there may be, among thepasted features, some which are not exposed to automation. If the selectedfeature after which the clipboard must be pasted is not exposed to automation,the Paste will be done all the way.Note: The method (and the script execution) fails if one of the followingerrors occurs:The CSO is empty. The Paste operation could not beperformed.No CSO element remains after the filtering through the UI activeobject. The Paste operation could not be performed.Example:This example pastes, in a cut, or copy, and paste operation. A selectedDMU Navigator URL will be put into the clipboard and removed from the document,although it is not exposed to automation.CATIA.ActiveDocument.Selection.Paste()
- Return type:
None
- paste_special(i_format: str) None ¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Sub PasteSpecial(CATBSTR iFormat)Puts the contents of the clipboard in the document at the indicatedlocation, according to the specified format.Role: After the execution of the Paste method, there may be, among thepasted features, some which are not exposed to automation. If the selectedfeature after which the clipboard must be pasted is not exposed to automation,the Paste will be done all the way.Note: The method (and the script execution) fails if one of the followingerrors occurs:The CSO is empty. The PasteSpecial operation could not beperformed.No CSO element remains after the filtering through the UI activeobject. The PasteSpecial operation could not beperformed.Formats are:In all the containers“CATIA_LINK_FORMAT” to paste “Catia Link Source”,“OLE_LINK_FORMAT” to paste “Ole Link Source”,“OLE_EMBED_FORMAT” to paste “Ole Embed Source”.In a Part container“CATPrtCont” to paste “As Specified In Part Document”,“CATPrtResultWithOutLink” to paste “AsResult”,“CATPrtResult” to paste “AsResultWithLink”,“CATMaterialCont” to paste “As material”,“AsMaterialLink” to paste “As material link”,“CATMechProdCont” to paste “As specified in Assembly”,“CATProdCont” to paste “As specified in ProductStructure”,“CATIA_SPEC” to paste “CATIA_SPEC”,“CATIA_RESULT” to paste “CATIA_RESULT”.In a Product container“CATProdCont” to paste “As specified in ProductStructure”,“CATSpecBreakLink” to paste “Break Link”.In a Process container“SPPProcessCont” to paste “Simple paste”,“SPP_I” to paste “Paste with Items”,“SPP_R” to paste “Paste with Resources”,“SPP_IR” to paste “Paste with Items and Resources”,“SPPI_I” to paste “Paste with Items and entirehierarchy”,“SPPI_R” to paste “Paste with Resources and entirehierarchy”,“SPPI_IR” to paste “Paste with Items and Resources and entirehierarchy”.In a Material container“CATMaterialCont” to paste “As material”,“AsMaterialLink” to paste “As material link”.In a Catalog container“CATDescriptionFormat” to paste “As defined in cataloginstanciation”,“CATCtlgChapterFormat” to paste “As defined in catalogdocument”.In a Rendering Scene container“CATRscLightContainer” to paste “As light”,“CATRscEnvironmentContainer” to paste “Asenvironment”,“CATRscShootingContainer” to paste “As shooting”,“CATRscTurntableContainer” to paste “As turntable”.In a Deneb Resource Program container“DNBProgCont” to paste “Resource Program”.In a Behavior container“Behaviors” to paste “Behaviors”.In a CATCamera container“CATCameraContainer” to paste “Camera”.To know more about those formats, refer to the interactivecommand.Example:This example pastes, in a cut, or copy, and paste special operation. Aselected DMU Navigator URL will be pasted from the clipboard at the specifiedlocation, although it is not exposed to automation.CATIA.ActiveDocument.Selection.PasteSpecial“CATPrtResultWithOutLink”
- Parameters:
i_format (str) –
- Returns:
None
- remove(i_index)¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Sub Remove(long iIndex)Deprecated:V5R16 #Remove2 . This method does the same as the Remove2 method, butit does know how to manage features which are not exposed to automation (suchas a ResourcesList feature of a .CATProcess document).
- Parameters:
i_index (int) –
- Returns:
None
- remove2(i_index)¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Sub Remove2(long iIndex)Removes the iIndex-th SelectedElement object contained by the currentselection.Role: Removes the iIndex-th SelectedElement object contained by the currentselection.Parameters:iIndexThe index of theSelectedElement object to remove, 1≤iIndex≤Selection.Count2.Example:This example removes the second SelectedElement object contained bythe current selection.CATIA.ActiveDocument.Selection.Remove2(2)
- Parameters:
i_index (int) –
- Returns:
None
- search(i_string_bstr)¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Sub Search(CATBSTR iStringBSTR)Finds an object in the document using the Edit/Searchgrammar.Role: Finds an object in the document using the Edit/Search grammar, andfills the selection with the found objects. A criterium is created, based onthe Search grammar, which defines in addition the depth of the investigationfield.Note: After the execution of the Search method, there may be, among theselected features, some which are not exposed toautomation.Example:The following example searches the objects matching the followingcriterium in all the document: Part.Sketcher.Color=’White’ . A selected DMUNavigator URL put into the selection although it is not exposed toautomation.CATIA.ActiveDocument.Selection.Search(“Part.Sketcher.Color=’White’,all”)
- Parameters:
i_string_bstr (str) –
- Return type:
None
- select_element2(i_filter_type: tuple, i_message: str, i_object_selection_before_command_use_possibility: bool) str ¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Func SelectElement2(CATSafeArrayVariant iFilterType,CATBSTR iMessage,boolean iObjectSelectionBeforeCommandUsePossibility) AsCATBSTRRuns an interactive selection command.Role: SelectElement2 asks the end user to select a feature (in the geometryor in the specification tree) in a Window of the active Document . During theselection, when the end user will move the mouse above a feature which maps thegiven filter, the mouse pointer will be the “hand” cursor, and when end userwill move the mouse above a feature which does not map the given filter, themouse pointer will be the “no entry” cursor.If iObjectSelectionBeforeCommandUsePossibility is equal toFalse:The end user is asked to interactively select an appropriate element.When this is done, the Selection object is cleared, and filled with theselected element.If iObjectSelectionBeforeCommandUsePossibility is equal toTrue:SelectElement2 determines whether the automation objects specified inSelectedElement.Value, for the SelectedElement objects contained in the currentselection, or one of the parents of the automation objects (seeAnyObject.Parent ) is an appropriate element:If it is the case, no interaction is asked to the end user, theSelection object is cleared, and filled with the appropriateelement.Otherwise, the Selection object is cleared, and the end user isasked to interactively select an appropriate element. When this is done, theselection is filled with the selected element.Note: The Selection object on which the Selection.SelectElement2 methodmust be called must be the Selection object obtained the followingway:determine the active document, for example, in the followingcase:Product3!+- Product2 (Product2.1)! !! ! +———————+! +-!Product1 (Product1.1)!! +———-+———-+! !! +- Part1 (Part1.1)! !! +- Part1! !! +- PartBody! !+——————+! +- Pad.1 !Selected feature !! !+——————+! +- Sketch.1+- Part2 (Part2.1)it will be Product3call the Document.Selection property onto thisdocumentOtherwise, results are unpredictable. Note: During the selection scanto find an automation object, a “Product” string constant specified iniFilterType will imply that SelectElement2 will also look at the possibleautomation object specified in SelectedElement.LeafProduct.After a call to SelectElement2, if the return value equals to “Normal”, acall to the Count2 method will return one, and a call to Item2(1) will returnthe selected element.Note: If the scripting language is Visual Basic for Applications or VisualBasic 6 Development Studio, then, you have to know that the use of aninteractive selection method such as this one from a form (dialog box) methodrequires some constraints regarding the content of an average formmethod.If your macro possess a form method which calls the SelectElement2 method,then, the content of an average form method of your macro must begin by a test,which checks that no form method is currently being executed and, otherwise, goout of the method. This constraint enable to prevent that, during the executionof the SelectElement2 method from a form method, when CATIA asks the end userto select a feature:the users select a dialog object of a form (CATIA going on asking theend user to select a feature)this selection trigger the corresponding form methodthis run CATIA automation objects methods, CATIA going on asking theend user to select a featurewhich would lead to unpredictable results.The code will be the following way:- macro module main variables:Dim AFormMethodIsBeingExecuted As Boolean- form method calling SelectElement2:Private SubFormPossessingOneMethodCallingSelectElement2_Click()Dim InputObjectType(0), StatusAFormMethodIsBeingExecuted = TrueInputObjectType(0)=”TriDimFeatEdge”Status=Selection.SelectElement2(InputObjectType,”Select anedge”,false)AFormMethodIsBeingExecuted = FalseEnd Sub- average form method:Private Sub AverageForm_Click()If (AFormMethodIsBeingExecuted) Then Exit Sub…‘ content of the form method itself…End SubParameters:iFilterTypeAn array of strings constants defining the automation object typeswith which the selection will be filtered. During the selection, when the enduser will move the mouse (above the geometry or the specification tree), if thefeature under the mouse does not map iFilterType, the cursor will be the “noentry” cursor.The resulting filter is a logical OR of the supplied stringsconstants. For instance if the array contains two elements “Point” and “Line”,when the end user will move the mouse above the geometry, if there is a featureunder a mouse, which is aHybridShapePointCoord object (you have to know that the Point object isa parent object of the HybridShapePointCoord object ), then, the cursor will bea “hand” cursor. At the opposite, if there is a feature under a mouse, which isneither a Point nor a Line, the cursor will be a “no entry”cursor.Beside the automation object names, the CATSelectionFilter value namesare supported.iMessageA string which instructs the user what to select. This string isdisplayed in the message area located at the left of the power input area.iObjectSelectionBeforeCommandUsePossibilityEnables the script to support the possibility, for the user, to selecta required object before running the script.If the scripter:writes a script calling SelectElement2, giving as iFilterTypeparameter an array containing one string: “Pad”for the first call to SelectElement2 made by the script, theiObjectSelectionBeforeCommandUsePossibility is set toTruethe scripter associates the script to an Icon. He will proceed asfollowing:in the Tools menu, select the Customize item. A windowappears.select the Commands Tab. The window contains twolists.in the list on the left, select the Macrosvalueselect the “Show Properties” push buttonselect the button on the right of the Icon label. A windowcontaining a list of icons appearsselect an Iconselect the Close button. The window containing the icon listdisappearsin the list on the right, push the key 1 of the mouse, thecursor beeing on the macro to associate to an Icon. Then drag to a desiredToolbar. The Icon has been added to theToolbar.Then the user will be able to implement the followingscenario:select a Padselect the Icon mentioned above. This runs thescript.During the execution of the script, the script will detect that theselected Pad is required as input, and the first call to SelectElement2 willnot ask to the user to interactively select a Pad: the Pad selected before thescript execution will be taken.Note:Regarding the features selected by the user (a Pad in the exampleabove), all the automation objects specified in SelectedElement.Value for thecurrent selection SelectedElement objects must be used: if an automation objectspecified in SelectedElement.Value is not asked by the input filter, theSelectElement2 method will ask the user to interactively select an appropriateelement.A False value for the iObjectSelectionBeforeCommandUsePossibility parametermay be used although the selection is not empty before entering the method.This enables that, during the selection, the selected elements remainhighlighted.Caution: After a call to SelectElement2 , theiObjectSelectionBeforeCommandUsePossibility parameter being set to False, theelements which were selected before the call to SelectElement2 are not any morein the selection (unless the user selected one of them!). Consequently, such ause of the False value for the iObjectSelectionBeforeCommandUsePossibilityparameter requires the following code:save the selection content in save variablescall the SelectElement2 method, theiObjectSelectionBeforeCommandUsePossibility parameter being set toFalsecopy the selected element to a dedicated variablemerge the selected element with the save variables, and put the resultin the selection. This mean:if the selected element does not belong to the save variables, addthe save variables to the selectionotherwise, remove the selected element from the save variables,clear the selection and then, add the save variables to theselectionoOutputStateThe state of the selection command once SelectElement2 returns. It canbe either “Normal” (the selection has succeeded), “Cancel” (the user wants tocancel the VB command, which must exit immediately), “Undo” or“Redo”.Note:The “Cancel” value is returned if one of the following casesoccured:an external command has been selectedthe ESCAPE key has been selectedanother window has been selected, the window document beeinganother document than the current documentCaution:All scripts should exit (after the necessary cleanings) whenthe “Cancel” value is returned.If the script does not exit (beside the cleanings) when the “Cancel”value is returned, but calls another interactive method such as SelectElement2, and, during execution, the user select an external command (which triggersthe return of the “Cancel” value), then, the execution of the other interactivemethod will display an error message.Example:The following example asks the end user to select a sketch (seeSketch ) in the current window, and creates a Pad (seeShapeFactory.AddNewPad ). If, before the script execution, a sketch was alreadyselected, it will be taken into account and the end user will ne be asked toselect a sketch.Then, it asks the end user to select an edge of the pad, and creates anedge fillet. Then, is asks the end user to select a 1-D entity whose geometryis rectilinear (see CATSelectionFilter ), such as an edge of thePad.Then, it asks the end user to select a pad face perpendicular to the 1-Dentity previously selected. Then, it creates a hole at the face selected point,the hole direction being the direction of the 1-D selectedentity.During the face selection, the 1-D entity previously selected ishighlighted.Dim Document,Part,Selection,ShapeFactory,SketchHasBeenAcquiredAtLeastOnce,EdgeHasBeenAcquiredAtLeastOnceDim FaceHasBeenAcquiredAtLeastOnce,MonoDimEntityHasBeenAcquiredAtLeastOnce,FirstExtrudeNotFinished,FilletEdgeDim PadNotFinished,Status,SketchForPad,Pad,FilletNotFinished,Fillet,MonoDimEntityDeterminationNotFinishedDim SelectedElement,MonoDimEntity,HoleNotFinished,PadFace,Hole,InputObjectType(0),HoleLocation(2),MonoDimEntitySaveDim SketchForPadPartBodySet Document = CATIA.ActiveDocument : Set Part = Document.PartSet Selection = Document.SelectionSet ShapeFactory = Part.ShapeFactorySketchHasBeenAcquiredAtLeastOnce = False : EdgeHasBeenAcquiredAtLeastOnce = FalseFaceHasBeenAcquiredAtLeastOnce = False : MonoDimEntityHasBeenAcquiredAtLeastOnce = FalseFirstExtrudeNotFinished = True : PadNotFinished = True : ReDim SelectionAtBeginning(1)‘We save the current selection contentReDim SelectionAtBeginning(Selection.Count2)for SelectionObjectIndex = 0 to Selection.Count2-1Set SelectionAtBeginning(SelectionObjectIndex) = Selection.Item2(1).ValuenextSelectionAtBeginningLength = Selection.Count2‘Feature creationdo while PadNotFinished‘ We propose to the user that he select a sketchInputObjectType(0)=”Sketch”Status=Selection.SelectElement2(InputObjectType,”Select asketch”,true)if ((Status = “Cancel”) Or (Status = “Undo”)) then‘ We restore the selection to its initial contentSelection.Clearfor SelectionObjectIndex = 0 to SelectionAtBeginningLength-1Selection.AddSelectionAtBeginning(SelectionObjectIndex)nextExit Subelseif (Status = “Redo” And Not SketchHasBeenAcquiredAtLeastOnce ) then‘ We do nothing: Redo has no meaning in this contextelseif (Status <> “Redo”) then Set SketchForPad = Selection.Item2(1).ValueSketchHasBeenAcquiredAtLeastOnce = True‘ We determine the PartBody corresponding to theSketchSet SketchForPadPartBody = SketchForPad.Parent.Parent‘ We create the PadSet Pad = ShapeFactory.AddNewPad(SketchForPad,20.0)Pad.SecondLimit.Dimension.Value = 0.0 : Part.UpdatePadNotFinished = FalseSelection.Clear‘ We create the fillet and the holeFilletNotFinished = Truedo while (FilletNotFinished And NotPadNotFinished)‘ We propose to the user that he select an edgeInputObjectType(0)=”TriDimFeatEdge”Status=Selection.SelectElement2(InputObjectType,”Select anedge of the Pad”,false)if (Status = “Cancel”) then‘ We remove the pad, restore the selection to its initialcontent and go outSelection.Clear : Selection.Add(Pad) : Selection.DeletePart.UpdateSelection.Clearfor SelectionObjectIndex = 0 to SelectionAtBeginningLength-1Selection.Add SelectionAtBeginning(SelectionObjectIndex)nextExit Subelseif (Status = “Redo” And Not EdgeHasBeenAcquiredAtLeastOnce ) then‘ We do nothing: Redo has no meaning in thiscontextelseif (Status = “Undo”) then‘ We copy the sketch to the clipboardSelection.Clear : Selection.Add(SketchForPad)‘ We remove the padSelection.Clear : Selection.Add(Pad) : Selection.Delete : Part.Update‘ We re-create the sketchSelection.Clear : Selection.Add(SketchForPadPartBody) : Selection.Paste()‘ We store the fact that the Pad is not finishedPadNotFinished = Trueelseif (Status <> “Redo”) then Set FilletEdge = Selection.Item2(1).ValueEdgeHasBeenAcquiredAtLeastOnce = True‘ Create the FilletSet Fillet = ShapeFactory.AddNewSolidEdgeFilletWithConstantRadius(FilletEdge,catTangencyFilletEdgePropagation,5.0)Part.UpdateFilletNotFinished = FalseSelection.Clear‘ Determine the 1-D entityMonoDimEntityDeterminationNotFinished = Truedo while (MonoDimEntityDeterminationNotFinished And NotFilletNotFinished)‘ We propose to the user that he select 1-D entity whosegeometry is rectilinearInputObjectType(0)=”RectilinearMonoDim”Status=Selection.SelectElement2(InputObjectType, _“Select a 1-D entitywhose geometry is rectilinear”,false)if (Status = “Cancel”) then‘ We remove the fillet, the pad, restore the selectionto its initial content and go outSelection.Clear : Selection.Add(Fillet) : Selection.DeleteSelection.Clear : Selection.Add(Pad) : Selection.DeletePart.UpdateSelection.Clearfor SelectionObjectIndex = 0 to SelectionAtBeginningLength-1Selection.Add SelectionAtBeginning(SelectionObjectIndex)nextExit Subelseif (Status = “Redo” And Not MonoDimEntityHasBeenAcquiredAtLeastOnce )then‘ We do nothing: Redo has no meaning in this contextelseif (Status = “Undo”) then‘ We remove the filletSelection.Clear : Selection.Add(Fillet) : Selection.DeletePart.UpdateFilletNotFinished = Trueelseif (Status = “Redo”) thenSelection.Clear : Selection.Add(MonoDimEntity)elseSet SelectedElement = Selection.Item2(1)Set MonoDimEntity = SelectedElement.Valueend ifMonoDimEntityHasBeenAcquiredAtLeastOnce = TrueMonoDimEntityDeterminationNotFinished = False‘ Create the HoleHoleNotFinished = Truedo while (HoleNotFinished And Not MonoDimEntityDeterminationNotFinished)‘ We save the selection content in savevariables.‘ This corresponds to the factthat:‘ - we want that, during the following call toSelectElement2, the 1-D entity previously‘ selected remain highlighted‘ - this is done using the False value for theiObjectSelectionBeforeCommandUsePossibility‘ parameter, the selection containing the 1-Dentity. It requires that the selection‘ content be savedSet MonoDimEntitySave = Selection.Item2(1).Value‘ We propose to the user that he select afaceInputObjectType(0)=”Face”Status=Selection.SelectElement2(InputObjectType, _“Select a faceperpendicular to the 1-D entity”,false)if (Status = “Cancel”) then‘ We remove the fillet, the pad, restore theselection to its initial content and go outSelection.Clear : Selection.Add(Fillet) : Selection.DeleteSelection.Clear : Selection.Add(Pad) : Selection.DeleteSelection.Clearfor SelectionObjectIndex = 0 to SelectionAtBeginningLength-1Selection.Add SelectionAtBeginning(SelectionObjectIndex)nextPart.UpdateExit Subelseif (Status = “Redo” And Not FaceHasBeenAcquiredAtLeastOnce ) then‘ We do nothing: Redo has no meaning in this contextelseif (Status = “Undo”) thenSelection.Clear‘ The 1-D entity must bere-selectedMonoDimEntityDeterminationNotFinished = Trueelseif (Status <> “Redo”) thenSet SelectedElement = Selection.Item2(1)Set PadFace = SelectedElement.ValueSelectedElement.GetCoordinatesHoleLocation‘ We merge the selected element with thesave variables, and put the result in the selectionSelection.AddMonoDimEntitySaveend ifFaceHasBeenAcquiredAtLeastOnce = True‘ We create the HoleSet Hole = Part.ShapeFactory.AddNewHoleFromPoint(HoleLocation(0),HoleLocation(1),HoleLocation(2),PadFace,10.0)Hole.ThreadingMode = 1 : Hole.ThreadSide = 0 :Hole.Diameter.Value = 5.0Hole.SetDirectionFilletEdgePart.UpdateHoleNotFinished = False‘ We clear the selectionSelection.Clearend ifloopend ifloopend ifloopend ifloop
- Parameters:
i_filter_type (tuple) –
i_message (str) –
i_object_selection_before_command_use_possibility (bool) –
- Return type:
str
- select_element3(i_filter_type: tuple, i_message: str, i_object_selection_before_command_use_possibility: bool, i_multi_selection_mode: int, i_tooltip: bool) str ¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Func SelectElement3(CATSafeArrayVariant iFilterType,CATBSTR iMessage,boolean iObjectSelectionBeforeCommandUsePossibility,CATMultiSelectionMode iMultiSelectionMode,boolean iTooltip) As CATBSTRRuns an interactive selection command, exhaustive version.Role: SelectElement3 asks the end user to select a feature (in the geometryor in the specification tree). It is identical to the SelectElement2 methodexcept that it manages complex uses through the specification of 2 moreparameters.Parameters:iFilterTypeAn array of strings constants defining the automation object typeswith which the selection will be filtered.iMessageA string which instructs the user what to select. This string isdisplayed in the message area located at the left of the power input area.iObjectSelectionBeforeCommandUsePossibilityEnables the script to support the possibility, for the user, toselect required object(s) before running the script. SeeSelectElement2 .iMultiSelectionModeThe type of multi-selection which will be offered to the user.iTooltipDisplays a tooltip as soon as an object is located under the mousewithout being selected.oOutputStateThe state of the selection command once SelectElement3 returns. It canbe either “Normal”, “Cancel”, “Undo” or “Redo”. See SelectElement2.Example:This first example asks the end user to select several points (seePoint ) into the current Part window, drawing a trap, and performs asymmetry with respect to the XZ plane on the selected points (seeHybridShapeSymmetry ). The points can be selected before the script berun.Dim Document,Part,Selection,HybridShapeFactory,HybridBodies,HybridBody,OriginElements,Plane,PlaneReference,StatusDim InputObjectType(0),PointIndex,PointReference,HybridShapeSymmetrySet Document = CATIA.ActiveDocument : Set Part = Document.Part :Set Selection = Document.SelectionSet HybridShapeFactory = Part.HybridShapeFactorySet Bodies = Part.BodiesSet Body = Bodies.Item(“PartBody”)Set OriginElements = Part.OriginElementsSet Plane = OriginElements.PlaneZXSet PlaneReference = Part.CreateReferenceFromObject(Plane)‘We propose to the user that he select several points, drawing atrapInputObjectType(0)=”Point”Status=Selection.SelectElement3(InputObjectType,”Select points”,_true,CATMultiSelTriggWhenSelPerf,false)if (Status = “Cancel”) then Exit SubFor PointIndex = 1 to Selection.Count2Set PointReference = Part.CreateReferenceFromObject(Selection.Item2(PointIndex).Value)Set HybridShapeSymmetry = HybridShapeFactory.AddNewSymmetry(PointReference,PlaneReference)HybridShapeSymmetry.VolumeResult = FalseBody.InsertHybridShape HybridShapeSymmetryPart.InWorkObject = HybridShapeSymmetryPart.UpdatenextSelection.ClearExample:This second example illustrates the use of theCATMultiSelTriggWhenUserValidatesSelection value for theiMultiSelectionMode parameter. This example is a training toolenabling the user to learn how to use the “Symmetry”command of the “Geometry Modification” toolbar of the Draftingworkbench.It creates a drawing containing a line and three points, and guidesthe user in:the selection of pointsthe selection of the symmetry axisthe selected points being moved by symmetry according to the selectedaxis.‘We create a drawingSet Documents = CATIA.Documents : Set Document = Documents.Add(“Drawing”): Document.Standard = catISOSet DrawingSheets = Document.Sheets : Set DrawingSheet = DrawingSheets.Item(“Sheet.1”)DrawingSheet.PaperSize = catPaperA0 : DrawingSheet.Scale = 1.000000: DrawingSheet.Orientation = catPaperLandscapeSet DrawingViews = DrawingSheet.Views : Set DrawingView = DrawingViews.ActiveViewSet Factory2D = DrawingView.Factory2D : Set Selection = Document.Selection: Dim Coordinates(2)ReDim InputObjectType(0) : Dim SelectedPoint(3) : SelectedPointCount = 0‘We create a horizontal line with a zero ordinateSet LineLeftExtremity = Factory2D.CreatePoint(-100.0, 0.0): LineLeftExtremity.ReportName = 3Set LineRightExtremity = Factory2D.CreatePoint(100.0, 0.0): LineRightExtremity.ReportName = 4Set Line2D = Factory2D.CreateLine(-100.0, 0.0, 100.0, 0.0) : Line2D.ReportName = 5Line2D.StartPoint = LineLeftExtremity : Line2D.EndPoint = LineRightExtremity‘We create three pointsSet Point2D1 = Factory2D.CreatePoint(-50.0, 50.0): Point2D1.ReportName = 6 : Point2D1.Construction = FalseSet Point2D2 = Factory2D.CreatePoint(0.0, 70.0) : Point2D2.ReportName = 7: Point2D1.Construction = FalseSet Point2D3 = Factory2D.CreatePoint(50.0, 50.0) : Point2D3.ReportName = 8: Point2D3.Construction = False‘We mention to the user that he will select the set of elements to besymmetrizedmsgbox “This tool will enable you to learn how to use the Symmetrycommand.” & Chr(13) & Chr(13) & _“Suppose you selected the Symmetry command.” & Chr(13) & _“You will first select several points to besymmetrized”‘We propose to the user that he select several pointsInputObjectType(0)=”Point2D”Status=Selection.SelectElement3(InputObjectType,”Select the set ofelements to be symmetrized”, _true,CATMultiSelTriggWhenUserValidatesSelection,false)if (Status = “Cancel”) then Exit Sub‘We add the selected points to SelectedPointfor PointIndex = 0 to Selection.Count2-1Set SelectedPoint(PointIndex) = Selection.Item2(PointIndex+1).Value: SelectedPointCount = SelectedPointCount+1next‘We mention to the user that he will select the axis from which theelements will remain equidistantmsgbox “You will then select the line from which the elements willremain equidistant”‘We propose to the user that he select the lineInputObjectType(0)=”Line2D”Status=Selection.SelectElement2(InputObjectType, _“Select the line or axis from whichthe elements will remain equidistant”,false)if (Status = “Cancel”) then Exit Sub‘We move the selected points by symmetry according to the selectedlinefor PointIndex = 0 to SelectedPointCount-1Set CurrentPoint2D = SelectedPoint(PointIndex)CurrentPoint2D.GetCoordinates CoordinatesCurrentPoint2D.SetData Coordinates(0),-Coordinates(1)nextSelection.Clear‘We mention to the user that the points have successfully beenmovedmsgbox “The points have successfully been moved.”
- Parameters:
i_filter_type (tuple) –
i_message (str) –
i_object_selection_before_command_use_possibility (bool) –
i_multi_selection_mode (int) – enum cat_multi_selection_mode
i_tooltip (bool) –
- Return type:
str
- select_element4(i_filter_type: tuple, i_active_document_message: str, i_non_active_document_message: str, i_tooltip: bool, o_document: Document) str ¶
Note
- CAA V5 Visual Basic Help (2020-07-03 17:02:05.216737))
- o Func SelectElement4(CATSafeArrayVariant iFilterType,CATBSTR iActiveDocumentMessage,CATBSTR iNonActiveDocumentMessage,boolean iTooltip,Document oDocument) As CATBSTRRuns an interactive selection command, enabling the selection in a nonactive document.Role: SelectElement4 asks the end user to select a feature (in the geometryor in the specification tree) of a non active document. During the selection,when end user will move the mouse above a window corresponding to a non activedocument, when he will move the mouse above a feature which maps the givenfilter, the mouse pointer will be the “hand” cursor. When he will move themouse above a feature which does not map the given filter, the mouse pointerwill be the “no entry” cursor.This method may be used, for example, to write a script which does thefollowing:a drawing is currently editedrequest that the user select a reference plane in the 3D geometry (apart)creation of a front view in the drawing, projecting the 3D geometryonto the selected reference planeCompared to the SelectElement2 , the result of the selection will not beaccessed through the Count2 and Item2 methods of the current selection object,but through the Count2 and Item2 methods of the Selection object aggregated bythe Document object returned through the oDocumentparameter.Note:The Selection object aggregated by the Document object returnedthrough the oDocument parameter is emptied by before the effective interactiveselection.Parameters:iFilterTypeAn array of strings constants defining the automation object typeswith which the selection will be filtered.iActiveDocumentMessageA string which instructs the user what to select, which will bedisplayed into the active document. This string is displayed in the messagearea located at the left of the power input area.iNonActiveDocumentMessageA string which instructs the user what to select, which will bedisplayed into the non active document.iTooltipDisplays a tooltip as soon as an object is located under the mousewithout being selected.oOutputStateThe state of the selection command once SelectElement3 returns. Itcan be either “Normal”, “Cancel”, “Undo”.Example:The following example supposes a part, containing a pad, and drawingare currently edited, the drawingwindow beeing the current window. It asks the end user to select a 2-Dtopological entity, such as aPlane , in a part. Then it creates a front view in the drawing, projectingthe 3D geometry onto the selected 2-D topological entity.Dim DrawingSelection,DrawingSheets,DrawingSheet,DrawingViews,DrawingFrontViewReDim DrawingSelectionAtBeginning(1)Dim Status,InputObjectType(0),Plane,Drawing,DrawingViewGenerativeBehavior,V1(2),V2(2),PartDocumentSet Drawing = CATIA.ActiveDocument : Set DrawingSelection = Drawing.Selection: Set DrawingSheets = Drawing.SheetsSet DrawingSheet = DrawingSheets.ActiveSheet‘We save the current selection contentReDimDrawingSelectionAtBeginning(DrawingSelection.Count2)for SelectionObjectIndex = 0 to DrawingSelection.Count2-1Set DrawingSelectionAtBeginning(SelectionObjectIndex) = DrawingSelection.Item2(1).ValuenextSelectionAtBeginningLength = DrawingSelection.Count2‘Feature creationInputObjectType(0)=”BiDimInfinite”Status=DrawingSelection.SelectElement4(InputObjectType,”Select a 2-Dtopological entity in a 3-D geometry”, _”Select a 2-D topologicalentity”,false,PartDocument)if ((Status = “Cancel”) Or (Status = “Undo”) Or (Status = “Redo”)) then‘ We restore the selection to its initial contentPartDocument.Selection.Clearfor SelectionObjectIndex = 0 to SelectionAtBeginningLength-1DrawingSelection.AddDrawingSelectionAtBeginning(SelectionObjectIndex)nextExit SubelseSet BiDimFeature = PartDocument.Selection.Item2(1).ValueBiDimFeatureType = TypeName(BiDimFeature)if ((BiDimFeatureType=”Plane”) Or (BiDimFeatureType=”PlanarFace”))thenBiDimFeature.GetFirstAxis V1BiDimFeature.GetSecondAxis V2elseExit Subend if‘ We create a view called “Front View” in the current sheet, using Planeas projection plane, and whose origin‘ coordinates are 300,150Set DrawingFrontView = DrawingSheet.Views.Add(“Front View”)Set DrawingViewGenerativeBehavior = DrawingFrontView.GenerativeBehaviorDrawingViewGenerativeBehavior.Document = PartDocumentDrawingViewGenerativeBehavior.DefineFrontView V1(0), V1(1), V1(2),V2(0), V2(1), V2(2)DrawingFrontView.x = 300DrawingFrontView.y = 150DrawingViewGenerativeBehavior.Update‘ We clear the PartDocument Selection objectPartDocument.Selection.Clearend if
- Parameters:
i_filter_type (tuple) –
i_active_document_message (str) –
i_non_active_document_message (str) –
i_tooltip (bool) –
o_document (Document) –
- Return type:
str
- property vis_properties: VisPropertySet¶
Note
- CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384)
- o Property VisProperties() As VisPropertySet (Read Only)Manages graphic properties on current selection.Role: Gives a VisPropertySet automation object so that graphic propertiesof the selected objects can be read or modified.Note: After the execution of the VisProperties methods which update graphicproperties of the features, selected features which are not exposed toautomation will be updated. After the execution of the VisProperties methodswhich consult the selection to give the graphic properties, selected featureswhich are not exposed to automation will be consulted.Example:This example sets in no show all elements of the currentselection:Dim Selection,VisPropertySetSet Selection = CATIA.ActiveDocument.SelectionSet VisPropertySet = Selection.VisPropertiesVisPropertySet.SetShow catVisPropertiesNoShowAttr
- Return type: