Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to real 2

Status
Not open for further replies.

matteo1578

Mechanical
May 30, 2012
4
Hi all,
I am a new member of this forum.

I want to ask a simple (I hope) question:

Suppose you have a file whose name indicates the measures of the piece (height, width, thickness), so for example:
2000x1000x10 (a panel in practice).

Using these relations:
height = EXTRACT (REL_MODEL_NAME, 1.4)
width = EXTRACT (REL_MODEL_NAME, 6.4)
thickness = EXTRACT (REL_MODEL_NAME, 11.2)

I get the parameters:
height = 2000
width = 1000
thickness = 10

All these values ​​are STRING. Is there a way to turn them into numbers?

Thank you!
 
Replies continue below

Recommended for you


....obviously, the correct syntax is this:

height = EXTRACT (REL_MODEL_NAME,1,4)
width = EXTRACT (REL_MODEL_NAME,6,4)
thickness = EXTRACT (REL_MODEL_NAME,11,2)
 
First a comment on your file name. Use a better naming system! What happens if you need to add holes to one of your panels, or need 2 panels with different holes, but the same panel.

You need a much more complex set of relations to convert a string into a real number.

The relations you have limit your plate to length and width of 1000 to 9999 and thinkness to 10 to 99.



"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
Thank for the answer Ben.

Your considerations are right, but it's just what I need.

I know that I need a much more complex set of relations for conversion...I would like to know the way!:)

Thank you for your help
 
Hallo Ben,
then I can not count on your help?

Greetings
 
First off welcome to the forums.

I'm going to start off with some questions & constructive criticism which I hope you don't take offense to.

Do you not have a reseller that you bought Pro/E from who can help you out with your problem as well?
While you may often find people here that may have better solutions than your Channel Partner or whatever the support providers are now called "Creo Support Partners".

Ben may have an answer for you, but he isn't getting paid to solve your problems so you can't expect him to do all your work for you.

Here's a suggestion from me.
What if you go about this the other way around and have your parameters as real numbers and drive your Strings for name from the numbers?

I also think that the naming convention may not be the best but if it's due to company standards already in place already maybe those can be revisited. As long as you take into account what your max sizes will be ahead of time and find a way to fit the 31char limit imposed on part files by PTC if that's still true you may be able to do the convert operation.

Ideally you should have a part numbers/names system that gives unique names to every part either by project_number part_type or customer_id then the other parameters like part size can be made as Integers Real or whatever you need to use them for.

You can also check out the PTC forums if they exist and use them. The SolidWorks forums are open to all users even those without the professional version. I'll post a link to it if I find one but you can also try other forum sites like the one that ends in central.com although the usage of that site has dropped.

I wish you the best and will try to help out but I cannot guarantee answers or results for this specific question.

"It's not the size of the Forum that matters, It's the Quality of the Posts"

Michael Cole
Boston, MA
CSWP, CSWI, CSWTS
Follow me on !w¡#$%
@ TrajPar - @ mcSldWrx2008
= ProE = SolidWorks
 
It isn't pretty, but you will get the task ahead to make it work from this example.

digit_1 = extract(thickness,1,1)
digit_2 = extract(thickness,2,1)
if digit_1 == "1"
value1 = 1
endif
if digit_1 == "2"
value1 = 2
endif
if digit_1 == "3"
value1 = 3
endif
if digit_1 == "4"
value1 = 4
endif
if digit_2 == "0"
value2 = 0
endif
if digit_2 == "5"
value2 = 5
endif
value = value1*10 + value2


"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor