Author Topic: Elevations on Worksheets  (Read 13080 times)

0 Members and 1 Guest are viewing this topic.

Offline DonWunder

  • Senior Member
  • ****
  • Posts: 274
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #30 on: Nov 16, 2012, 04:13:08 AM »
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.

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

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

and so on
Don Wunderlich
The Hill Group

Offline jmerchTopic starter

  • Premier Member
  • *****
  • Posts: 2297
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #31 on: Nov 16, 2012, 04:22:43 AM »
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.
Intel i7-6700K @ 4 GHz - 32GB RAM - NVidia Quadro M5000 - W10x64 - MEP & FABRICATION 2014/2017 - NAVIS 2017 - REVIT 2017.1

Offline jabowabo

  • Premier Member
  • *****
  • Posts: 974
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #32 on: Nov 16, 2012, 15:16:20 PM »
The function here will change input decimal inches to feet and fractional inches.

Code: [Select]
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
My Free CAD Apps
My LinkedIn

Offline cam-nav

  • Premier Member
  • *****
  • Posts: 4077
  • Country: us
  • Gender: Male
    • McKinstry.com
Re: Elevations on Worksheets
« Reply #33 on: Nov 16, 2012, 15:44:08 PM »
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.
Dave

Offline jmerchTopic starter

  • Premier Member
  • *****
  • Posts: 2297
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #34 on: Nov 16, 2012, 15:50:48 PM »
Thanks to all you guys.  This should help out quite a bit until Autodesk/MAP actually organize this better on their end.
Intel i7-6700K @ 4 GHz - 32GB RAM - NVidia Quadro M5000 - W10x64 - MEP & FABRICATION 2014/2017 - NAVIS 2017 - REVIT 2017.1

Offline jmerchTopic starter

  • Premier Member
  • *****
  • Posts: 2297
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #35 on: Nov 16, 2012, 21:11:19 PM »
Here is the final script for anyone else.  Thanks to Don, Jabo, and Dave for the input and putting this together!

Code: [Select]
dim quote = ascii(34)
dim ft = ascii(39)
dim cr = ascii(10)

select item.cid
  case 838,8382,8384

dim sBtm = item.endlocation(1,"Btm")
dim len = len(sBtm)
dim pt = instr(1,sBtm,".")
pt = pt-1
dim getfrac = right(sBtm,(len-pt))
dim inch = left(sBtm,pt)
dim frac = 0
dim getfeet = number(inch)/12
dim feet = rounddown(getfeet)
dim decinch = (getfeet - feet)*12

if getfrac < .9375 then
        select number(getfrac)
            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"
            case > .9374
                frac = ""
                inch = inch + 1
        end select
end if

rem debug "sBtm - " + sBtm +cr+cr+ "len sBtm - " + len +cr+cr+ "pt sBtm - " + pt +cr+cr+ "getdec/getfrac - " + getfrac +cr+cr+ "inch - " + inch +cr+cr+ "frac - " + frac +cr+cr+ "getfeet - " + getfeet +cr+cr+ "feet - " + feet +cr+cr+ "decinch - " + decinch

dim BtmElev
if feet > 0 then
BtmElev = feet + ft + "-" + decinch + " " + frac + quote
else
BtmElev = decinch + " " + frac + quote
end if

rem debug BtmElev

item.customdata["Hanger Wksht Elevation"].value=BtmElev
endselect
Intel i7-6700K @ 4 GHz - 32GB RAM - NVidia Quadro M5000 - W10x64 - MEP & FABRICATION 2014/2017 - NAVIS 2017 - REVIT 2017.1

Offline cadmium

  • Senior Member
  • ****
  • Posts: 308
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #36 on: Feb 17, 2017, 20:31:28 PM »
This is great, I cant believe I missed this thread.  Can anyone help me do one more custom field, maybe added to this script that just adds item dimension list 6 and 7?
This would give me a total rod length that I could put on our labels.

Offline dopefish

  • Senior Member
  • ****
  • Posts: 429
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #37 on: Feb 15, 2018, 18:32:09 PM »
Tried running this and got an error on line 52. "value=" was highlighted.
"And the wood header is still 4  3/4" on top of the top of the double top plate." . . . Random VDC Coodinator

I love coordination

Offline myohalem

  • Active Member
  • **
  • Posts: 1
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #38 on: May 31, 2024, 13:49:09 PM »
did you ever fix that line 52 error?

Offline dopefish

  • Senior Member
  • ****
  • Posts: 429
  • Country: us
  • Gender: Male
Re: Elevations on Worksheets
« Reply #39 on: Jun 01, 2024, 21:44:05 PM »
Hey Mo. Let me take a look at my script for this and see what I did. But I did get this working at some point.
"And the wood header is still 4  3/4" on top of the top of the double top plate." . . . Random VDC Coodinator

I love coordination