Skip to main content
14-Alexandrite
October 23, 2023
Solved

STOCK SIZE PARAMETER IN MODEL?

  • October 23, 2023
  • 3 replies
  • 4889 views

Creo 7

This seems insane that its not easier than this.

I can not figure out how to get my parameter in my model to display my full stock size?

I have the following parameters: thickness / width / length

 

Then I have a relation: thickness=d12, width=d9, length=d10 (and these default to 2 decimal places)

 

So then I thought, the relation, (stock_size = thickness "x" width "x" length) would give me what I'm after.

Ex 1.50 x 2.50 x 3.50

Nope, further digging got me to the following equation:

 

STOCK_SIZE = itos(D12) + "." + itos( (D12 - floor(D12)) * 100 ) + " X " + itos(d9) + "." + itos( (d9- floor(d9)) * 100 ) + " X " + itos(d10) + "." + itos( (d10- floor(d10)) * 100 )

 

Which I arrived at because I needed this specific "itos" function to give me 2 decimal places. Now I get 2.50 x 3.50 x 4.50? (Not the 1.50 x 2.50 x 3.50 that it should be)

 

So all my values have increased by (1) somehow.

The itos function makes no sense to me but I suppose it works if I can find out what is causing it to increase all my values by (1)?

 

 

 

Best answer by KenFarley

Here's a previous discussion that deals with this topic. The answer I gave is a bit more complicated, preventing weird results and taking into account all the possiblities of dimensional values.

https://community.ptc.com/t5/3D-Part-Assembly-Design/How-to-make-text-with-dimensions/m-p/492558 

3 replies

19-Tanzanite
October 24, 2023

Lol, it's been a while since this classic issue showed up on the forum.

I am not sure, but your formulas for deriving the string representation of a number seem different from what I am used to.

This thread is my go-to for the hack needed:

Converting Real Numbers to Strings

KenFarley
21-Topaz II
October 24, 2023

The ITOS function will round numbers before giving you the results. So ITOS ( 1.50 ) = "2".

You need to use the floor function when generating the integer portion of your number i.e. ITOS ( floor ( D12 ) ).

Another danger of the ITOS function that has annoyed me for years is that ITOS ( 0 ) = "", or that a zero value doesn't yield the zero character, but an empty string.

KenFarley
KenFarley21-Topaz IIAnswer
21-Topaz II
October 24, 2023

Here's a previous discussion that deals with this topic. The answer I gave is a bit more complicated, preventing weird results and taking into account all the possiblities of dimensional values.

https://community.ptc.com/t5/3D-Part-Assembly-Design/How-to-make-text-with-dimensions/m-p/492558 

MORECREO14-AlexandriteAuthor
14-Alexandrite
October 24, 2023

That seems like an insane way to get there. Very "Creo" like lol. However, that worked great. Thank you!

23-Emerald III
October 24, 2023

https://community.ptc.com/t5/Creo-Parametric-Ideas/RTOS-function-in-relations/idi-p/469120

Please vote on the product enhancement request from 2014...you know it's way older but this is the one with the most votes and isn't archived.

KenFarley
21-Topaz II
October 24, 2023

Wow, I'd never seen that idea.

The coding for such a function would be pretty simple. It's the kind of problem one gets for a beginner level programming class.