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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Renaming a parameter value based on a dimension value

RA_9969089
4-Participant

Renaming a parameter value based on a dimension value

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? 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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 

 

View solution in original post

9 REPLIES 9

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 

 

RA_9969089
4-Participant
(To:KenFarley)

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

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

 

 

 

 

 

 

 

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
RA_9969089
4-Participant
(To:tbraxton)

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. 

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.

My suggested approach is based on an assumption about how you wanted to use the values. What exactly do you need to use the parameter local_description for? Is it used in a note or in a table cell on a drawing, or something else? Why is it important to have local desc to have a string dependent on model dimensions?

 

The method I shared is fully parametric, is very robust and does not require any relations. You can of course use the dimension names in relations. I used them to create a model note whose values are driven by the dimensions.

 

I only named the dimensions using a word to clarify how to do it. There is no need to rename the dimensions to use them.

 

Using this syntax (below) you have a parametric note driven by the dimension values. You can concatenate dim values to form a note with multiple dims without using ITOS function. 

Part size: &length x &depth x &height

 

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric
RA_9969089
4-Participant
(To:tbraxton)

We use the local_description on drawings specifying the outer dimensions of a part, and we create a lot of different variations. So I just wanted to make a automated workflow, minimizing the amount of work I have to do and minimizing mistakes. 

 

But I sitll don't follow where I use this syntax in order to do the intended. 

Part size: &length x &depth x &height

I agree on naming dimensions instead of using default "ad451" naming scheme, and I already practice that since it makes creating relations a lot easier. 
I also comment to an extend to clarify further what specific relations does, just so I can remember it myself in the future.  

You can just use the syntax presented in a note in the part or on the drawing. If you turn on annotation display in the model I posted you should see the model note as shown in the screen shots with the dimensions.

 

If you edit that note you will see the syntax using the dimension values. 

 

Based on your use case I would create a note and use the dimension values in the note. This will be fully parametric and will update with changes to the model.

========================================
Involute Development, LLC
Consulting Engineers
Specialists in Creo Parametric

Yeah, totally agree with this philosophy. Parameters are handy if I'm not using the actual dimensions, but something like, for example, the size of a raw block I might need (i.e. the part is 12.117 long, but raw stock only comes in increments of 0.25, so I need at least 12.25 long raw stock). Or maybe I want a metric number in the note when the model is in inches.

Also, remember you can specify the number of decimal places that are shown for your dimension by appending [.#] to the dimension name, for example if diaPart = 12.13347, if I say in a note &diaPart[.3] the number will be displayed as "12.133", otherwise just using &diaPart will use all the decimal places.

Top Tags