Hola chago
Te dejo la ayuda del comando seleciton:
Represents the selection.
The Selection object contains the features the end user selected, usually with the mouse, and which are candidates as subjects for the next action.
A feature possess parent objects in the specification tree (hierarchy). For example, the Pad below possess parent objects in the specification tree:
+--------+
!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 to automation can be accessed through a recursive call to the AnyObject.Parentproperty. 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):
- no access is given to the feature through the Count2 and Item2 methods of the Selection object
- 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
- 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):
- no access is given to the feature through the Count2 and Item2 methods of the Selection object
- no access is given neither to any parent object of the feature through the Item2 and Count2 methods
- 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 "DPM - Process and Resource Definition" workshop
- 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.
Note: The Selection object can be accessed through the Document.Selection property . 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 this document. You will, for example, determine the Selectionobject the following way:
Set ActiveProductDocument = CATIA.ActiveDocument
Set Product3 = ActiveProductDocument.Product
Set Product3Products = Product3.Products
Set Product2Dot1 = Product3Products.Item("Product2.1") : Set Product2 = Product2Dot1.ReferenceProduct
Set ProductDocument2 = Product2.Parent
Set Product2Products = Product2.Products
Set Product1Dot1 = Product2Products.Item("Product1.1") : Set Product1 = Product1Dot1.ReferenceProduct
Set ProductDocument1 = Product1.Parent
Set Product1Products = Product1.Products
Set Part1Dot1 = Product1Products.Item("Part1.1") : Set Part1 = Part1Dot1.ReferenceProduct
Set PartDocument1 = Part1.Parent
Set Selection = ActiveProductDocument.Selection
Another Selectionobject, such as:
Set ProductDocument2Selection = ProductDocument2.Selection
Set ProductDocument1Selection = ProductDocument1.Selection
Set PartDocument1Selection = PartDocument1.Selection
(lets take ProductDocument2Selection for example) can only be used if, among the different Window , there is at least one whose root Document is ProductDocument2 . Otherwise, results are unpredictable.