×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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.

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

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

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

(OP)
Thanks!
I follow this way...
ZsZs.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources