Showing results for 
Search instead for 
Did you mean: 

User attribute modification not taken into account

Siemens Creator Siemens Creator
Siemens Creator

Hello everybody,


I modify a user attribute in the properties window. The attribute is well modified but if I read its value with NXopen, I still have the initial value.


For my example I use electrical routing stock. The problem may be the same with other object.

First I add a string User Attribute with NX Open.

stock->SetUserAttribute("FPMaterial", -1, "Material\\PLASTIC\\kzie1", Update::OptionNow);

I well see the result in properties windows.



I modify the value (to aaa), validate, apply and close the windows. The value is well updated in the GUI. If I save the part and close NX, I still well have my value (aaa) in the Information report.


However if I browse with NXOpen the stocks and ask their Attributes, I obtain the initial value assign not the one I assign then (aaa).

The code I use (C++)

RouteManager* routeManager = part->RouteManager();

StockCollection* stockCollection = routeManager->Stocks();
for(StockCollection::iterator stockItr = stockCollection->begin(); stockItr != stockCollection->end(); ++stockItr)
	Stock* stock = *stockItr;
	vector<NXObject::AttributeInformation> attrib = sdata->GetUserAttributes();
	for(size_t ii = 0; ii < attrib.size(); ii++)
		if(attrib[ii].Type == NXObject::AttributeTypeString && strcmp(attrib[ii].Title.GetUTF8Text(), "FPMaterial") == 0)
			cout << attrib[ii].StringValue.GetUTF8Text()) << endl;

Can  somebody tell me what is wrong?

Do I mix several concepts (attribute, user attribute, characteristics…)?


Thank in advance.





Re: User attribute modification not taken into account

Siemens Creator Siemens Creator
Siemens Creator

Hi past me!


I understand what is wrong.


stock->SetUserAttribute doesn’t set an attribute, it set two, one on the stock object and another one on the feature. When editing user attribute, only the one attached to the feature is modified!

Furthermore, common getFeatures does not return expected result but an UF function do the job:

tag_t stockFeat;
UF_ROUTE_ask_stock_feature(stock->Tag(), &stockFeat);
TaggedObject *object = NXObjectManager::Get(stockFeat);
Features::Feature* fea = dynamic_cast<Features::Feature*>(object);

It is puzzling!