! +- 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 to automation can be accessed through a recursive call to the AnyObject.Parent property. When a given feature is selected, there are three possibilities:
? ?
The feature is exposed to automation (a Pad for example, this is the common case): the feature can be accessed by all Selection object methods
The feature is not exposed to automation, but at least one of its parent objects is exposed to automation (a DMU Navigator URL for example: the Hyperlink is not exposed to automation, but the root Product, which contains the Hyperlink, is exposed to automation):
o no access is given to the feature through the Count2 and Item2 methods of the Selection
object o nevertheless, the first parent object of the feature, which is exposed to automation (the root
Product in our example) can be accessed through the Item2 and Count2 methods
o The Search, Delete, VisProperties, Copy, Cut, Paste and PasteSpecial methods of the Selection
object, take into account the feature. For example, if the user:
? ?
Puts a DMU Navigator URL in the clipboard Runs a script calling the PasteSpecial method
then, during the paste, the DMU Navigator URL will be pasted
?
The feature is not exposed to automation, and he has no parent object which is exposed to automation (a ResourcesList object of a .CATProcess for example):
o no access is given to the feature through the Count2 and Item2 methods of the Selection
object o no access is given neither to any parent object of the feature through the Item2 and Count2
methods
o The Search, Delete, VisProperties, Copy, Cut, Paste and PasteSpecial methods of the Selection
object take into account the feature. For example, if the user:
? ? ?
Go to the \ Puts a ResourcesList object in the clipboard
Runs a script calling the Selection.PasteSpecial method
then, during the paste, the ResourcesList object will be pasted.
Property Index
Count Count2
Returns the number of SelectedElement objects contained by the current selection.
VisProperties
Manages graphic properties on current selection.
Method Index
Add
Creates a SelectedElement object which Value property is the given automation object, and adds it to the selection.
Clear
Clears the selection.
Copy
Copies, in a copy and paste operation.
Cut
Cuts, in a cut and paste operation.
Delete
Deletes all selected objects.
FilterCorrespondence
Specifies if the automation objects appearing as Value property of SelectedElement objects fit a given filter.
FindObject
Finds an object in the current selection and deletes it from the selection.
IndicateOrSelectElement2D
Runs an interactive command enabling both indication and selection, 2D version.
IndicateOrSelectElement3D
Runs an interactive command enabling both indication and selection, 3D version.
Item Item2
Returns the iIndex-th SelectedElement object contained by the current selection.
Paste
Puts the contents of the clipboard in the document at the indicated location.
PasteSpecial
Puts the contents of the clipboard in the document at the indicated location, according to the specified format.
Remove
Remove2
Removes the iIndex-th SelectedElement object contained by the current selection.
Search
Finds an object in the document using the Edit/Search grammar.
SelectElement2
Runs an interactive selection command.
SelectElement3
Runs an interactive selection command, exhaustive version.
SelectElement4
Runs an interactive selection command, enabling the selection in a non active document.
Properties
o Property Count( ) As long (Read Only)
Deprecated:
V5R16 #Count2 . The Count and Item Methods have been replaced by the Count2 and Item2 methods because they did not process correctly features which are not exposed to automation (such as a ResourcesList feature of a .CATProcess document).
o Property Count2( ) As long (Read Only)
Returns the number of SelectedElement objects contained by the current selection.
Role: This method returns the number of SelectedElement objects contained by the Selection. The Value property of a given SelectedElement object is an automation object associated to a selected
feature.
o Property VisProperties( ) As CATIAVisPropertySet (Read Only)
Manages graphic properties on current selection.
Role: Gives a VisPropertySet automation object so that graphic properties of the selected objects can be read or modified.
Note: After the execution of the VisProperties methods which update graphic properties of the features, selected features which are not exposed to automation will be updated. After the execution of the VisProperties methods which consult the selection to give the graphic properties, selected features which are not exposed to automation will be consulted. Example:
This example sets in no show all elements of the current selection:
Dim Selection,VisPropertySet
Set Selection = CATIA.ActiveDocument.Selection Set VisPropertySet = Selection.VisProperties VisPropertySet.SetShow catVisPropertiesNoShowAttr
Methods
o Sub Add( CA TIABase iObject)
Creates a SelectedElement object which Value property is the given automation object, and adds it to
the selection.
Role: Creates a SelectedElement object, which Value property is the given automation object, and which LeafProduct property is the first (when scanning the specification tree) which contains the automation object. The SelectedElement is added to the current selection. Example:
This example creates a SelectedElement object, which Value property is the ObjectToAdd automation object, the SelectedElement being added to the current selection.
CATIA.ActiveDocument.Selection.Add(ObjectToAdd)
o Sub Clear( )
Clears the selection. Example:
This example clears the selection. The selection is then empty.
CATIA.ActiveDocument.Selection.Clear()
o Sub Copy( )
Copies, in a copy and paste operation.
Role: Puts the contents of the selection in the clipboard, but leaves the selected elements in the document, and clears the selection. This is the programming equivalent of the Copy command from the Edit menu.
Note: If a selected feature is not exposed to automation, it will be copied into the clipboard all the way. Example:
This example copies, in a copy and paste operation. A selected DMU Navigator URL will be put into the clipboard although it is not exposed to automation.
CATIA.ActiveDocument.Selection.Copy()
o Sub Cut( )
Cuts, in a cut and paste operation.
Role: Puts the contents of the selection in the clipboard, and removes the selected elements from the document, and clears the selection. This is the programming equivalent of the Cut command from the Edit menu.
Note: If a selected feature is not exposed to automation, it will be copied into the clipboard and removed from the document all the way. Example:
This example cuts, in a cut and paste opertation. A selected DMU Navigator URL will be put into the clipboard and removed from the document, although it is not exposed to automation.
CATIA.ActiveDocument.Selection.Cut()
o Sub Delete( )
Deletes all selected objects.
Role: For all the SelectedElement objects contained by the selection, the SelectedElement.Value automation object is deleted from the document.
Note: If a selected feature is not exposed to automation, it will deleted all the way. Example:
This example deletes all the selected objects. A selected DMU Navigator URL will be removed from the document, although it is not exposed to automation.
CATIA.ActiveDocument.Selection.Delete()
o Func FilterCorrespondence( CA TSafeArrayVariant iFilterType) As boolean
Specifies if the automation objects appearing as Value property of SelectedElement objects fit a given filter.
Role: FilterCorrespondence filters the selection with respect to provided automation types. The use of this method coupled with the use of the SelectElement2 will enable, for example, to write a script reproducing the functionalities of the \This method, called before a loop onto SelectElement2 calls, will enable to initialize a set of objects to select.
This way of coding corresponds to a power multi-selection with a visual feedback of the selected edge (high-lighting) as soon as an edge has been selected. Parameters: iFilterType
An array of strings constants to be used as a filter for the kind of element to which current selection object must correspond. See the iFilterType parameter of the
SelectElement2 method.
oAllFit
All current selection objects fit the iFilterType filter, i.e. regarding each of the current selection objects, they all fit one of the iFilterType string constant. Example:
The following example uses an internalized array of edges. It loops onto:
? asking the end user to select an edge of a tri-dimentional feature (see TriDimFeatEdge )
? adding the selected edge into the internalized edge list (the edge count maximum value equals to 5) Then, it creates an edge fillet (see ConstRadEdgeFillet ), giving it as specifications the selected edges.
At the beginning of the execution of the script, we test if all current selection objects are edges. If it is the case, the internalized edge list is updated. Otherwise, we clear the current selection content.
Set Document = CATIA.ActiveDocument : Set Part = Document.Part : Set Selection = Document.Selection
Set ShapeFactory = Part.ShapeFactory : AllocatedEdgeCount = 10 : ReDim Edge(AllocatedEdgeCount-1)
ReDim InputObjectType(0) : InputObjectType(0)=\ AllFit = Selection.FilterCorrespondence(InputObjectType) if (AllFit) then
' We add the selected edges to Edge
for EdgeIndex = 0 to Selection.Count2-1
' We increase the allocation of EdgeSet if necessary if (EdgeCount = AllocatedEdgeCount) then
AllocatedEdgeCount = AllocatedEdgeCount + 10 : ReDim Edge(AllocatedEdgeCount-1) end if