Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
We want to assign the object name 'TAFE_S325.5_46HP' to attribute values. We have 3 attributes: 'customer', 'emission', and 'engine'. We assign 'TAFE' to 'customer', 'S325.5' to 'emission', and '46HP' to 'engine' without underscores in the object name.
Solved! Go to Solution.
Hi @ukrishnan-3,
write a utility to get all eligible objects, store in a list.
Iterate the list, using Persistable Adapter API you can update the attributes values one by one in loop.
Hi @ukrishnan-3,
when do you want to assign these values to the attributes?
while creation of the object?
We are currently creating three attributes for an existing object, and then assigning the object's name to one of these attributes.
Hi @ukrishnan-3,
write a utility to get all eligible objects, store in a list.
Iterate the list, using Persistable Adapter API you can update the attributes values one by one in loop.
Label nameComponent = new Label("");
nameComponent.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc));
nameComponent.setId(component_id);
wt.doc.WTDocument part = (wt.doc.WTDocument) datum;
String fullName = part.getName();
String[] parts = fullName.split("_");
String customer = parts.length > 0 ? parts[0] : "";
String emission = parts.length > 1 ? parts[1] : "";
String engine = parts.length > 2 ? parts[2] : "";
PersistableAdapter pa = new PersistableAdapter(fullName, null, null, null);
pa.load("customer","emission","engine");
pa.set("customer", customer);
pa.set("emission", emission);
pa.set("engine", engine);
pa.apply();. I wrote this code, however the value does not update to attribute. please correct this.
you should be able to do this with Object Initialization Rules, but i don't have all the details handy. take a look at the PTC support site for this topic and you should find an example.
How does this look?
Notice the attributes were updated WITHOUT iterating the object, this test was done on a WTPart but this can work on an EPMDocument or any object type.
In addition to code used to create the result below, if Name is going to be used to set the value of the three attributes, 'customer', 'emissions' and 'engine', I would consider automating the update of those attributes in the event the object is renamed. Or visa versa, update Name if any of the attributes are updated. Or maybe make the three attributes read only.
Before
After
David
Your answer is exactly the same as our requirement . please explain me how to do this ways to do in windchill.
Label nameComponent = new Label("");
nameComponent.setColumnName(AttributeDataUtilityHelper.getColumnName(component_id, datum, mc));
nameComponent.setId(component_id);
wt.doc.WTDocument part = (wt.doc.WTDocument) datum;
String fullName = part.getName();
String[] parts = fullName.split("_");
String customer = parts.length > 0 ? parts[0] : "";
String emission = parts.length > 1 ? parts[1] : "";
String engine = parts.length > 2 ? parts[2] : "";
PersistableAdapter pa = new PersistableAdapter(fullName, null, null, null);
pa.load("customer","emission","engine");
pa.set("customer", customer);
pa.set("emission", emission);
pa.set("engine", engine);
pa.apply();.I wrote this code, however the value does not update to attribute. please correct this.
sir please help us for doing this.
Send me an email from your work email account to windchill.developer@yahoo.com
Im sure we can workout how I can help you to get this working per your spec.
BTW, I don’t supply code to people anonymously. I need to know who you are. Too many “consultants” have used my code in the past, pawning it off as their own. They get paid but the guy who actually wrote it gets nothing. Just doesn’t seem right to me.
David