cancel
Showing results for 
Search instead for 
Did you mean: 

NX does not save attributes / way to set modified flag programmatically

Creator
Creator

Hello all,

 

we run into some problems when setting attributes in NX 10.

 

To set the attribute we use the following NX code [ we use JAVA ]:

...
final AttributeInformation attributeInformation = new AttributeInformation();

attributeInformation.category = "category";
attributeInformation.title = "title";

part.setUserAttribute(attributeInformation, Update.Option.NOW);

 

If we now save with one of the following functions the attributes were not saved at all.

  • Session().parts().saveAll()
  • UFSession.part().save()
  • UFSession().part().saveAll()

 

The only method which really saves the attributes to the file is:

Session().parts().forceSaveAll

Like the name says this function save every single part in the current assembly which is like an overkill if only a single part was modified...

 

 

I've recognized that the "is modified indicator" in the assembly navigator does not change when using this function

setUserAttribute(attributeInformation, Update.Option.NOW);

 

Can we set a modified flag programmatically? We do not want to use the AttributePropertieBuilder since it is much more time consuming then the way descriped above.

 

Hope someone can help me Smiley Happy

6 REPLIES

Re: NX does not save attributes / way to set modified flag programmatically

Siemens Phenom Siemens Phenom
Siemens Phenom

 

Well, you could have your program create and then delete a point, and that should mark the part as modified.

 

If you are changing the value of an attribute or creating a new part attribute, and the part is not being flagged as modified, please report that to GTAC with information about the version that you are running.  If we can reproduce that behavior, we will refer it to development for resolution.

 

Thanks!

Re: NX does not save attributes / way to set modified flag programmatically

Master
Master

Yes i remember that to. Update.Option.NOW is usless for a natitive use i think.Smiley Frustrated

 

I use the load part fully to tell NX there is a change.

 

loadThisPartFully()

 

Spoiler

Make a list white the parts you change. After your changes are done use the 

loadThisPartFully() option from the list of part objects.

 

 

Re: NX does not save attributes / way to set modified flag programmatically

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

My hack to face this bug:

		public static void CheckSetPartModified(this NXOpen.NXObject obj)
		{
			var part = obj.OwningPart;
			var ufs = NXOpen.UF.UFSession.GetUFSession();
			var s = NXOpen.Session.GetSession();
			if (ufs.Part.IsModified(part.Tag))
			{
				if (part.Tag != s.Parts.Work.Tag)
				{
					var work = s.Parts.Work;
					s.Parts.SetWork(part);
					s.Parts.SetWork(work);
				}
			}
		}

For me the problem happens if you make changes in parts that are not the work part - so the solution is to make the part the workpart and switch back. Then you get the modified indicator.

Re: NX does not save attributes / way to set modified flag programmatically

Master
Master

I had performance issues changing lots of parts to work. Work part changes will force display activity.

Spoiler
You can't make a part to work that is not a component of the displayed part.

Re: NX does not save attributes / way to set modified flag programmatically

Phenom
Phenom

You can suppress the display activity to get a slight performance boost (also it is easier on the eyes).

 

theUfSession.Disp.SetDisplay(UFConstants.UF_DISP_SUPPRESS_DISPLAY)

'do work here

'Unsuppress display updates and regenerate the view.
theUfSession.Disp.SetDisplay(UFConstants.UF_DISP_UNSUPPRESS_DISPLAY)
theUfSession.Disp.RegenerateDisplay()

Re: NX does not save attributes / way to set modified flag programmatically

Master
Master

Yes that's true! Even in GRIP we could do it Smiley Happy 

DRAW/OFF