Selection
This section describes how to use Interactive Selection in Web.Link.
Interactive Selection
Methods and Properties Introduced:
  • pfcBaseSession.Select()
  • pfcSelectionOptions.Create()
  • pfcSelectionOptions.MaxNumSels
  • pfcSelectionOptions.OptionKeywords
  • The method pfcBaseSession.Select() activates the standard Creo Parametric menu structure for selecting objects and returns a pfcSelection 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 pfcSelection sequence to the method. The returned pfcSelection sequence will contain the input sequence and any new objects.
    The method pfcSelectionOptions.Create() and the property pfcSelectionOptions.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
    ITEM_POINT
    Datum axis
    axis
    ITEM_AXIS
    Datum plane
    datum
    ITEM_SURFACE
    Coordinate system datum
    csys
    ITEM_COORD_SYS
    Feature
    feature
    ITEM_FEATURE
    Edge (solid or datum surface)
    edge
    ITEM_EDGE
    Edge (solid only)
    sldedge
    ITEM_EDGE
    Edge (datum surface only)
    qltedge
    ITEM_EDGE
    Datum curve
    curve
    ITEM_CURVE
    Composite curve
    comp_crv
    ITEM_CURVE
    Surface (solid or quilt)
    surface
    ITEM_SURFACE
    Surface (solid)
    sldface
    ITEM_SURFACE
    Surface (datum surface)
    qltface
    ITEM_SURFACE
    Quilt
    dtmqlt
    ITEM_QUILT
    Dimension
    dimension
    ITEM_DIMENSION
    Reference dimension
    ref_dim
    ITEM_REF_DIMENSION
    Integer parameter
    ipar
    ITEM_DIMENSION
    Part
    part
    N/A
    Part or subassembly
    prt_or_asm
    N/A
    Assembly component model
    component
    N/A
    Component or feature
    membfeat
    ITEM_FEATURE
    Detail symbol
    dtl_symbol
    ITEM_DTL_SYM_INSTANCE
    Note
    any_note
    ITEM_NOTE, ITEM_DTL_NOTE
    Draft entity
    draft_ent
    ITEM_DTL_ENTITY
    Table
    dwg_table
    ITEM_TABLE
    Table cell
    table_cell
    ITEM_TABLE
    Drawing view
    dwg_view
    N/A
    Solid body
    3d_body
    ITEM_BODY
    Datum Curve End
    curve_end
    ITEM_CRV_START or ITEM_CRV_END
    When you specify the maximum number of selections, the argument to pfcSelectionOptions.MaxNumSels must be an Integer.
    The default value assigned when creating a pfcSelectionOptions object is –1, which allows any number of selections by the user.
    Accessing Selection Data
    Properties Introduced:
  • pfcSelection.SelModel
  • pfcSelection.SelItem
  • pfcSelection.Path
  • pfcSelection.Params
  • pfcSelection.TParam
  • pfcSelection.Point
  • pfcSelection.Depth
  • pfcSelection.SelView2D
  • pfcSelection.SelTableCell
  • pfcSelection.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 pfcSelection.SelModel or pfcSelection.SelItem.
    •  For an assembly component use pfcSelection.Path.
    •  For UV parameters of the selection point on a surface use pfcSelection.Params.
    •  For the T parameter of the selection point on an edge or curve use pfcSelection.TParam.
    •  For a three-dimensional point object that contains the selected point use pfcSelection.Point.
    •  For selection depth, in screen coordinates use pfcSelection.Depth.
    •  For the selected drawing view, if the selection was from a drawing, use pfcSelection.SelView2D.
    •  For the selected table cell, if the selection was from a table, use pfcSelection.SelTableCell.
    •  For the selected table segment, if the selection was from a table, use pfcSelection.SelTableSegment.
    Controlling Selection Display
    Methods Introduced:
  • pfcSelection.Highlight()
  • pfcSelection.UnHighlight()
  • pfcSelection.Display()
  • These methods cause a specific selection to be highlighted or dimmed on the screen using the color specified as an argument.
    The method pfcSelection.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 pfcWindow.Repaint(); it is not removed if you use pfcWindow.Refresh().
    The method pfcSelection.UnHighlight() removes the highlight.
    The method pfcSelection.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.js located at <creo_weblink_loadpoint>/weblinkexamples/jscript demonstrates how to use Web.Link to allow interactive selection.
    Programmatic Selection
    Web.Link 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:
  • MpfcSelect.CreateModelItemSelection()
  • MpfcSelect.CreateComponentSelection()
  • MpfcSelect.CreateModelSelection()
  • MpfcSelect.CreateSelectionFromString()
  • pfcSelection.SelItem
  • pfcSelection.SelTableCell
  • pfcSelection.SelView2D
  • The method MpfcSelect.CreateModelItemSelection() creates a selection out of any model item object. It takes a pfcModelItem and optionally a pfcComponentPath object to identify which component in an assembly the Selection Object belongs to.
    The method MpfcSelect.CreateComponentSelection() creates a selection out of any component in an assembly. It takes a ptcComponentPath object. For more information about pfcComponentPath objects, see the section Getting a Solid Object in Solid.
    Use the method MpfcSelect.CreateModelSelection() to create a pfcSelection object, based on a pfcModel object.
    The method MpfcSelect.CreateSelectionFromString() creates a new selection object, based on a Web.Link style selection string specified as the input.
    Some Web.Link 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 pfcSelection.SelItem.
    The selected table cell using the method pfcSelection.SelTableCell.
    The selected drawing view using the method pfcSelection.SelView2D.
    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.
    Web.Link 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:
  • pfcSession.CurrentSelectionBuffer
  • pfcSelectionBuffer.Contents
  • The property pfcSession.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 pfcSelectionBuffer.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:
  • pfcSelectionBuffer.RemoveSelection()
  • pfcSelectionBuffer.Clear()
  • Use the method pfcSelectionBuffer.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 method pfcSelectionBuffer.Contents.
    Use the method pfcSelectionBuffer.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:
  • pfcSelectionBuffer.AddSelection()
  • Use the method pfcSelectionBuffer.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.