Fabrication CADmep™ > CADmep™ Worksheets & Reports

Elevations on Worksheets

<< < (7/8) > >>

DonWunder:

--- Quote from: jmerch on Nov 15, 2012, 22:08:01 PM ---k, so now what about multiple "if" statements to round to 1/4 and up?  I tried putting them all in under

dim frac
if......then 1/8
if.....then 1/4
endif
endif

I also tried individual if and that errored.

--- End quote ---


--- Code: ---if (value1 >= .0625 and value1 < .1875) then
  fraction = "1/8"
endif

if (value1 >= .1875 and value1 < .3125) then
  fraction = "1/4"
endif
--- End code ---

and so on

jmerch:
I tried that, it's not reading it.  I've got

dim frac at the beginning, then the if statements with endif after each, and it's not completing the code for the fraction.

jabowabo:
The function here will change input decimal inches to feet and fractional inches.


--- Code: ---Function GetTotFtInFrac(ti)
dim quote = ascii(34)
dim apos = ascii(39)
dim decfeet
dim feet
dim decinch
dim inch
dim dec
dim frac = ""
dim result

decfeet = ti/12
feet = rounddown(decfeet)

decinch = (decfeet - feet)*12
inch = rounddown(decinch)
dec = decinch - inch

select dec
case > .9374
frac = ""
inch = inch + 1
case > .8124
frac = "7/8"
case > .6874
frac = "3/4"
case > .5624
frac = "5/8"
case > .4374
frac = "1/2"
case > .3124
frac = "3/8"
case > .1874
frac = "1/4"
case > .0624
frac = "1/8"

end select


result = feet + apos + "-" + inch + " " + frac + quote
return result
End Function

dim totalinchesdec = inputbox("Enter Inches","Inches",0)
dim totftinfrac = GetTotFtInFrac(totalinchesdec)
debug totftinfrac

--- End code ---

cam-nav:
Jabo, the "If" statement worked good too. I got it to output what I wanted with a click on the item.

The only thing I changed was "select number(dec)"

You need to have the script convert to a "number" before the case select will work. Unless you pass through a number but mine was passing a string.

jmerch:
Thanks to all you guys.  This should help out quite a bit until Autodesk/MAP actually organize this better on their end.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version