Cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding read the attribute from component part

Valued Contributor
Valued Contributor

Hi all

 

I have a problem that how can I read the attribute of component part and create a note in drafting, let this note could update according to the attribute of component part(Children level)? For now, I found I only could read the attribute of top component part(Parent level), for example, I import  <W@Material> in the note, it works but only for parent level, not for children level. I found someone use a good way to read the the attribute of children level like  <W!66189@Material>, it works, and the number "66189" looks like a random number, every time to open the part, this number will be changed. 

I'll be very appriciated if anyone could help me to achieve it? 

 I use NX6.0 to develop.

Thanks in advance!

 

Best Regards

Christian

Best Regards
Christian
6 REPLIES

Re: Regarding read the attribute from component part

Valued Contributor
Valued Contributor

I'm not shure if I got your question.

You should always be able to ask attributes on objects such as components and/or parts.

YourObject.GetStringAttribute() in NX6 or YourObject.GetUserAttributeAsString() in NX8 or later should work fine.

The magic numbers are internal references (tags) that are resolved by NX in your session.

I have a legacy function (since UGII aera) that updates notes with attribute values. All notes which needs an update by an attribute have the attribute title as name on the note element. So the program cycles through all the notes on a part/drawing sheet, reads the name of the note and gets the corresponding attribute value. This is used to set the note text.

 

Hope this helps

 

 

 

Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter10 and Native)

Re: Regarding read the attribute from component part

Valued Contributor
Valued Contributor
Hi Herbert,

I'm appreciate that you could give me a hint, but I'm the beginner and can not understand very well, can you give me more hint or share your code to me? Thanks in advance!
Best Regards
Christian

Re: Regarding read the attribute from component part

Valued Contributor
Valued Contributor
Maybe my discription is not so clear. I mean I need create a note on the drawing, and this note need link to attribute from component. How does it work and how can I set this magic number? I know this magic number is from system, but I realy don't understand how to get it.
Best Regards
Christian

Re: Regarding read the attribute from component part

Valued Contributor
Valued Contributor

Hello Christian,

 

the magic number is a TAG (NXopen.Tag). Each NXOpen.TaggedObject has one.

A NXOpen.Assemblies.Component is derived from TaggedObject, so you can access the tag using

MyComponent.Tag.

 

To form a reference text use something like (in C#)
String.Format("<W!{0}@ATTRIBUTE_TITLE>", (int)MyComponent.Tag);

 

To update note programmatically like mentioned in my previous reply you can

  • cycle all notes on a part by using NXOpen.UF.UFObj.CycleObjsInPart()
    (you get tags out of this. To get the object use NXOpen.Utilities.NXObjectManager.Get(tag)) or
  • ask all visible objects of a drafting view using MyDraftingView.AskVisibleObjects()

Hope this helps

Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter10 and Native)

Re: Regarding read the attribute from component part

Valued Contributor
Valued Contributor

It looks like there is a problem with special characters.

So I post an image to show the String.Format statement.
StringFormat.png


Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter10 and Native)

Re: Regarding read the attribute from component part

Valued Contributor
Valued Contributor
Hi Herbert

It's working!!! Thank you so much! You gave an important lesson to me, it was puzzled me for a few days! Now the problem solved, thank you and have a nice day!
Best Regards
Christian