home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p115 / 10.ddi / GCD4 / UPL / INSBCIR.UPL < prev    next >
Encoding:
Text File  |  1988-06-01  |  3.9 KB  |  86 lines

  1. --------------------------------------------------------------------------
  2. --INSBCIRC.UPL
  3. --This UPL program implements a new GCD command via UPL to insert circles 
  4. --in a bolt pattern.  
  5. --
  6. --This program demonstrates how a UPL program can be made to behave just
  7. --like a GCD command. An accompanying file INSCIR.DEF provides on-line help.
  8. --Appendix J, Writing GCD Commands in UPL, outlines the method used here.
  9. --
  10. --------------------------------------------------------------------------
  11.  
  12. $DataSize 5000  --this reduces the memory requirements of UPL, at most
  13.                 --we only use about 4900 bytes for data, the default value
  14.                 --of DataSize is 20000
  15.  
  16. proc main
  17.     const integer MaxDig = 400, CR = 13, Abort = 3, Colon = 58
  18.     integer NDigs, NHoles=8, i, j, IColor, IFont, ILayer
  19.     real HoleDia=1.0, CircleDia=5.0, BeginAngle=0.0, IncAngle=45.0, \
  20.          R, RC, RH, HAng
  21.     coord COrg, CirOrg(MaxDig)
  22.     string SVal:1
  23.     const string HelpFile = 'INSBCIR.HLP'
  24.     boolean FirstPass = True, Selected
  25.  
  26.     DefineModifier(1,"HOLEDia",    "R",False, HoleDia)
  27.     DefineModifier(2,"CIRDia",     "R",False, CircleDia)
  28.     DefineModifier(3,"ABegin",     "R",False, BeginAngle)
  29.     DefineModifier(4,"AIncrement", "R",False, IncAngle)
  30.     DefineModifier(5,"Nholes",     "I",False, real(NHoles))
  31.     SysVarI(1, IColor); DefineModifier(6, "COLor", "I", False, Real(IColor))
  32.     SysVarI(2, IFont);  DefineModifier(7, "FONt",  "I", False, Real(IFont))
  33.     SysVarI(3, ILayer); DefineModifier(8, "LAYer", "I", False, Real(ILayer))
  34.  
  35.     loop                                --loop to get modifiers
  36.         exit all when LastChar = Abort or LastChar = CR
  37.         
  38.         if not FirstPass or LastChar <> Colon then
  39.             SetHelp(HelpFile, 1,0,1)    --set up help indexes
  40.             AskModifiers(0)             --get modifier values from user
  41.             exit all when LastChar = Abort or LastChar = CR
  42.             GetModifier(1, Selected, HoleDia, SVal)
  43.             GetModifier(2, Selected, CircleDia, SVal)
  44.             GetModifier(3, Selected, BeginAngle, SVal)
  45.             GetModifier(4, Selected, IncAngle, SVal)
  46.             GetModifier(5, Selected, R, SVal); NHoles = integer(R)
  47.             GetModifier(6, Selected, R, SVal); IColor = integer(R)
  48.             GetModifier(7, Selected, R, SVal); IFont = integer(R)
  49.             GetModifier(8, Selected, R, SVal); ILayer = integer(R)
  50.         endif
  51.         
  52.         FirstPass = False           --FirstPass flag
  53.         RC = CircleDia*0.5          --Circle radius
  54.         RH = HoleDia*0.5            --Hole radius
  55.  
  56.         loop    
  57.             loop
  58.                 SetHelp(HelpFile, 1,1,1)            --set up getdata help index
  59.                 print "dig bolt circle centers: ",
  60.                 GetDig(MaxDig, 1, NDigs, CirOrg(1)) --get bolt circle origins
  61.                 exit all when LastChar = Abort      --user aborted command
  62.                 exit when NDigs > 0                 --got some origins
  63.                 exit all when LastChar = CR         --exit command
  64.                 exit 2 when LastChar = Colon        --go get new modifiers
  65.             end loop
  66.  
  67.             loop i = 1 to NDigs
  68.                 HAng = DegRad(BeginAngle)   --initialize starting angle
  69.                 COrg = MapMV(CirOrg(i))     --center of holes
  70.                 loop j = 1 to NHoles
  71.                     insert arc radius(RH) view(0) rpnt(true) org(COrg + \
  72.                                coord(RC*cos(HAng),RC*sin(HAng),CirOrg(i).Z))\
  73.                                color(IColor) layer(ILayer) font(IFont)
  74.                     HAng = HAng+DegRad(IncAngle)
  75.                 end loop
  76.             end loop
  77.             exit all when LastChar = CR     --all done
  78.             exit when LastChar = Colon      --get new modifiers
  79.         end loop
  80.     end loop
  81.  
  82.     SetHelp("",1,1,1)     --restore default help documentation
  83.  
  84. end proc
  85.  
  86.