Selection
This section describes how to use Interactive Selection in the VB API.
Interactive Selection
Methods and Properties Introduced:
  • IpfcBaseSession.Select()
  • CCpfcSelectionOptions.Create()
  • IpfcSelectionOptions.MaxNumSels
  • IpfcSelectionOptions.OptionKeywords
  • The method IpfcBaseSession.Select() activates the standard Creo Parametric menu structure for selecting objects and returns a IpfcSelection sequence that contains the objects the user selected. Using the Options argument, you can control the type of object that can be selected and the maximum number of selections.
    In addition, you can pass in a IpfcSelection sequence to the method. The returned IpfcSelection sequence will contain the input sequence and any new objects.
    The method CCpfcSelectionOptions.Create() and the property IpfcSelectionOptions.OptionKeywords take a String argument made up of one or more of the identifiers listed in the table below, separated by commas.
    For example, to allow the selection of features and axes, the arguments would be feature, axis.
    Creo Parametric Database Item
    String Identifier
    ModelItemType
    Datum point
    point
    EpfcITEM_POINT
    Datum axis
    axis
    EpfcITEM_AXIS
    Datum plane
    datum
    EpfcITEM_SURFACE
    Coordinate system datum
    csys
    EpfcITEM_COORD_SYS
    Feature
    feature
    EpfcITEM_FEATURE
    Edge (solid or datum surface)
    edge
    EpfcITEM_EDGE
    Edge (solid only)
    sldedge
    EpfcITEM_EDGE
    Edge (datum surface only)
    qltedge
    EpfcITEM_EDGE
    Datum curve
    curve
    EpfcITEM_CURVE
    Composite curve
    comp_crv
    EpfcITEM_CURVE
    Surface (solid or quilt)
    surface
    EpfcITEM_SURFACE
    Surface (solid)
    sldface
    EpfcITEM_SURFACE
    Surface (datum surface)
    qltface
    EpfcITEM_SURFACE
    Quilt
    dtmqlt
    ITEM_QUILT
    Dimension
    dimension
    EpfcITEM_DIMENSION
    Reference dimension
    ref_dim
    EpfcITEM_REF_DIMENSION
    Integer parameter
    ipar
    EpfcITEM_DIMENSION
    Part
    part
    N/A
    Part or subassembly
    prt_or_asm
    N/A
    Assembly component model
    component
    N/A
    Component or feature
    membfeat
    EpfcITEM_FEATURE
    Detail symbol
    dtl_symbol
    EpfcITEM_DTL_SYM_INSTANCE
    Note
    any_note
    EpfcITEM_NOTE, EpfcITEM_DTL_NOTE
    Draft entity
    draft_ent
    EpfcITEM_DTL_ENTITY
    Table
    dwg_table
    EpfcITEM_TABLE
    Table cell
    table_cell
    EpfcITEM_TABLE
    Drawing view
    dwg_view
    N/A
    Solid body
    3d_body
    EpfcITEM_BODY
    Datum Curve End
    curve_end
    EpfcITEM_CRV_START or EpfcITEM_CRV_END
    When you specify the maximum number of selections, the argument to IpfcSelectionOptions.MaxNumSels must be an Integer.
    The default value assigned when creating a IpfcSelectionOptions object is –1, which allows any number of selections by the user.
    Accessing Selection Data
    Properties Introduced:
  • IpfcSelection.SelModel
  • IpfcSelection.SelItem
  • IpfcSelection.Path
  • IpfcSelection.Params
  • IpfcSelection.TParam
  • IpfcSelection.Point
  • IpfcSelection.Depth
  • IpfcSelection.SelView2D
  • IpfcSelection.SelTableCell
  • IpfcSelection.SelTableSegment
  • These properties return objects and data that make up the selection object. Using the appropriate properties, you can access the following data:
    •  For a selected model or model item use IpfcSelection.SelModel or IpfcSelection.SelItem.
    •  For an assembly component use IpfcSelection.Path.
    •  For UV parameters of the selection point on a surface use IpfcSelection.Params.
    •  For the T parameter of the selection point on an edge or curve use IpfcSelection.TParam.
    •  For a three-dimensional point object that contains the selected point use IpfcSelection.Point.
    •  For selection depth, in screen coordinates use IpfcSelection.Depth.
    •  For the selected drawing view, if the selection was from a drawing, use IpfcSelection.SelView2D.
    •  For the selected table cell, if the selection was from a table, use IpfcSelection.SelTableCell.
    •  For the selected table segment, if the selection was from a table, use IpfcSelection.SelTableSegment.
    Controlling Selection Display
    Methods Introduced:
  • IpfcSelection.Highlight()
  • IpfcSelection.UnHighlight()
  • IpfcSelection.Display()
  • These methods cause a specific selection to be highlighted or dimmed on the screen using the color specified as an argument.
    The method IpfcSelection.Highlight() highlights the selection in the current window. This highlight is the same as the one used by Creo Parametric when selecting an item—it just repaints the wire-frame display in the new color. The highlight is removed if you use the View, Repaint command or IpfcWindow.Repaint(); it is not removed if you use IpfcWindow.Refresh().
    The method IpfcSelection.UnHighlight() removes the highlight.
    The method IpfcSelection.Display() causes a selected object to be displayed on the screen, even if it is suppressed or hidden.
    Note
    This is a one-time action and the next repaint will erase this display.
    Example Code: Using Interactive Selection
    The sample code in the file pfcSelectionExamples.vb located at <creo_vbapi_loadpoint>/vbapi_examples demonstrates how to use the VB API to allow interactive selection.
    Programmatic Selection
    The VB API provides methods whereby you can make your own Selection objects, without prompting the user. These Selections are required as inputs to some methods and can also be used to highlight certain objects on the screen.
    Methods and Properties Introduced:
  • CMpfcSelect.CreateModelItemSelection()
  • CMpfcSelect.CreateComponentSelection()
  • CMpfcSelect.CreateModelSelection()
  • IpfcSelection.SelItem
  • IpfcSelection.SelTableCell
  • IpfcSelection.SetSelView2D
  • The method pCMpfcSelect.CreateModelItemSelection() creates a selection out of any model item object. It takes a IpfcModelItem and optionally a IpfcComponentPath object to identify which component in an assembly the Selection Object belongs to.
    The method CMpfcSelect.CreateComponentSelection() creates a selection out of any component in an assembly. It takes a IpfcComponentPath object. For more information about IpfcComponentPath objects, see the section Getting a Solid Object in Solid.
    Use the method CMpfcSelect.CreateModelSelection() to create a IpfcSelection object, based on a IpfcModel object.
    Some VB API properties require more information to be set in the selection object. The methods allow you to set the following:
    The selected item using the method IpfcSelection.SetSelItem.
    The selected table cell using the method IpfcSelection.SetSelTableCell.
    The selected drawing view using the method IpfcSelection.SetSelView2D.
    Selection Buffer
    Introduction to Selection Buffers
    Selection is the process of choosing items on which you want to perform an operation. In Creo Parametric, before a feature tool is invoked, the user can select items to be used in a given tool's collectors. Collectors are like storage bins of the references of selected items. The location where preselected items are stored is called the selection buffer.
    Depending on the situation, different selection buffers may be active at any one time. In Part and Assembly mode, Creo Parametric offers the default selection buffer, the Edit selection buffer, and other more specialized buffers. Other Creo Parametric modes offer different selection buffers.
    In the default Part and Assembly buffer there are two levels at which selection is done:
    •  First Level Selection
    Provides access to higher-level objects such as features or components. You can make a second level selection only after you select the higher-level object.
    •  Second Level Selection
    Provides access to geometric objects such as edges and faces.
    Note
    First-level and second-level objects are usually incompatible in the selection buffer.
    The VB API allows access to the contents of the currently active selection buffer. The available functions allow your application to:
    •  Get the contents of the active selection buffer.
    •  Remove the contents of the active selection buffer.
    •  Add to the contents of the active selection buffer.
    Reading the Contents of the Selection Buffer
    Properties Introduced:
  • IpfcSession.CurrentSelectionBuffer
  • IpfcSelectionBuffer.Contents
  • The property IpfcSession.CurrentSelectionBuffer returns the selection buffer object for the current active model in session. The selection buffer contains the items preselected by the user to be used by the selection tool and popup menus.
    Use the property IpfcSelectionBuffer.Contents to access the contents of the current selection buffer. The method returns independent copies of the selections in the selection buffer (if the buffer is cleared, this array is still valid).
    Removing the Items of the Selection Buffer
    Methods Introduced:
  • IpfcSelectionBuffer.RemoveSelection()
  • IpfcSelectionBuffer.Clear()
  • Use the method IpfcSelectionBuffer.RemoveSelection() to remove a specific selection from the selection buffer. The input argument is the IndexToRemove specifies the index where the item was found in the call to the property IpfcSelectionBuffer.Contents.
    Use the method IpfcSelectionBuffer.Clear() to clear the currently active selection buffer of all contents. After the buffer is cleared, all contents are lost.
    Adding Items to the Selection Buffer
    Method Introduced:
  • IpfcSelectionBuffer.AddSelection()
  • Use the method IpfcSelectionBuffer.AddSelection() to add an item to the currently active selection buffer.
    Note
    The selected item must refer to an item that is in the current model such as its owner, component path or drawing view.
    This method may fail due to any of the following reasons:
    •  There is no current selection buffer active.
    •  The selection does not refer to the current model.
    •  The item is not currently displayed and so cannot be added to the buffer.
    •  The selection cannot be added to the buffer in combination with one or more objects that are already in the buffer. For example: geometry and features cannot be selected in the default buffer at the same time.