Skip to main content
5-Regular Member
October 4, 2022
Solved

Renaming a parameter value based on a dimension value

  • October 4, 2022
  • 2 replies
  • 3364 views

Hello

 

I'm trying to find out if it is possible to rename a parameter value based on some dimension values.


I have a model where we use a parameter called "Local_Description". This parameter is used on drawings to indicate some outer dimensions of the part.  

Can I create a relation that takes input from dimensions, converts them to string and set's them up in a desired way? 

Something along this: 

ad451 =100

ad452=200

ad453=300

Local_description = ad451 & "x" & ad452 & "x" & ad453 

 

Resulting in the following 

 

Local_description = 100x200x300

 

Is there a way to create this? Either with relations or with pro/program? 

 

Best answer by KenFarley

How easy this is will depend on what your numbers being converted need to be. The only method provided in relations to convert numeric values to text strings is the ITOS function. As its name implies it takes a number and converts it to an integer string, for example,

myString = ITOS ( 123.456 ) ==> myString = "123"

So, to do what you asked in your example, the relations code would be:

Local_description = ITOS(ad451) + "x" + ITOS(ad452) + "x" + ITOS(ad453)

Some caveats, however. A zero value yields an ITOS string that is blank. I think the number gets rounded up, i.e. ITOS(123.8) => "124".

If you want to convert real numbers and get strings with decimal places, that takes much more code, but is commonly done. You can certainly find examples in other discussions on this forum, like this one:

 

Old Real to String Discussion 

 

2 replies

KenFarley
KenFarley21-Topaz IIAnswer
21-Topaz II
October 4, 2022

How easy this is will depend on what your numbers being converted need to be. The only method provided in relations to convert numeric values to text strings is the ITOS function. As its name implies it takes a number and converts it to an integer string, for example,

myString = ITOS ( 123.456 ) ==> myString = "123"

So, to do what you asked in your example, the relations code would be:

Local_description = ITOS(ad451) + "x" + ITOS(ad452) + "x" + ITOS(ad453)

Some caveats, however. A zero value yields an ITOS string that is blank. I think the number gets rounded up, i.e. ITOS(123.8) => "124".

If you want to convert real numbers and get strings with decimal places, that takes much more code, but is commonly done. You can certainly find examples in other discussions on this forum, like this one:

 

Old Real to String Discussion 

 

5-Regular Member
October 4, 2022

Thank you for the quick response! This works precisely as intended and is the solution for my initial question. 

tbraxton
22-Sapphire II
October 4, 2022

One method is to name the dimensions you want to use in a relation. In this example I have named the driving dimensions of the box to height, depth, and length. You can then use those names as parameters in notes or relations. Creo 7 model enclosed for reference.

 

See this article for details on protocol:

https://www.ptc.com/en/support/article/CS313862 

 

tbraxton_0-1664879342029.png

tbraxton_1-1664879392855.png

tbraxton_3-1664879500574.png

tbraxton_4-1664879528000.png

 

 

 

 

 

 

 

5-Regular Member
October 4, 2022

I understand the part where you give dimension specific names to better understand their function. But how I can translate this into using them to drive the naming of the local_description parameter, I don't fully understand. 
Luckily the answer above did exactly what I intended. 

KenFarley
21-Topaz II
October 4, 2022

The idea behind renaming dimensions is the same as what you'd do if you are writing a program. If I'm going to use a dimension in a relation, I *always* rename it to something that represents what it is. For example, as @tbraxton recommended, I'd probably go with something like "length", "width", etc. instead of the Creo default d### names. That way, when someone in the future (probably me) pops in to see what's going on with these relations, it is much more understandable, and easier to figure out where those dimensions are coming from. I do it as a favor to future me, not necessarily someone else, but there is no greater stomach-sinking feeling than opening up the relations on a model and finding it's all just "d12=d33+d101-d4488" stuff. You just want to cry, but resort to muttered vulgarities. Finding the feature or sketch that a particular dimension "belongs" to is not fun.

 

On the other hand, using dimensions in notes and stuff is pretty cool. Takes away one of the possible mistakes I would often make (not updating the notes to reflect dimensional changes) and really speeds up re-using models for other purposes. It's so nice to be able to generate a new version of something in minutes.