Showing results for 
Search instead for 
Do you mean 
Reply

Set User Attribute Method

Hello,

 

during a program that i writing with c# (for NX 9) i am using the SetUserAttribute to insert Attribute to an object from type NXOpen.Point. while i am debug the program i can see that i get a NXObject.AttributeInformation (i tried to use GetUserAttribute after i using SetUserAttribute so i can get feedback while debug) that equel to the attribute value that i insert.

 

but when i close the program and open it again (the NXOpen.Point are still exist) i can see in the NX that the points properties do not have attributes and when i try to get the attribute (in the same way i tried before) i do not get any value (i get error because i tring to get attribute that do not exist).

 

do i need to do more actions to update my attribute when i set them? why it the attributes do not saved on the point?

 

here is the way i use the function:

 

NXOpen.Point = new NXOpen.Point(1.0, 1.0, 1.0)

point.SetUserAttribute("I Value", -1, -0.6, Update.Option.Now);

point.SetUserAttribute("J Value", -1, 0.41, Update.Option.Now);

point.SetUserAttribute("K Value", -1, 1.5, Update.Option.Now);

 

and this is the way i try to get the values after i open and close my program:

 

NXObject.AttributeInformation IJKValue;

IJKValue = point.GetUserAttribute("I Value", NXObject.AttributeType.Real, -1)

IJKValue = point.GetUserAttribute("J Value", NXObject.AttributeType.Real, -1)

IJKValue = point.GetUserAttribute("K Value", NXObject.AttributeType.Real, -1)

 

I appreciate any help,

Ran.

3 REPLIES

Re: Set User Attribute Method

Did you save the file before closing it?

Re: Set User Attribute Method

I did not closed the part, i used the getUserAttribute in a different section in my program.

 

but i solved the problem! i use the setUserAttribute right after i create the point (earlier
 i set the attribute after i cast the points to NXObject and then cast them back to NXOpen.Point) i still do not know why it is not worked before and if i will found out i will post the reason.

 

Thanks for the help,

Ran.

Re: Set User Attribute Method

I think you mixed something up here.

NXOpen.Point point = new NXOpen.Point(1.0, 1.0, 1.0);
point.SetUserAttribute("I Value", -1, -0.6, Update.Option.Now);
point.SetUserAttribute("J Value", -1, 0.41, Update.Option.Now);
point.SetUserAttribute("K Value", -1, 1.5, Update.Option.Now);

The variable "point" was missing.

Double IValue = point.GetUserAttribute("I Value", NXObject.AttributeType.Real, -1);
Double JValue = point.GetUserAttribute("J Value", NXObject.AttributeType.Real, -1);
Double KValue = point.GetUserAttribute("K Value", NXObject.AttributeType.Real, -1);

The IJK values are of type double and not an attribute information.

You should have got an exception or your IDE should have barked on you.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community