cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

Truncated String Attribute

ChiselnMallet1
12-Amethyst

Truncated String Attribute

Anyone know of a way for atttribute B to use a truncated string of attribute A

 

Attribute A = 12345-67-89

Attribute B = 12345

13 REPLIES 13

Both are strings by the way...

 

WIndchilll 11.2

There may be some java code that will do this in Windchill.

Where in Windchill are you trying to truncate the attribute.

 

This is in Creo, not Windchill.

AttributeB = extract(AttributeA,1,5)

This will extract the first 5 characters.

 

If you want something fancier, like the # of characters before the first -, then it can be done in relations.

count = search(AttributeA,'-')

AttributeB = extract(attributeA,1,count)

 

 

 

I'd  like to do this in Windchill... Where the PTC_WM_Number (Attribute A) is used (cascading?) by Attribute B.  

So PTC_WM_Number = 12345.prt and Attribute B = 12345.

 

I'm not sure where I would code this are make a formula for this in WIndchill

Where do you get the PTC_WM_number from in your CREO files?

I do not see it in mine.

What is driving the PTC_WM_Number parameter in Creo? Is this new in a WIndchill version above 11.0 m030, which is what I have.

 

If the number is coming from Creo, why not use a standard relation in your start parts to truncate the parameter and then designate it and pass the truncates parameter to the Windchill attribute.

From what I ready PTC made this available with this combo CREO 6.0 and Windchill 11.2

 

We started new with these installs.

 

PTC_WM_NUMBER comes from the number Windchill assigns in on upload.  By default it names Number the same as the filename (the filed you enter on part creation in CREO).

If I can access the PTC_WM_NUMBER and make a new attribute from it by calculated or something to drop the file name extension it will relieve my users from having to enter the number into a CREO parameter that gets used in a title block.

We avoid that issue by using our own parameter in the titleblock and BOM.

In our start parts, we have this.

/*** SET PDM_NUMBER PARAMETER TO MODEL NAME ***
PDM_NUMBER=extract(REL_MODEL_NAME,1,14)

adjust the extract length or remove it depending on what you need.

To date none of our existing parts have this relation in them... getting the team 30+ to remember to add this relation in everytime they touch a part that predates this relations is going to happen at best 80% of the time... 

 

I can count on folks to simply update their drawing format... one single step... and it will grab the model attribute PTC_COMMON_NAME for the description and PT_WM_NUMBER (sans extention somehow) for the number.

 

What ever I can do to make updating the least amount of PITA will make everyone's life a lot easier!

When are you trying to update attribute B?
This can be done using OIR algorithm or wherever.

It could also automatically be done anytime attribute A is edited.

 

Is it fair to say you are looking to pass everything in front of the first “-“?

 

Do you already know how to get and update attributes using Windchill APIs? If yes, get the value of A and then set the value of B.

The code to do the truncating at the first “-“ would look like this.

 

String A = “1234-56-789”;

String B = A.substring(0, A.indexOf(“-“));

Attribute is actually PTC_NUMBER, Attribute B is the truncated version of that.  Any time the Number is changed attribute B needs to change.  I want this to be a Windchill attribute that does not need to live as a parameter in the file.  I don't want to use relations inside the files because I have soooo many files that would retroactively need this relation added.  I want to be able to just have folks update a new format in there drawings and it would use Windchill Attribute B from the model rather than a relation controlled  parameter.  I don't know where to put the expression to calculate the Attribute B value in windchill.

This is definitely doable.

I’d suggest an OIR custom algorithm with to code to edit attribute B. This would cover new objects.

 

If you want this to be automatic, that is anytime Windchill attribute A gets edited Windchill attribute B is automatically updated accordingly, I’d write a listener that would detect when attribute A is edited. Once detected the listener would contain/run the Java code to update attribute B accordingly.

I realize this is not a step-by-step explanation nor is the required code supplied. But using a listener is my rocommendation.

This technique would not need to involve the Creo files.

Very Cool... So an OIR is where I can code the value of attribute B by referencing attribute A?

 

I am going to get there at some point... educating myself to use Java... is a listener something that is coded in the OIR or is it a java"class?" that needs to be called from the OIR?

 

Thank you very much for responding back so far.... and hopefully continued??!!

Yes to your OIR question however this would only do what you want for, as the name implies, the objects initial creation.

If you want this to be automatic going forward a listener will get the job done.

One listener can also get the job done for both initial creation and going forward.

 

And yes, a listener in Windchill requires a Java class that implements an interface. The interface doesn’t have to do anything but it is a requirement to register the listener. The listener is registered by pointing to it with a wt.properties option.

Thank your for breaking this down for me... feeling the water rising above my head on this one know... will need to research some more to get a better understanding..

Top Tags