Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Instance Name & number from selected part

Status
Not open for further replies.

Alan Lowbands

Aerospace
May 17, 2017
274
GB
Hi,
I'm trying to get the instance name from a selected part but with no luck.
I cant find anything in the v5 automation file but found some code online.
I have asked this in another thread but I thought I would ask everyone as i'm stuck.


Set InstName = CATIA.ActiveDocument.Selection.Name.Value "dosent work"
&
Set InstName = sSel.Item(1).Value "This one returns the part name"

thanks
Alan
 
Replies continue below

Recommended for you

Hello,

If you are in an assembly and you've selected a product from the tree, you'd have to use this:

Code:
InstName = sSel.item(1).Value.Name

You'd also need to learn basic VBA concept before attempting to script in CATIA (e.g. use 'set' to assign object to variables, not strings).

Calin

 
Hi Calin,
Thanks for the reply but the code would show the part name not the instance name & number.
Do you know how to modify it to do so?

regards
Alan
 
Hello,

I am very sure that IF you are in an assembly (CATProduct), your active document is the CATProduct and you select an item from the tree, the code I provided would return the Instance Name not the Part Number.

Please see the attached image for details.

Calin
 
 http://files.engineering.com/getfile.aspx?folder=0d192318-13c0-488e-90e6-c15ae6bec61d&file=test.png
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top