Indexes   

SelectedElement (Object)

Represents an element contained by a Selection object.
This object is an object contained by a Selection object. The Selection object contains SelectedElement objects, which are accessed through the Selection.Count2 and Selection.Item2 methods.

Property Index

Document
Returns the document to which the selected element belongs.
LeafProduct
Returns the leaf product corresponding to the selection in the specification tree.
Reference
Returns a Reference version of the Value property.
Type
Returns the string constant which describes the selected element Automation type.
Value
Returns the actual selected automation object.

Method Index

GetCoordinates
Returns the coordinates of the pick point.

Properties


o Property Document() As (Read Only)
Returns the document to which the selected element belongs.
o Property LeafProduct() As (Read Only)
Returns the leaf product corresponding to the selection in the specification tree.
Role: Returns the leaf
Product (component, corresponding for example to "Product1.1" in the specification tree). The AnyObject returned is a Product if a product appears in the specification tree, in the path corresponding to the current selection, and a fake AnyObject whose AnyObject.Name property equals to "InvalidLeafProduct" otherwise.
Cumulated with the use of the AnyObject.Parent property (which enables to navigate into the object structure), the current property enables the scripter to obtain the path, in the specification tree, corresponding to the selection.
Example:
The following example supposes a Part or a Product is opened. It asks the end user to select a Shape in the current window. It then sends message boxes containing the names of the automation objects contained in the specification tree path corresponding to the shape selected, and, regarding the automation objects which are products (only products which are components), a message box containing the abcissa of the translation of the product compared to its reference product.
 Dim Status,Feature,LeafProduct,LeafProductProcessed,InputObjectType(0)
 Dim Document,Selection,AutomationTreeNodeOrProduct,Position,AxisComponentsArray(11)
 Set Document = CATIA.ActiveDocument : Set Selection = Document.Selection
'We propose to the user that he select a feature
 InputObjectType(0)="AnyObject" 
 Status=Selection.SelectElement2(InputObjectType,"Select a feature",true)
 if (Status = "Cancel") then Exit Sub
 Set Feature = Selection.Item(1).Value
 Set LeafProduct = Selection.Item(1).LeafProduct
 LeafProductProcessed = true
 if (LeafProduct.Name<>"InvalidLeafProduct") then LeafProductProcessed = false
 Set AutomationTreeNodeOrProduct = Feature
 do while (TypeName(AutomationTreeNodeOrProduct)<>"Application")
'  We send a message box, if AutomationTreeNodeOrProduct is not nor a Shapes object neither a PartDocument object
     if ((TypeName(AutomationTreeNodeOrProduct)<>"Shapes") And _
         (TypeName(AutomationTreeNodeOrProduct)<>"Bodies") And _
         (TypeName(AutomationTreeNodeOrProduct)<>"PartDocument") And _
         (TypeName(AutomationTreeNodeOrProduct)<>"Products") And _
         (TypeName(AutomationTreeNodeOrProduct)<>"ProductDocument")) then
         msgbox AutomationTreeNodeOrProduct.Name
         if (TypeName(AutomationTreeNodeOrProduct)="Product") then
'          We display a message box containing the abcissa of the translation, except in the case of the
'          root product
             if (TypeName(AutomationTreeNodeOrProduct.Parent.Parent)<>"Application") then
                 Set Position = AutomationTreeNodeOrProduct.Position
                 Call Position.GetComponents(AxisComponentsArray)
                 msgbox AxisComponentsArray(9)
             end if
         end if
     end if
'  We determine the next automation tree node or product
     Set AutomationTreeNodeOrProduct = AutomationTreeNodeOrProduct.Parent
     if ((TypeName(AutomationTreeNodeOrProduct)="Application") And (Not LeafProductProcessed)) then
'      The specification tree path corresponding to the selection contains at least one product, which the current
'      loop as not yet processed. It means that the parent in the specification tree of the feature corresponding
'      to the last message box sent is LeafProduct
         Set AutomationTreeNodeOrProduct = LeafProduct
         LeafProductProcessed = true
     end if
 loop
If you run the preceeding piece of script, the current document beeing a product with the following specification tree:
     +--------+ 
     !Product3!
     +----+---+
          !
          +- Product2 (Product2.1)             'translation value: 10
          !     !
          !     +- Product1 (Product1.1)       'translation value: 20
          !           !
          !           +- Part1 (Part1.1)       
          !                !
          !                +- Part1
          !                     !
          !                     +- PartBody
          !                           !
          !                           +- Pad.1
          +- Part2 (Part2.1)
and you select Pad.1, the message boxes displayed will be:
     Pad.1
     PartBody
     Part1
     Part1.1
     Product1.1
     20
     Product2.1
     10
     Product3
 
o Property Reference() As (Read Only)
Returns a Reference version of the Value property.
Role: Returns a
Reference version of Value .
o Property Type() As (Read Only)
Returns the string constant which describes the selected element Automation type.
This type is returned by the
Value property, and may be, for instance "Pad" or "Line2D".
Caution: This property gives the leaf automation type of the object, in the inheritance hierarchy. Nevertheless, after a call to Selection.SelectElement2 , Selection.SelectElement3 , Selection.SelectElement4 , Selection.IndicateOrSelectElement2D or Selection.IndicateOrSelectElement3D , this property gives the input filter string constant relative to the effective selection (more precisely the first filter string constant delivered through the iFilterType parameter, for which the current automation object fullfills the string constant). This string constant may be an automation object name corresponding to the iFilterType parameter with which Selection.SelectElement2 has previously been called, or even a CATSelectionFilter value name.
Example:
Suppose you run the following piece of script:
 Set Selection = CATIA.ActiveDocument.Selection
'  We propose to the user that he select a Prism or a Hole
 ReDim InputObjectType(1) : InputObjectType(0)="Prism" : InputObjectType(1)="Hole"
 Status=Selection.SelectElement2(InputObjectType,"Select a prism or a hole",true)
 if (Status = "Cancel") then Exit Sub
 AutomationType = Selection.Item(1).Type
If the user selects a Pad, the script AutomationType variable will contain "Prism" and not "Pad".

Consequently, in most cases, use the VBScript TypeName function instead of this property.

o Property Value() As (Read Only)
Returns the actual selected automation object.

Methods


o Sub GetCoordinates( ioPoint)
Returns the coordinates of the pick point.
Parameters:
oPoint
The coordinates of the pick point, i.e. the hit between the geometric object and the cursor.
The length of this parameter will be 3, except if the document is a
DrawingDocument
Example:
This example retrieves the coordinates of the pick point in the array myArray:
 Dim oSelElem As SelectedElement
 Set oSelElem = CATIA.ActiveDocument.Selection.Item(1)
 ReDim myArray(2)
 oSelElem.GetCoordinates myArray

Copyright © 2006, Dassault Systèmes. All rights reserved.