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 The entity is appended to the current selection list
Already selected The entity is removed from the current selection list
false Not already selected The current selection list is cleared, and then the entity is put on the list
Already selected The 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 or not 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 might return false. For selection of dimensions, the Name argument needs to be fully qualified. For example, specify "D1@Sketch2@Part1.SLDPRT" rather than simply "D1@Sketch2"; otherwise, this method might 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 XYZ 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 XYZ in terms of the sketch where the point was created. Even if the sketch is not active, specify the XYZ values in terms of sketch space when you use the Name parameter. In certain situations, you can also pass in the XYZ coordinates as simply ( 0,0,0 ). For example, to select a feature shown in the FeatureManager design tree, you do not need to specify an XYZ coordinates. However, to select objects such as notes or faces, or when you need a point location picked, you must specify the XYZ coordinates. If you are not using the Name parameter as a filter, then specify the XYZ coordinates in terms of model space.

If you do not know the object name or the object type, pass in empty strings for the Name and Type parameters and 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 swSelectOptionDefault to indicate that the Shift key is not used during selection or specify 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:  

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) 2014 SP05

The search functionality within the web help is in a beta test phase and you may experience periodic delays or interruptions in its performance. These are the normal and ordinary features of a beta test and shall not under any circumstances give rise to any liability on the part of Dassault Systèmes SolidWorks Corporation or its licensors. The topics within the Web-based help are not beta topics; they document API Help (English only) 2014 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.