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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

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

jbennett
3-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?


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 ACCEPTED SOLUTION

Accepted Solutions
FV
17-Peridot
17-Peridot
(To:jbennett)

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.

View solution in original post

2 REPLIES 2
FV
17-Peridot
17-Peridot
(To:jbennett)

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.

gkoch
1-Newbie
(To:jbennett)

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

Top Tags