Skip to main content
1-Visitor
July 14, 2020
Question

Truncated String Attribute

  • July 14, 2020
  • 3 replies
  • 5263 views

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

 

Attribute A = 12345-67-89

Attribute B = 12345

3 replies

1-Visitor
July 14, 2020

Both are strings by the way...

 

WIndchilll 11.2

23-Emerald III
July 14, 2020

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)

 

 

 

1-Visitor
July 14, 2020

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

23-Emerald III
July 14, 2020

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.

18-Opal
July 24, 2020

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(“-“));
1-Visitor
July 29, 2020

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.

18-Opal
July 29, 2020

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.