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

SOLVED
Highlighted
Visitor

## how to convert a decimal numeric dimension to a fraction in an ebom drawing table

I am trying to convert a decimal numeric dimension to a fraction in an ebom drawing table. I have already added a parameter to the dimension and I am able to reference the parameter in the table. I don't want to convert the dimension in the model, only on the drawing table. How would I do that?

Tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: how to convert a decimal numeric dimension to a fraction in an ebom drawing table

Hi all,

John,

You can add a relation block to implement a 'repeated multiplication by 2' algorithm.

It is kind of ugly code, but with the limited pro/relations syntax we have to use what we could.

Something like this:

test =7/64 /* replace 7/64 with dimension symbol, works for positive numbers

test0=floor(test)

test2 = mod(test,1) *2

if floor(test2) > 0
first=1
denomiator = 2
numerator = 1
else
first = 0
endif

test4 = mod( test2, 1) * 2
if floor(test4) > 0
second=1
denomiator = 4
numerator = 1*second + 2*first
else
second = 0
endif

test8 = mod( test4, 1) * 2
if floor(test8) > 0
third=1
denomiator = 8
numerator = 1*third + 2*second + 4*first
else
third = 0
endif

test16 = mod( test8, 1) * 2
if floor(test16) > 0
fourth=1
denomiator = 16
numerator = 1 * fourth + 2*third + 4*second + 8*first
else
fourth = 0
endif

test32 = mod( test16, 1) * 2
if floor(test32) > 0
fifth=1
denomiator = 32
numerator = 1*fifth + 2*fourth + 4*third + 8*second + 16*first
else
fifth = 0
endif

test64 = mod( test32, 1) * 2
if floor(test64) > 0
sixth=1
denomiator = 64
numerator = 1*sixth + 2*fifth + 4*fourth + 8*third + 16*second + 32*first
else
sixth = 0
endif

result = itos( test0) + "-" + itos( numerator) + "/" + itos(denominator) /* string representation of fractional number

HIH.

Feliks.

2 REPLIES 2
Highlighted

## Re: how to convert a decimal numeric dimension to a fraction in an ebom drawing table

Hi all,

John,

You can add a relation block to implement a 'repeated multiplication by 2' algorithm.

It is kind of ugly code, but with the limited pro/relations syntax we have to use what we could.

Something like this:

test =7/64 /* replace 7/64 with dimension symbol, works for positive numbers

test0=floor(test)

test2 = mod(test,1) *2

if floor(test2) > 0
first=1
denomiator = 2
numerator = 1
else
first = 0
endif

test4 = mod( test2, 1) * 2
if floor(test4) > 0
second=1
denomiator = 4
numerator = 1*second + 2*first
else
second = 0
endif

test8 = mod( test4, 1) * 2
if floor(test8) > 0
third=1
denomiator = 8
numerator = 1*third + 2*second + 4*first
else
third = 0
endif

test16 = mod( test8, 1) * 2
if floor(test16) > 0
fourth=1
denomiator = 16
numerator = 1 * fourth + 2*third + 4*second + 8*first
else
fourth = 0
endif

test32 = mod( test16, 1) * 2
if floor(test32) > 0
fifth=1
denomiator = 32
numerator = 1*fifth + 2*fourth + 4*third + 8*second + 16*first
else
fifth = 0
endif

test64 = mod( test32, 1) * 2
if floor(test64) > 0
sixth=1
denomiator = 64
numerator = 1*sixth + 2*fifth + 4*fourth + 8*third + 16*second + 32*first
else
sixth = 0
endif

result = itos( test0) + "-" + itos( numerator) + "/" + itos(denominator) /* string representation of fractional number

HIH.

Feliks.

Highlighted

## Re: how to convert a decimal numeric dimension to a fraction in an ebom drawing table

Hello John,

did the answer from Feliks help you solve your issue?

If yes, please let us know, i.e. mark the answer as correct to signal the thread has been answered.

Thanks,

Gunter

Announcements