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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Convert a string to integer in Relations and integer / how can i calculate the blank weight of part?

PascalE
6-Contributor

Convert a string to integer in Relations and integer / how can i calculate the blank weight of part?

Hello,

 

I'm using creo 9.0.8.0 and need a formula to calculate the Blank weight.

 

Usually we write the dimensions down in a parameter like this 10x101x1. I did change it to 6 separate Parameters so that i have 3 for the number and 3 for the decimal places . I multiply the normal numbers in a relation to get the weight and merge the parameters to a single Parameter for the bom.

 

now the problem:

 

some of my colleges say its to complicated and time consuming to fill in those measurements and i need a simplier way of doing it. My new way to do it is by extracting the measurements from a single parameter.

 

The Problem with this solution is that creo cant calculate it that way because it says theyre all Strings and not integers. 

 

Any ideas how to calculate it? Or make it easier? 

PRO_MP_MASS is showing the current weight and not the blank one. And getting the numbers from the first profile isnt an option.

 

If you want i can provide you the current relation/params/part.

 

thanks in adavance

13 REPLIES 13

Hi,

MartinHanak_0-1713948879654.png

MartinHanak_1-1713948905784.png

 


Martin Hanák
PascalE
6-Contributor
(To:MartinHanak)

Thanks for you answer, but thats the current solution that my coworkers dont like. i need it the other way around. 

 

A problem we have with itos that the decimal is rounded down and up, what isnt a reliable solution for us.

Also we sometimes write mesurements like 10x101.00x20 so that the production sees withe the .00 that the block has to be grinded, what we do not have with itos.


@PascalE wrote:

Thanks for you answer, but thats the current solution that my coworkers dont like. i need it the other way around. 

 

A problem we have with itos that the decimal is rounded down and up, what isnt a reliable solution for us.

Also we sometimes write mesurements like 10x101.00x20 so that the production sees withe the .00 that the block has to be grinded, what we do not have with itos.


Hi,

in this case the only solution is additional application "attached" to Creo.

  • Creo Toolkit
  • Creo J-Link
  • AutoIT

 


Martin Hanák
PascalE
6-Contributor
(To:MartinHanak)

Hi,

 

if there would be a strtoi (String to Integer) function in creo it would be quite easy, i got the extraction so far with this:

 


if Search(ABMESSUNG, "x")!=0

GEWICHT=extract(ABMESSUNG,1,Search(ABMESSUNG, "x")-1)+"*"+extract(ABMESSUNG,Search(ABMESSUNG, "x")+1,String_length(ABMESSUNG)-Search(ABMESSUNG, "x"))

if Search(GEWICHT, "x")!=0

GEWICHT=extract(GEWICHT,1,Search(GEWICHT, "x")-1)+"*"+extract(GEWICHT,Search(GEWICHT, "x")+1,String_length(GEWICHT)-Search(GEWICHT, "x"))

if Search(GEWICHT, "x")!=0

GEWICHT=extract(GEWICHT,1,Search(GEWICHT, "x")-1)+"*"+extract(GEWICHT,Search(GEWICHT, "x")+1,String_length(GEWICHT)-Search(GEWICHT, "x"))

endif

endif

endif


 

Maybe someone here knows how to execute the builded calculation multiplied with the density, 

 

But i guess without a strtoi function its not possible to make it easily in relations.

BenLoosli
23-Emerald II
(To:PascalE)

With Creo 11, you will have a Real to String function, RTOS(number,3) for 3 decimal places.

RPN
17-Peridot
17-Peridot
(To:BenLoosli)

It is a bit annoying that there is no format function like in C where you can build your string by some common specifier with more then one input

 

mystring=format(„%dx%.2fx%d“, i_or_d_val1,i_or_d_val2, i_or_d_val3)

 

could easily provide the required result, rtos is a poor improvement in my point of view. 

And on top a Display Value is really required. 
The integration with Windchill is somewhat poor, there are common cases where you want to have a readable string on your drawing and not a weird database identifier where you can’t handle blanks. 

I wouldn’t have a problem when this is calculated during Post Regeneration. 

MartinHanak
24-Ruby II
(To:RPN)


