Hide Table of Contents
SelectByID2 Method (IModelDocExtension)

Selects the specified entity.

.NET Syntax

Visual Basic (Declaration) 
Function SelectByID2( _
   ByVal Name As System.String, _
   ByVal Type As System.String, _
   ByVal X As System.Double, _
   ByVal Y As System.Double, _
   ByVal Z As System.Double, _
   ByVal Append As System.Boolean, _
   ByVal Mark As System.Integer, _
   ByVal Callout As Callout, _
   ByVal SelectOption As System.Integer _
) As System.Boolean
Visual Basic (Usage) 
Dim instance As IModelDocExtension
Dim Name As System.String
Dim Type As System.String
Dim X As System.Double
Dim Y As System.Double
Dim Z As System.Double
Dim Append As System.Boolean
Dim Mark As System.Integer
Dim Callout As Callout
Dim SelectOption As System.Integer
Dim value As System.Boolean
 
value = instance.SelectByID2(Name, Type, X, Y, Z, Append, Mark, Callout, SelectOption)
C# 
System.bool SelectByID2( 
   System.string Name,
   System.string Type,
   System.double X,
   System.double Y,
   System.double Z,
   System.bool Append,
   System.int Mark,
   Callout Callout,
   System.int SelectOption
)
C++/CLI 
System.bool SelectByID2( 
&   System.String^ Name,
&   System.String^ Type,
&   System.double X,
&   System.double Y,
&   System.double Z,
&   System.bool Append,
&   System.int Mark,
&   Callout^ Callout,
&   System.int SelectOption
) 

Parameters

Name

Name of object to select or an empty string

Type

Type of object (uppercase) as defined in swSelectType_e or an empty string

X

X selection location or 0

Y

Y selection location or 0

Z

Z selection location or 0

Append

 

If... And if entity is... Then...
True Not already selected Entity is appended to the current selection list
Already selected Entity is removed from the current selection list
False Not already selected Current selection list is cleared, and then the entity is put on the list
Already selected Current selection list remains the same

Mark

Value that you want to use as a mark; this value is used by other functions that require ordered selection

Callout

Pointer to the associated callout

SelectOption

Selection option as defined in swSelectOption_e (see Remarks)

Return Value

True if item was successfully selected, false if not

Example

Remarks

Use this method instead of using the selection methods on the following objects:

The previously listed objects' selection methods do not work well when a PropertyManager page is open or a command is running. This method, IModelDocExtension::SelectByID2, handles selection correctly whether a command is running.

If your application already has an object handle (for example, IFace2), use the appropriate Select method to select the item directly using its handle.

To filter the objects selected by this method, set the Type argument. If no filtering is required, then pass an empty string for this argument.

For example, to select an object of type swSelDIMENSIONS, use the string that appears in the comment column, "DIMENSION". The objectType might change based on your current state. For example, to select a sketch point that was created in the active sketch, specify the Type "SKETCHPOINT". However, if you do not have an active sketch, or if the point was created in a sketch other than the active sketch, or the point is the origin point, then specify the Type "EXTSKETCHPOINT".

If a type is specified in Type, then this method returns false if it cannot find the matching object type.

The Name argument is not intended for selection of faces, edges, and so on. This is a case-sensitive string for objects that are automatically named by SOLIDWORKS during entity creation, such as dimensions, drawing views, and so on. This method tries to find and select an object whose name matches the Name argument; however, the match needs to be exact for this method to return true.

For example:

  • If a string is passed that matches an object name but whose case does not match exactly, this method could return false. For selection of dimensions, the Name argument must be fully qualified.
  • Specify "D1@Sketch2@Part1.SLDPRT" rather than simply "D1@Sketch2"; otherwise, this method could return false. If you do not know the object name, or if it is an item that is not automatically named by SOLIDWORKS, you can pass an empty string.

If you are using the Name parameter, then specify the x, y, and z  coordinates in terms of the context where the item was created. For example, if you want to select a sketch point using its name (for example, "Point1") in the Name argument, then specify X, Y, and Z in terms of the sketch where the point was created. Even if the sketch is not active, specify the X, Y, and Z values in terms of sketch space when you use the Name parameter. In certain situations, you can also pass in the x, y, and z coordinates as ( 0,0,0 ). For example, to select a feature shown in the FeatureManager design tree, you do not need to specify x, y, and z coordinates. However, to select objects such as notes or faces, or when you need a point location picked, you must specify the x, y, and z coordinates. If you are not using the Name parameter as a filter, then specify the x, y, and z coordinates in terms of model space.

If you do not know the object name or the object type, pass empty strings for the Name and Type parameters. The selection routine makes the best attempt to select the correct object.

To get IFace2, IEdge or IVertex objects by name, use IPartDoc::GetEntityByName or IPartDoc::IGetEntityByName.

For SelectOption, specify swSelectOption_e.swSelectOptionDefault to indicate that the Shift key is not used during selection or specify swSelectOption_e.swSelectOptionExtensive to indicate that the Shift key is used during selection.

The IModelDoc2 object used to call this method must be an open and visible document. For example, you cannot use the ModelDoc2 object returned from an assembly component (IComponent2::GetModelDoc or IComponent2::IGetModelDoc) unless that SOLIDWORKS component part or subassembly is an open and visible document. In this case, you can select the item using the fully qualified name (for example, "Plane4@Part1-1@Assem1").

When selecting IFace2 objects, this method uses the specified point as input to the normal user-interface selection routines to use the speed of ray tracing. As a result, if the view changes from the original recorded size or orientation, then the same IFace2 might not be selected next time. If your application has a pointer to the IFace2 object to be selected, then you can call the IEntity::Select4 method directly. Otherwise, you can call IModelDoc2::SelectByRay or IModelDoc2::ISelectByRay. Calling either of these methods allows for tighter control over the starting point and the direction in which to search.

Use ISelectionMgr::AddSelectionListObject and ISelectionMgr::AddSelectionListObjects to add objects to a selection list without preselecting the objects in the user interface.

 

See Also

Availability

SOLIDWORKS 2005 FCS, Revision Number 13.0


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   SelectByID2 Method (IModelDocExtension)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:




x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.