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

SOLVED
Highlighted
Amethyst

## Does anyone know how to achieve it in Creo?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Does anyone know how to achieve it in Creo?

Hello,

use the following relations:

/* v ... real parameter

/* y ... real parameter

/* x1 ... string parameter

/* d0 ... name of diameter dimension

/*******************************************

v=0

/*******************************************

x1=extract(rel_model_name(),4,1)

y=1000

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

x1=extract(rel_model_name(),5,1)

y=100

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

x1=extract(rel_model_name(),6,1)

y=10

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

x1=extract(rel_model_name(),7,1)

y=1

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

d0=v

Rename part and regenerate it.

Martin Hanak

Martin Hanák
5 REPLIES 5
Highlighted

## Re: Does anyone know how to achieve it in Creo?

Hello,

use the following relations:

/* v ... real parameter

/* y ... real parameter

/* x1 ... string parameter

/* d0 ... name of diameter dimension

/*******************************************

v=0

/*******************************************

x1=extract(rel_model_name(),4,1)

y=1000

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

x1=extract(rel_model_name(),5,1)

y=100

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

x1=extract(rel_model_name(),6,1)

y=10

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

x1=extract(rel_model_name(),7,1)

y=1

if x1=="0"

v=v+0*y

endif

if x1=="1"

v=v+1*y

endif

if x1=="2"

v=v+2*y

endif

if x1=="3"

v=v+3*y

endif

if x1=="4"

v=v+4*y

endif

if x1=="5"

v=v+5*y

endif

if x1=="6"

v=v+6*y

endif

if x1=="7"

v=v+7*y

endif

if x1=="8"

v=v+8*y

endif

if x1=="9"

v=v+9*y

endif

/*******************************************

d0=v

Rename part and regenerate it.

Martin Hanak

Martin Hanák

Family tables?

John

Highlighted

## Re: Does anyone know how to achieve it in Creo?

yes,recently I have made a part using family tables, I want to use part name to control the dimension.

Highlighted

## Re: Does anyone know how to achieve it in Creo?

You may also wish to use the string_length()function to make the relations insensitive to overall part name length.

The above assumes the filename is always 7 characters long.

It might also be more compact with the search function. search() returns a 0 if a match isn't found, so if you want to add if/endif statements to allow using this on shorter number sequences, then that's an option.

Create parameters:

digitlist, type string

value, type real

digit_found, type integer

digitlist = "0123456789"

value = 0

/* because the search function returns the number of the item in the list

/* it is necessary to subtract '1' from the result; for example '0' will be position 1,

/* but the value should be one less than that

/* the one's position is the end of the character string

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name),1)-1

value = value+digit_found

/* the ten's position is one less than the end of the character string

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name)-1,1)-1

value = value+digit_found*10

/* the hundred's position should be obvious by now

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name)-2,1)-1

value = value+digit_found*100

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name)-3,1)-1

value = value+digit_found*1000

d0=value

**************************************************************************************************

digitlist = "0123456789"

value = 0

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name),1)-1

value = value+digit_found

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name)-1,1)-1

value = value+digit_found*10

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name)-2,1)-1

value = value+digit_found*100

digit_found = search(digitlist,extract(rel_model_name(),len(rel_model_name)-3,1)-1

value = value+digit_found*1000

d0=value

Highlighted

## Re: Does anyone know how to achieve it in Creo?

David,

I'll try to remember your smart solution .

Martin Hanak

Martin Hanák
Announcements