Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How get the instance number of my component (in API) ?

Status
Not open for further replies.

ZsZs

Computer
May 8, 2007
30
0
0
HU
Hi!

I attach a picture. I like selecting the component (with API) - signed with red circle.
Before I use the ModelDocExtension::SelectByID2 method, I need to use the fully qualified name (otherwise not working this method).

The API help wrote:
"The ModelDoc2 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 (Component2::GetModelDoc) 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")."

I how get the instance number of component before selection?

Thanks,
ZsZs.
 
Replies continue below

Recommended for you

You can't if you have more than one instance of the component in the assembly.. You could get the instance number of all of the instances of a component in the assembly, but how is the macro supposed to know which one you want to select? If you're sure there will only be one instance in the assembly, then you would only get one instance returned. Look in the API help under Assemblies...specifically Traversing Assemblies. You should be able to get a list of all of the components that way.

ken
 
Status
Not open for further replies.
Back
Top