@RPN wrote:

It is a bit annoying that there is no format function like in C where you can build your string by some common specifier with more then one input

 

mystring=format(„%dx%.2fx%d“, i_or_d_val1,i_or_d_val2, i_or_d_val3)

 

could easily provide the required result, rtos is a poor improvement in my point of view. 

And on top a Display Value is really required. 
The integration with Windchill is somewhat poor, there are common cases where you want to have a readable string on your drawing and not a weird database identifier where you can’t handle blanks. 

I wouldn’t have a problem when this is calculated during Post Regeneration. 


Hi,

also it is a pitty that sscanf() [C language] is not available in Creo relations.


Martin Hanák
RPN
17-Peridot
17-Peridot
(To:MartinHanak)

In my 3 days of using Creo, I had never the requirement to extract double or int values from a string inside of a relation. Do you have an example?


On the other side our drawing have the requirement to have leading ‚zero‘s

like 03/05 sheet 3 of 5

 

Without toolkit we had a very scrappy solution, but with the capability of formatting an integer, %02d is all what you need.

 

MartinHanak
24-Ruby II
(To:RPN)


@RPN wrote:

In my 3 days of using Creo, I had never the requirement to extract double or int values from a string inside of a relation. Do you have an example?


On the other side our drawing have the requirement to have leading ‚zero‘s

like 03/05 sheet 3 of 5

 

Without toolkit we had a very scrappy solution, but with the capability of formatting an integer, %02d is all what you need.

 


Hi,

OP has string parameter containing 10x101x1 value and needs to get 3 numerical values and multiply them together.


Martin Hanák
RPN
17-Peridot
17-Peridot
(To:MartinHanak)

But my assumption would be that this is modeled in Creo, in this case all original dims and parameter are available and the string 10x101x1 was build by a relation. In that case I don't want to create 2 new parameter. 

 

Just my 2 Cents😎 

KenFarley
21-Topaz I
(To:PascalE)

My understanding of the problem is you want to have a string parameter that specifies the raw blank dimensions in the form:

AAAA X BBBB X CCCC

And to be able to parse that string to obtain the three lengths that are separated by the " X ".

Being able to do this means the people entering the parameter are strictly following whatever rules you set up as to the numbers. Will they only be integer values? Are real (i.e. 25.3) values allowed? These are important things to know in order to attempt the process.

You'll also probably need some way to indicate to someone that there's an error, like if someone doesn't enter anything at all for the source string.

Basically you've got to extract the strings from the original string, then examine them to calculate the equivalent numeric value. Not easy, especially if you're dealing with a wide range of values. You'd have to know what the maximum value someone could use, etc.

Definitely look into the string handling functions available in the Creo relations, so you'll know what "tools" you have to work with.

BenLoosli
23-Emerald II
(To:PascalE)

Why do any math at all? Creo will give you the weight of your model when you assign a material to the model so it has a density. As for dimensions, those can be extracted from the model.

I don't understand why you need to 1) enter the size values in a string and 2) convert those to real numbers. Are you using your string values to drive the model design?

What is the difference in the current weight and the blank weight? if you are doing a machining operation, then create a blank part that is used to create the finished machined part. These can be related.

PascalE
6-Contributor
(To:BenLoosli)

We make make big stamping tools, so every prt we create is unique, a tool can easily get up to 500-1000prts if we would make for every prt a block to get the weight it would be to much time we waste just for it. Also our parts are to 99% made in house without a drawing for 95% of them, so its just showing the prt in the BOM.

We need the blank block weight and not the creo provided weight,

The dimension can't be extracted from the part like you say, because we are not only cutting out material from an existing block, were also adding, so it's not a reliable solution.

I need to make it in a string, because some of my collegues complain that it's too complicated with six parameters, before we had a single string, what they want to have back. So i need to convert it to numbers so that the relation is executable and calculates the weight.

As mentioned before, i need the 6 params to realise the ,00 at the end of some measurements.

It would be easy if the bounding box would show the the overall dimensions in a parameter, but thats not the case in creo9.

The string values are only used in the BOM, and if it would work for the weight.

Top Tags