home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------
- --INSBCIRC.UPL
- --This UPL program implements a new GCD command via UPL to insert circles
- --in a bolt pattern.
- --
- --This program demonstrates how a UPL program can be made to behave just
- --like a GCD command. An accompanying file INSCIR.DEF provides on-line help.
- --Appendix J, Writing GCD Commands in UPL, outlines the method used here.
- --
- --------------------------------------------------------------------------
-
- $DataSize 5000 --this reduces the memory requirements of UPL, at most
- --we only use about 4900 bytes for data, the default value
- --of DataSize is 20000
-
- proc main
- const integer MaxDig = 400, CR = 13, Abort = 3, Colon = 58
- integer NDigs, NHoles=8, i, j, IColor, IFont, ILayer
- real HoleDia=1.0, CircleDia=5.0, BeginAngle=0.0, IncAngle=45.0, \
- R, RC, RH, HAng
- coord COrg, CirOrg(MaxDig)
- string SVal:1
- const string HelpFile = 'INSBCIR.HLP'
- boolean FirstPass = True, Selected
-
- DefineModifier(1,"HOLEDia", "R",False, HoleDia)
- DefineModifier(2,"CIRDia", "R",False, CircleDia)
- DefineModifier(3,"ABegin", "R",False, BeginAngle)
- DefineModifier(4,"AIncrement", "R",False, IncAngle)
- DefineModifier(5,"Nholes", "I",False, real(NHoles))
- SysVarI(1, IColor); DefineModifier(6, "COLor", "I", False, Real(IColor))
- SysVarI(2, IFont); DefineModifier(7, "FONt", "I", False, Real(IFont))
- SysVarI(3, ILayer); DefineModifier(8, "LAYer", "I", False, Real(ILayer))
-
- loop --loop to get modifiers
- exit all when LastChar = Abort or LastChar = CR
-
- if not FirstPass or LastChar <> Colon then
- SetHelp(HelpFile, 1,0,1) --set up help indexes
- AskModifiers(0) --get modifier values from user
- exit all when LastChar = Abort or LastChar = CR
- GetModifier(1, Selected, HoleDia, SVal)
- GetModifier(2, Selected, CircleDia, SVal)
- GetModifier(3, Selected, BeginAngle, SVal)
- GetModifier(4, Selected, IncAngle, SVal)
- GetModifier(5, Selected, R, SVal); NHoles = integer(R)
- GetModifier(6, Selected, R, SVal); IColor = integer(R)
- GetModifier(7, Selected, R, SVal); IFont = integer(R)
- GetModifier(8, Selected, R, SVal); ILayer = integer(R)
- endif
-
- FirstPass = False --FirstPass flag
- RC = CircleDia*0.5 --Circle radius
- RH = HoleDia*0.5 --Hole radius
-
- loop
- loop
- SetHelp(HelpFile, 1,1,1) --set up getdata help index
- print "dig bolt circle centers: ",
- GetDig(MaxDig, 1, NDigs, CirOrg(1)) --get bolt circle origins
- exit all when LastChar = Abort --user aborted command
- exit when NDigs > 0 --got some origins
- exit all when LastChar = CR --exit command
- exit 2 when LastChar = Colon --go get new modifiers
- end loop
-
- loop i = 1 to NDigs
- HAng = DegRad(BeginAngle) --initialize starting angle
- COrg = MapMV(CirOrg(i)) --center of holes
- loop j = 1 to NHoles
- insert arc radius(RH) view(0) rpnt(true) org(COrg + \
- coord(RC*cos(HAng),RC*sin(HAng),CirOrg(i).Z))\
- color(IColor) layer(ILayer) font(IFont)
- HAng = HAng+DegRad(IncAngle)
- end loop
- end loop
- exit all when LastChar = CR --all done
- exit when LastChar = Colon --get new modifiers
- end loop
- end loop
-
- SetHelp("",1,1,1) --restore default help documentation
-
- end proc
-