home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CADKEY_C.ZIP / CADKEY14.ZIP / CDL / SH_KIN.CDL < prev    next >
Encoding:
Text File  |  1980-01-01  |  8.2 KB  |  317 lines

  1. REM     Name:     sh_kin.cdl
  2. REM
  3. REM     Date:     011089 simon izraelevitz
  4. REM
  5. REM     Task:     Constructs a keyway shape given the shaft diameter, the
  6. REM               distance of the key way to the opposite edge, and the 
  7. REM               key way width.
  8. REM               The user has the option to create the key way centerlines.
  9. REM 
  10. REM     Note:     A message is displayed for all error conditions.
  11. REM
  12. REM     -----------------------------------------------
  13.  
  14.    CLEAR
  15.  
  16. REM define icon scale factor
  17.    sc = 1 / @scale
  18.  
  19. REM compute icon oval origin
  20.    xinc = (@xmax - @xmin)/10
  21.    yinc = (@ymax - @ymin)/10
  22.    ox = @xmax - 3*xinc
  23.    oy = @ymax - 3*yinc
  24.  
  25. REM create icon geometry
  26.    MODE DRAW
  27.  
  28.    x = ox + ( 0.0000000*sc)
  29.    y = oy + ( 0.0000000*sc)
  30.    r = 1.0000000*sc
  31.    ARC x, y, @depth, r, 41.5369587, 378.4630324, 0, 5
  32.  
  33.    x1 = ox + ( 0.9485281*sc)
  34.    y1 = oy + ( 0.3166929*sc)
  35.    x2 = ox + ( 0.6712232*sc)
  36.    y2 = oy + ( 0.1565909*sc)
  37.    VLINE x1, y1, @depth, x2, y2, @depth, 0, 5
  38.  
  39.    x1 = ox + ( 0.7485281*sc)
  40.    y1 = oy + ( 0.6631030*sc)
  41.    x2 = ox + ( 0.4712233*sc)
  42.    y2 = oy + ( 0.5030010*sc)
  43.    VLINE x1, y1, @depth, x2, y2, @depth, 0, 5
  44.  
  45.    x1 = ox + ( 0.6712232*sc)
  46.    y1 = oy + ( 0.1565909*sc)
  47.    x2 = ox + ( 0.4712233*sc)
  48.    y2 = oy + ( 0.5030010*sc)
  49.    VLINE x1, y1, @depth, x2, y2, @depth, 0, 5
  50.  
  51.    x1 = ox + ( 0.6000000*sc)
  52.    y1 = oy + (-1.0392305*sc)
  53.    x2 = ox + (-0.6000000*sc)
  54.    y2 = oy + ( 1.0392305*sc)
  55.    VLINE x1, y1, @depth, x2, y2, @depth, 0, 5, 0, 3
  56.  
  57.    x1 = ox + (-1.0392305*sc)
  58.    y1 = oy + (-0.6000000*sc)
  59.    x2 = ox + ( 1.0392305*sc)
  60.    y2 = oy + ( 0.6000000*sc)
  61.    VLINE x1, y1, @depth, x2, y2, @depth, 0, 5, 0, 3
  62.  
  63.    x1 = ox + ( 1.5022154*sc)
  64.    y1 = oy + ( 0.0000000*sc)
  65.    x2 = ox + (-1.3720618*sc)
  66.    y2 = oy + ( 0.0000000*sc)
  67.    VLINE x1, y1, @depth, x2, y2, @depth, 0, 5, 0, 3
  68.  
  69. REM draw 'W' dimension
  70.    ARRAY GENDAT[22]
  71.    GENDAT[ 0] = ox + ( 0.8784319*sc)
  72.    GENDAT[ 1] = oy + ( 0.7381030*sc)
  73.    GENDAT[ 2] = ox + ( 1.2729704*sc)
  74.    GENDAT[ 3] = oy + ( 0.9658900*sc)
  75.    GENDAT[ 4] = ox + ( 1.0784320*sc)
  76.    GENDAT[ 5] = oy + ( 0.3916928*sc)
  77.    GENDAT[ 6] = ox + ( 1.4729705*sc)
  78.    GENDAT[ 7] = oy + ( 0.6194797*sc)
  79.    GENDAT[ 8] = ox + ( 0.9080186*sc)
  80.    GENDAT[ 9] = oy + ( 1.4480053*sc)
  81.    GENDAT[10] = ox + ( 1.2080185*sc)
  82.    GENDAT[11] = oy + ( 0.9283900*sc)
  83.    GENDAT[12] = ox + ( 1.7080185*sc)
  84.    GENDAT[13] = oy + ( 0.0623643*sc)
  85.    GENDAT[14] = ox + ( 1.4080186*sc)
  86.    GENDAT[15] = oy + ( 0.5819796*sc)
  87.    GENDAT[16] = ox + ( 1.2080185*sc)
  88.    GENDAT[17] = oy + ( 0.9283900*sc)
  89.    GENDAT[18] = 120.0000000
  90.    GENDAT[19] = ox + ( 1.4080186*sc)
  91.    GENDAT[20] = oy + ( 0.5819796*sc)
  92.    GENDAT[21] = -60.0000000
  93.  
  94.    x = ox + ( 1.2301614*sc)
  95.    y = oy + ( 0.6101335*sc)
  96.  
  97.    GENDIM    50, 4, 0, 2, GENDAT, 1, x, y, `W
  98. `, 0.0000000, 0.3000000*sc, 0.5000000, 0, 5
  99.  
  100. REM draw 'L' dimension
  101.    ARRAY GENDAT[22]
  102.    GENDAT[ 0] = ox + (-0.7910254*sc)
  103.    GENDAT[ 1] = oy + (-0.6299038*sc)
  104.    GENDAT[ 2] = ox + (-0.1049144*sc)
  105.    GENDAT[ 3] = oy + (-1.8182828*sc)
  106.    GENDAT[ 4] = ox + ( 0.6462232*sc)
  107.    GENDAT[ 5] = oy + ( 0.1998921*sc)
  108.    GENDAT[ 6] = ox + ( 1.3323343*sc)
  109.    GENDAT[ 7] = oy + (-0.9884869*sc)
  110.    GENDAT[ 8] = ox + ( 0.3482646*sc)
  111.    GENDAT[ 9] = oy + (-1.4700372*sc)
  112.    GENDAT[10] = ox + (-0.1424144*sc)
  113.    GENDAT[11] = oy + (-1.7533309*sc)
  114.    GENDAT[12] = ox + ( 0.7982646*sc)
  115.    GENDAT[13] = oy + (-1.2102296*sc)
  116.    GENDAT[14] = ox + ( 1.2948343*sc)
  117.    GENDAT[15] = oy + (-0.9235350*sc)
  118.    GENDAT[16] = ox + (-0.1424144*sc)
  119.    GENDAT[17] = oy + (-1.7533309*sc)
  120.    GENDAT[18] = 30.0000000
  121.    GENDAT[19] = ox + ( 1.2948343*sc)
  122.    GENDAT[20] = oy + (-0.9235350*sc)
  123.    GENDAT[21] = -150.0000000
  124.  
  125.    x = ox + ( 0.4982646*sc)
  126.    y = oy + (-1.4901334*sc)
  127.  
  128.    GENDIM    50, 4, 0, 2, GENDAT, 1, x, y, `L
  129. `, 0.0000000, 0.3000000*sc, 0.5000000, 0, 5
  130.  
  131. REM draw 'D' dimension
  132.    ARRAY GENDAT[22]
  133.    GENDAT[ 0] = ox + ( 0.1663187*sc)
  134.    GENDAT[ 1] = oy + ( 1.5077335*sc)
  135.    GENDAT[ 2] = ox + ( 0.4663187*sc)
  136.    GENDAT[ 3] = oy + ( 1.5077335*sc)
  137.    GENDAT[ 4] = ox + ( 0.4663187*sc)
  138.    GENDAT[ 5] = oy + ( 1.5077335*sc)
  139.    GENDAT[ 6] = ox + ( 0.2954751*sc)
  140.    GENDAT[ 7] = oy + ( 0.9553505*sc)
  141.    GENDAT[ 8] = ox + ( 0.0000000*sc)
  142.    GENDAT[ 9] = oy + ( 0.0000000*sc)
  143.    GENDAT[10] = ox + ( 0.2954751*sc)
  144.    GENDAT[11] = oy + ( 0.9553505*sc)
  145.    GENDAT[12] = ox + ( 0.0000000*sc)
  146.    GENDAT[13] = oy + ( 0.0000000*sc)
  147.    GENDAT[14] = ox + (-0.2954751*sc)
  148.    GENDAT[15] = oy + (-0.9553505*sc)
  149.    GENDAT[16] = ox + ( 0.2954751*sc)
  150.    GENDAT[17] = oy + ( 0.9553505*sc)
  151.    GENDAT[18] = 252.8139648
  152.    GENDAT[19] = ox + (-0.2954751*sc)
  153.    GENDAT[20] = oy + (-0.9553505*sc)
  154.    GENDAT[21] = 72.8139725
  155.  
  156.    x = ox + (-0.1336814*sc)
  157.    y = oy + ( 1.3577335*sc)
  158.  
  159.    GENDIM    52, 4, 0, 2, GENDAT, 1, x, y, `D
  160. `, 0.0000000, 0.3000000*sc, 0.5000000, 0, 5
  161.  
  162. REM draw 'Rot' dimension
  163.    ARRAY GENDAT[24]
  164.    GENDAT[ 0] = ox + (-1.5220618*sc)
  165.    GENDAT[ 1] = oy + ( 0.0000000*sc)
  166.    GENDAT[ 2] = ox + (-1.6873851*sc)
  167.    GENDAT[ 3] = oy + ( 0.0000000*sc)
  168.    GENDAT[ 4] = ox + (-1.1691343*sc)
  169.    GENDAT[ 5] = oy + (-0.6750000*sc)
  170.    GENDAT[ 6] = ox + (-1.4613183*sc)
  171.    GENDAT[ 7] = oy + (-0.8436925*sc)
  172.    GENDAT[ 8] = ox + ( 0.0000000*sc)
  173.    GENDAT[ 9] = oy + ( 0.0000000*sc)
  174.    GENDAT[10] = 1.6123850*sc
  175.    GENDAT[11] = 158.6791229
  176.    GENDAT[12] = 180.0000000
  177.    GENDAT[13] = ox + ( 0.0000000*sc)
  178.    GENDAT[14] = oy + ( 0.0000000*sc)
  179.    GENDAT[15] = 1.6123850*sc
  180.    GENDAT[16] = 210.0000000
  181.    GENDAT[17] = 231.3208923
  182.    GENDAT[18] = ox + (-1.6123850*sc)
  183.    GENDAT[19] = oy + ( 0.0000000*sc)
  184.    GENDAT[20] = 84.6620636
  185.    GENDAT[21] = ox + (-1.3963664*sc)
  186.    GENDAT[22] = oy + (-0.8061925*sc)
  187.    GENDAT[23] = 305.3379517
  188.  
  189.    x = ox + (-1.6308904*sc)
  190.    y = oy + ( 0.6394668*sc)
  191.  
  192.    GENDIM    53, 2, 2, 2, GENDAT, 1, x, y, `Rot
  193. `, 0.0000000, 0.3000000*sc, 0.5000000, 0, 5
  194.  
  195. REM get data to create permanent geometry
  196. REM default values
  197.    dia = 2.00
  198.    widthx = .50
  199.    dist = 1.5
  200.    rot = 0
  201.  
  202. REM get shaft diameter
  203. :get_dia
  204.    GETFLT "Enter (D) shaft diameter (%f):",dia,dia
  205.    ON (@key + 3) GOTO exit,exit,
  206.    rad = abs(dia/2)
  207.    IF ((rad <= .00005) || (rad >= 10000))
  208.      GOTO message1
  209.    GOTO get_width
  210.  
  211. REM get width
  212. :get_width
  213.    GETFLT "Enter (W) keyway width (%f):",widthx,widthx
  214.    ON (@key + 3) GOTO exit,get_dia,
  215.    width = abs(widthx/2)
  216.    IF ((width <= .00005) || (width >= 10000))
  217.      GOTO message1
  218.  
  219. REM get dist
  220. :get_dist
  221.    GETFLT "Enter (L) dist. from keyway to opp. shaft side (%f):",dist,dist
  222.    ON (@key + 3) GOTO exit,get_width,
  223.    dist = abs(dist)
  224.    IF ((dist <= .00005) || (dist >= 10000))
  225.      GOTO message1
  226.    GOTO check_data
  227.  
  228. :message1
  229.    PROMPT "Entered value is out of range ..."
  230.    WAIT 3
  231.    GOTO get_dia
  232.  
  233. :check_data
  234.    c = sqrt(rad*rad - width*width)
  235.    IF (dist >= (rad + c))
  236.      GOTO message2
  237.    GOTO get_rot
  238.      
  239. :message2
  240.    PROMPT "Construction not possible per given data ..."
  241.    WAIT 3
  242.    GOTO get_dia
  243.  
  244. :get_rot
  245.    GETFLT "Enter (Rot) rotation angle (%f):",rot,rot
  246.    ON (@key + 3) GOTO exit,get_dist,
  247.  
  248. REM construct keyway
  249. :geom_constr
  250.    MODE NORMAL
  251.    posdef = 1
  252.    GETPOS "Indicate shaft center position",posdef
  253.    ON (@key + 3) GOTO exit,get_rot,geom_constr,
  254.    xc     = @XVIEW
  255.    yc     = @YVIEW
  256.    zc     = @DEPTH
  257.  
  258.    c = sqrt(rad*rad - width*width)
  259.    ang = atan2(width,c)
  260.    sinrot = sin(rot)
  261.    cosrot = cos(rot)
  262.  
  263. REM construct arc
  264.    ARC xc,yc,zc,rad,(rot + ang),(rot + 360 - ang)
  265.  
  266. REM construct lines
  267.    ax = c
  268.    ay = -width
  269.    bx = dist - rad
  270.    by = -width
  271.    lntype = 1
  272.    DOSUB sh_drwln
  273.  
  274.    ax = c
  275.    ay = width
  276.    bx = dist - rad
  277.    by = width
  278.    lntype = 1
  279.    DOSUB sh_drwln
  280.  
  281.    ax = dist - rad
  282.    ay = width
  283.    bx = dist - rad
  284.    by = -width
  285.    lntype = 1
  286.    DOSUB sh_drwln
  287.  
  288. :do_ctrlines
  289.    GETMENU "Do you want the shaft center lines (YES) ?",\
  290.            "YES",\
  291.            "NO"
  292.    ON (@key + 3) GOTO exit,get_dia,yes,do_ctrlines,yes,no,
  293.  
  294. :yes
  295.    ax = -(rad + .2)
  296.    ay = 0
  297.    bx = dist - rad + .2
  298.    by = 0
  299.    lntype = 3
  300.    DOSUB sh_drwln
  301.  
  302.    ax = 0
  303.    ay = -(rad + .2)
  304.    bx = 0
  305.    by = rad + .2
  306.    lntype = 3
  307.    DOSUB sh_drwln
  308.  
  309. REM back to the begining
  310. :no
  311.    GOTO get_dia
  312.  
  313. :exit
  314.    MODE NORMAL
  315.    CHAIN shapes
  316.    exit
  317.