home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p086 / 3.img / ACADSUP.LIF / BLOCKIT.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1991-04-08  |  23.0 KB  |  875 lines

  1. ;;;*********************************************************************
  2. ;;;   Blockit.lsp 1.01
  3. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  4. ;;;  
  5. ;;;   Block animation command for use with AutoCAD Release 10
  6. ;;;
  7. ;;;   Permission to use, copy, modify, and distribute this software and its
  8. ;;;   documentation for any purpose and without fee is hereby granted.  
  9. ;;;
  10. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
  11. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
  12. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  13. ;;;    
  14. ;;;   Designed and implemented by Jamie Clay in June of 1990
  15. ;;;   Reformatted file for compliance with coding standards.  
  16. ;;;     JSY -- Sept. 1990
  17. ;;; 
  18. ;;;   Note: Requires the presence of PTOOLS.LSP
  19. ;;;    
  20. ;;;*********************************************************************
  21. ;;; NUMBERS
  22. ;;; f# - total number of frames
  23. ;;; s# - block motion start number  
  24. ;;; r# - block motion steps 
  25. ;;; c# - count number for block list 
  26. ;;; m# - stored value for frame starting number
  27. ;;; strt# - start number for filmrolls 
  28. ;;; count - animation process counter 
  29. ;;; ent_sel -  index counter for anim_set
  30. ;;; ent_sel# - number of lists in anim_set
  31. ;;;
  32. ;;; STRINGS
  33. ;;; flm -  updated name for filmrolls
  34. ;;; kflm - saved name for filmrolls 
  35. ;;; kname - user entered filmroll name
  36. ;;; pline - response string for path prompt
  37. ;;; scale - Block scale prompt response
  38. ;;;
  39. ;;; LISTS
  40. ;;; anim_set - master animation list
  41. ;;; items - blocks for insertion
  42. ;;; camlst - path points
  43. ;;; rot - block rotation information
  44. ;;; xs - block x scale information
  45. ;;; ys - block y scale information
  46. ;;; zs - block z scale information
  47. ;;;
  48. ;;; MISC
  49. ;;; flatland - flatland value when routine is started
  50. ;;; osmode - object snap value when routine is started
  51. ;;; blipmode - blip setting value when routine is started
  52. ;;; *olderror* - stored *error* function
  53. ;;; steps - while switch
  54. ;;; ans - switch for *close* function
  55. ;;; select - switch for animation setup while loop
  56.  
  57. (prompt "\nLoading...")
  58. (vmon)
  59. (defun c:blockit (/ outfile rot xs ys zs f# s# r# select flm kflm kname optp
  60.                     items count appfile camlst camlst2 c# pline pline2 sshade
  61.                     ans anim_set ucsfollow items steps seepath hide rem)
  62.  
  63.   ;; This function has been broken into three parts to allow it to run in
  64.   ;; very tight memory situations.  The three functions are listed below.
  65.   
  66.   (b-it1)                             ; Set up, get name and frames.
  67.   (b-it2)                             ; Start the selection while loop.
  68.   (b-it3)                             ; Output and cleanup before exiting.
  69.  
  70.   (princ)
  71. )
  72.  
  73. ;;; Blockit part 1 of the defun c:blockit
  74. ;;; All variables are defined in c:blockit.
  75.  
  76. (defun b-it1 ()
  77.   (if (= oset "Test")(setq oset nil))
  78.  
  79.   ;;Set up the system variables
  80.  
  81.   (setvar "cmdecho" 0)
  82.   (command "undo" "group")
  83.   (setq rf#        0
  84.         attreq     (getvar "attreq")
  85.         flatland   (getvar "flatland")
  86.         ucsfollow  (getvar "ucsfollow")
  87.         osmode     (getvar "osmode")
  88.         blipmode   (getvar "blipmode")
  89.         ent_sel    -1
  90.         remove     (ssadd)
  91.         *olderror* *error*
  92.         *error*    *close*
  93.   )
  94.   (setvar "attreq" 0)
  95.   (setvar "flatland" 0)
  96.   (setvar "osmode" 0)
  97.   (setvar "blipmode" 0)
  98.   (setvar "highlight" 1)
  99.   (setvar "ucsfollow" 0)
  100.   (command "ucs" "world")
  101.  
  102.   (getdir)                            ; Find directory information
  103.  
  104.  
  105.   ;;Get the file name
  106.  
  107.   (if (not dwg_name)
  108.     (setq kflm (substr (justname (getvar "dwgname")) 1 4))
  109.     (setq kflm (substr dwg_name 1 4))
  110.   )
  111.  
  112.   (while (not kname)
  113.     (setq kname (getname (strcat "\nFilmroll title <" kflm ">: ")))
  114.     (if (not kname) (prompt "\nInvalid file name, please re-enter."))
  115.   )
  116.  
  117.   (if (= kname "")
  118.     (setq kname (justname (getvar "dwgname")))
  119.     (setq kflm (substr kname 1 4))
  120.   )
  121.  
  122.   (while (not f#)
  123.     (initget 7)
  124.     (setq f# (getint "\nNumber of frames: "))
  125.     (if (< f# 3)
  126.       (progn
  127.         (setq f# nil)
  128.         (prompt "\nPlease use a larger number.")
  129.       )
  130.     )
  131.   )
  132.  
  133.  
  134.   (if (or (not deed) (= deed "TEST")) (setq m# 1))
  135.   (if (not m#) (setq m# 1))
  136.   (initget 6)
  137.   (setq strt# (getint (strcat "\nStarting number <" 
  138.                                (cname "" m#) ">: "))
  139.   )
  140.   (if strt# (setq m# strt#))
  141. )
  142.  
  143. ;;; Blockit part 2 of the defun c:blockit
  144. ;;; All variables are defined in c:blockit.
  145.  
  146. (defun b-it2 ()
  147.   (setq select T)                     ; start the selection while loop
  148.   (while select
  149.     (setq items (blk_get))
  150.     (if items
  151.       (progn
  152.  
  153.         ;; get the entity motion information
  154.         ;; if this is a 3 frame animation, skip this part.
  155.         (if (/= f# 3)
  156.           (motion_steps)
  157.           (setq s# 1 c# 0)
  158.         )                             ; end of if \= 3 f#
  159.  
  160.         ;; while (not pline)
  161.         (b-it2a)
  162.         ;; selection conditional and camlist setting
  163.         (b-it2b)
  164.         ;; Get path option, scale, and align options.
  165.         (b-it2c)
  166.         ;; Get block rotation and set the animation set.
  167.         (b-it2d)
  168.  
  169.  
  170.         (setq camlst  nil
  171.               camlst2 nil
  172.                   s#  nil
  173.                items  nil
  174.                  rot  nil
  175.                select T
  176.         )
  177.       )                               ; end of the 'if items true progn'
  178.       (progn
  179.         (if (< (length anim_set) 1)
  180.           (setq anim_set nil)
  181.           (progn
  182.             (initget "Yes No")
  183.             (setq select (getkword 
  184.                 "\nAre you finished with the selection process? <Y>: ")
  185.             )
  186.             (if (or (not select) (= select "Yes"))
  187.               (setq select nil)
  188.             )
  189.           )
  190.         )
  191.       )
  192.     )                                 ; end of if items
  193.   )
  194. )
  195.  
  196. ;;; Blockit part 2, subpart a
  197. ;;; All variables are defined in c:blockit.
  198.  
  199. (defun b-it2a ()
  200.   (while (not pline)
  201.     (initget "Fixed Path List")
  202.     (setq pline (getkword "\nBlock motion Path/Fixed/List <Path>: "))
  203.     (if (= pline "Path") (setq pline nil))
  204.  
  205.     ; Get block insertion point
  206.     (cond
  207.       ((= pline "Fixed")
  208.         (setq camlst (list (getpoint 
  209.           "\nBlock, fixed position>> Pick a point: "))
  210.         ) 
  211.       )
  212.       ((= pline "List")
  213.         (while (not camlst)
  214.           (setq pathfile (getstring "\nBlock, point list>> File to use: ")
  215.                 camlst (ptsread pathfile)
  216.           )
  217.           (if (and (< txtpt# r#) camlst)
  218.             (progn              
  219.               (prompt "\nInsufficient number of points.")
  220.               (prompt "\nSorry, can not use this file.")
  221.               (setq camlst nil)
  222.             ) 
  223.           ) 
  224.         )
  225.       )
  226.       ((not pline)
  227.         (while (not pline)
  228.           (setq pline (entsel"\nBlock motion path>> Select a polyline: ")
  229.                 pline (polytest pline)
  230.           )
  231.         )
  232.         (setq remove (ssadd (car pline) remove))
  233.         (redraw (car pline) 3)
  234.         (if r#
  235.           (setq camlst (gather pline  r#))                   
  236.           (setq camlst (gather pline f#)) 
  237.         )
  238.       ) 
  239.       ;; If the block is fixed it will pass through this cond
  240.     )
  241.   )
  242. )
  243.  
  244. ;;; Blockit part 2, subpart b
  245. ;;; All variables are defined in c:blockit.
  246.  
  247. (defun b-it2b ()
  248.   (initget "Path List")
  249.   (if (/= pline "Fixed")
  250.     (setq optp (getkword "\nOptional Path - Path/List <none>: "))
  251.   )
  252.   (cond
  253.     ((= optp "Path")
  254.        (while (not pline2)
  255.          (setq pline2 (entsel "\nOptional path>> Select a polyline: "))
  256.          (setq pline2 (polytest pline2))
  257.          (if (eq (car pline) (car pline2))
  258.            (progn
  259.              (setq pline2 nil)
  260.              (prompt "\nSorry, you can not use the motion path. Try again."
  261.              )
  262.            )
  263.          )
  264.        )
  265.        (redraw (car pline2) 3)
  266.        (setq remove (ssadd (car pline2) remove))
  267.     )
  268.     ((= optp "List")
  269.       (while (not optfile)
  270.         (setq optfile (getstring "\nOptional, point list>> File to use: ")
  271.              camlst2 (ptsread optfile)
  272.         )
  273.         (if (not camlst2) 
  274.           (set optfile nil)
  275.           (cond
  276.             ((= optfile pathfile)
  277.                (prompt 
  278.                  "\nSorry, you can't use the same file used for Camera path.")
  279.                (setq optfile nil)
  280.             )
  281.             ((< txtpt# r#)
  282.                (prompt "\nInsufficient number of points.")
  283.                (prompt "\nSorry, you can not use this file.")
  284.                (setq optfile nil)
  285.             )
  286.             ((equal camlst2 camlst)
  287.                (prompt "\nBoth lists are identical.")
  288.                (prompt "\nSorry, you can not use this file.")
  289.                (setq optfile nil)
  290.             )
  291.           )
  292.         )  
  293.       )
  294.     )
  295.     ;; If there isn't an optional path, nothing here will happen
  296.   )
  297.   (if pline2 
  298.     (if r#
  299.       (setq camlst2 (gather pline2 r#))
  300.       (setq camlst2 (gather pline2 f#))
  301.     )
  302.   )
  303. )
  304.  
  305. ;;; Blockit part 2, subpart c
  306. ;;; All variables are defined in c:blockit.
  307.  
  308. (defun b-it2c ()
  309.   ;;get scale information
  310.   (setq xs nil
  311.         ys nil
  312.         zs nil
  313.       xstr "[X] 1.0,1.0,S "
  314.       ystr "[Y] 1.0,1.0,S "
  315.       zstr "[Z] 1.0,1.0,S "
  316.   )
  317.   (while (/= scale "")
  318.     (princ (strcat "\nScale settings: " xstr ystr zstr))
  319.     (setq scale (getstring "\nScale >> X/Y/Z: ")
  320.           scale (strcase scale)
  321.     )
  322.     (cond
  323.       ((= scale "X") (setq xstr (doSTR  "X")))
  324.       ((= scale "Y") (setq ystr (doSTR  "Y")))
  325.       ((= scale "Z") (setq zstr (doSTR  "Z")))
  326.     )
  327.   )
  328.  
  329.   ;;Align block prompt
  330.   (if (/= pline "Fixed")
  331.     (progn
  332.       (initget "Yes No")
  333.       (setq rot (getkword "\nAlign block with path? <Y> "))
  334.       (if (= rot "No")
  335.         (setq rot nil)
  336.         (setq rot "Yes")
  337.       )
  338.     )
  339.   )
  340. )
  341.  
  342. ;;; Blockit part 2, subpart d
  343. ;;; All variables are defined in c:blockit.
  344.  
  345. (defun b-it2d ()
  346.   ;;Block rotation?
  347.   (if (/= rot "Yes")
  348.     (setq rot (getreal "\nBlock rotation <none>: "))
  349.   )
  350.  
  351.   (if (and rot (/= (type rot) 'STR))
  352.     (progn
  353.       (setq rst (getreal "\nStarting angle <0>: "))
  354.       (if r#
  355.         (setq rot (/ rot (1- r#)))
  356.         (setq rot (/ rot (1- f#))
  357.                r# f#
  358.         )
  359.       )
  360.       (if (not rst)
  361.         (setq rst 0)
  362.       )
  363.       (setq rot (list rot rst))
  364.     )
  365.     (if (not r#) (setq r# f#))
  366.   )
  367.  
  368.   (setq scale  nil
  369.         pline  nil
  370.         pline2 nil
  371.         ent_sel (1+ ent_sel)
  372.         ent_sel# (1+ ent_sel)
  373.         count 0
  374.   )
  375.  
  376.   (if anim_set
  377.     (setq anim_set (append anim_set (list 
  378.             (list items xs ys zs rot camlst camlst2 s# c# r# nil)))
  379.     )
  380.     (setq anim_set (list 
  381.              (list items xs ys zs rot camlst camlst2 s# c# r# nil))
  382.     )
  383.   )
  384. )
  385.  
  386. ;;; Blockit part 3 of the defun c:blockit
  387. ;;; All variables are defined in c:blockit.
  388.  
  389. (defun b-it3 ()
  390.   (setq testf# f#
  391.         testm# m#
  392.   )
  393.  
  394.   (output) ; find output format
  395.  
  396.   (if (= deed "TEST")  ;; If we want to test, test away!
  397.     (progn
  398.       (setq hold_set anim_set
  399.             testmode T
  400.       )
  401.       (while testmode
  402.         (b_action)
  403.         (princ "\n*press any key to reset animation*")
  404.         (while (/= (nth 0 (grread)) 2)) ;pause for keybard input
  405.         (setq del_ent (1- ent_sel#))
  406.         (repeat ent_sel#
  407.           (entdel (nth 10 (nth del_ent anim_set)))
  408.           (setq del_ent (1- del_ent))
  409.         )
  410.         (output)
  411.         (if (/= deed "TEST")
  412.           (setq testmode nil)
  413.         )
  414.         ;; Restore the values needed for animation
  415.         (setq count 0   
  416.               f# testf#
  417.               m# testm#
  418.               anim_set hold_set
  419.         )
  420.       )
  421.     )
  422.   )
  423.  
  424.   (command "undo" "group")
  425.  
  426.   ;; This is where we remove paths for slide animations
  427.   (if rem   
  428.     (command "erase" remove "")
  429.   )
  430.  
  431.   (if deed      ;; this is where we process the animation
  432.     (b_action)
  433.   )
  434.  
  435.  
  436.   ;; All done, shut her down
  437.  
  438.   (if outfile
  439.     (progn
  440.       (close outfile)
  441.       (princ (strcat "\nAnimation list "(strcase fdir) (strcase fname)))
  442.       (if appfile
  443.          (princ " updated.")
  444.          (princ " created.")
  445.        )
  446.       (setq outfile nil)
  447.     )
  448.   )
  449.   (if rem
  450.     (progn
  451.       (setq repo 0)
  452.       (repeat (sslength remove)
  453.         (entdel (ssname remove repo))
  454.         (setq repo (1+ repo))
  455.       )
  456.     )
  457.   )
  458.   (command "ucsicon" "all" "on")
  459.   (command "undo" "end")
  460.   (setvar "attreq" attreq)
  461.   (setvar "cmdecho" 1)
  462.   (setvar "highlight" 1)
  463.   (setvar "ucsfollow" ucsfollow)
  464.   (setvar "blipmode" blipmode)
  465.   (setq *error* *olderror*)
  466. )
  467.  
  468. ;;; Supporting defuns
  469.  
  470. ;;; B_ACTION
  471.  
  472. (defun b_action ()
  473.  
  474.   (command "ucsicon" "all" "off")
  475.   (setvar "highlight" 0)
  476.  
  477.   ;; Process the animation
  478.  
  479.   (repeat f#
  480.     (repeat ent_sel#
  481.       (blk_action (nth ent_sel anim_set))
  482.       (setq ent_sel (1- ent_sel))
  483.     )
  484.     (setq flm (cname kflm m#))
  485.  
  486.     (if seepath (view seepath))
  487.     
  488.     ;; hide or shade the image as requested
  489.     (if hide 
  490.       (command "hide")
  491.       (if sshade
  492.         (command "shade")
  493.       )
  494.     )
  495.  
  496.     (if (or (= deed "MSLIDE") (= deed "SAVE"))
  497.       (supfile flm kname)
  498.     )
  499.     ; test mode switch
  500.     (if (= deed "TEST")
  501.       (princ (strcat "\nTest mode >> " flm ))
  502.       (progn
  503.         (princ (strcat "\nMaking " fdir flm sfx)) 
  504.         ; see if a drawing with the same name exists
  505.         (if (and (findfile (strcat fdir flm ".dwg"))(= deed "SAVE"))
  506.           (command deed (strcat fdir flm) "Y")
  507.           (command deed  (strcat fdir flm))
  508.         )
  509.       )
  510.     )
  511.  
  512.     (setq m# (1+ m#)
  513.           ent_sel (1- ent_sel#)
  514.           count (1+ count)
  515.     )
  516.   )
  517. )
  518.  
  519. ;;;  BLK_ACTION - The block party machine
  520.  
  521. (defun blk_action (blkset /  doit rot xale yale zale doit)
  522.   (setq blks (nth 0 blkset)           ; block list
  523.         xale (nth 1 blkset)           ; X block scale info
  524.         yale (nth 2 blkset)           ; Y block scale info
  525.         zale (nth 3 blkset)           ; Z block scale info
  526.         rot  (nth 4 blkset)           ; Block rotation amount
  527.         camlst (nth 5 blkset)         ; Point list
  528.         camlst2 (nth 6 blkset)        ; secondary point list
  529.         st# (nth 7 blkset)            ; motion start
  530.         count2 (nth 8 blkset)         ; motion steps count
  531.         stps (nth 9 blkset)           ; motion steps
  532.         lins (nth 10 blkset)          ; last insertion
  533.    )
  534.  
  535.   ;; Timer
  536.   (if (<= (1+ count) st#)
  537.     (setq doit nil)
  538.     (setq doit T)
  539.   )
  540.   (if (and (/= stps f#) (= count2 stps)) (setq doit nil))
  541.   (if (= (1+ count) 1) (setq doit T))
  542.  
  543.   ;; If ok, do the deed
  544.   (if doit
  545.     (progn
  546.  
  547.       ;; Erase previous insertion
  548.       (if lins (entdel lins))
  549.  
  550.       ;; Get block name
  551.       (if (= (length blks) 1)
  552.         (setq blk (nth 0 blks))
  553.         (progn
  554.           (setq bcount (nth 0 blks))
  555.           (setq bcount (1+ bcount))
  556.           (setq blk (nth bcount blks))
  557.           (if (= (1+ bcount) (length blks))
  558.             (setq bcount 0)
  559.           )
  560.           (setq blks (subst bcount (nth 0 blks) blks))
  561.         )
  562.       )
  563.  
  564.       ;; Get insertion point
  565.       (if (= (length camlst) 1)
  566.         (setq pt1 (nth 0 camlst))
  567.         (setq pt1 (nth count2 camlst))
  568.       )
  569.  
  570.       ;; Get X scale factor
  571.       (if xale
  572.         (if (= (length xale) 1)
  573.           (setq x (nth 0 xale))
  574.           (setq x (scaleit xale)
  575.                 xale scale
  576.           )  
  577.         )  
  578.         (setq x 1)
  579.       )
  580.       (if (< (abs x) 1e-10)        ; Zero scale value "filter"
  581.         (setq x 0.0000001)
  582.       )
  583.  
  584.       ;; Get Y scale factor
  585.       (if yale
  586.         (if (= (length yale) 1)
  587.           (setq y (nth 0 yale))
  588.           (setq y (scaleit yale)
  589.                 yale scale
  590.           )
  591.         )
  592.         (setq y 1)
  593.       )
  594.       (if (< (abs y) 1e-10)        ; Zero scale value "filter"
  595.         (setq y 0.0000001)
  596.       )
  597.  
  598.       ;; Get Z scale factor
  599.       (if zale
  600.         (if (= (length zale) 1)
  601.           (setq z (nth 0 zale))
  602.           (setq z (scaleit zale)
  603.                 zale scale
  604.           )
  605.         )
  606.         (setq z 1)
  607.       )
  608.       (if (< (abs z) 1e-10)        ; Zero scale value "filter"
  609.         (setq z 0.0000001)
  610.       )
  611.  
  612.       ;; Get Rotation amount
  613.       (if rot
  614.         (if (= rot "Yes")
  615.           (if (not camlst2)
  616.             (progn 
  617.               ;Get path follow points (3 point UCS info)
  618.               (if (not (setq pt2 (nth (1+ count2) camlst)))  
  619.                 ; Get X point
  620.                 (setq pt2 (polar pt1 
  621.                           (angle (nth (1- count2) camlst) pt1) 1)
  622.                 )         ; Get X if we're at the end
  623.               )
  624.               (setq pt3 (polar pt1 
  625.                         (+ (angle pt1 pt2) 1.578) 1)
  626.               )         ; Create Y point
  627.               (command "ucs" "3" pt1 pt2 pt3 ) ; change the UCS
  628.             )
  629.           )
  630.           (setq r (nth 1 rot)                  ; Read rotation amount
  631.                 r2 (+ (nth 0 rot) (nth 1 rot)) ; update the rotation
  632.                 rot (list (nth 0 rot) r2)      ; store for next use
  633.           )
  634.         )
  635.         (setq r 0)      ; if nothing specified, go to 0 rotation
  636.       )
  637.  
  638.       (if camlst2
  639.         (progn
  640.           (setq pt3 (nth count2 camlst2))
  641.           (if (not (setq pt2 (nth (1+ count2) camlst)))
  642.             (setq pt2 (polar pt1 (angle (nth (1- count2) camlst) pt1) 1))
  643.           )
  644.           (if (= rot "Yes")
  645.             (command "ucs" "3" pt1 pt2 pt3 )
  646.             (command "ucs" "3" pt1 (polar pt1 0 1) pt3)
  647.           )
  648.         )
  649.       )
  650.  
  651.       ;; Do that block magic
  652.       (if (= rot "Yes")
  653.         (command "insert" blk "0,0" "XYZ" x y z "0" "ucs" "")
  654.         (if camlst2
  655.           (command "insert" blk "0,0" "XYZ" x y z r "ucs" "")
  656.           (command "insert" blk pt1 "XYZ" x y z r)
  657.         )
  658.       )
  659.  
  660.  
  661.       ;; Update the list info
  662.       (setq anim_set (subst
  663.           (list blks xale yale zale rot camlst camlst2 st# (1+ count2)
  664.            stps (entlast)) blkset anim_set)
  665.       )
  666.     )
  667.   )
  668. )
  669.  
  670. ;;; SCALEIT - Making that block work for scale
  671.  
  672. (defun scaleit (slist)
  673.   (setq switch (nth 0 slist)          ; switch
  674.         rate   (nth 1 slist)          ; change rate
  675.         lrate  (nth 2 slist)          ; last change
  676.   )
  677.   (if (= count2 0)
  678.     (setq sr lrate)
  679.     (if (= switch 0)                  ; if sequential do this
  680.       (setq sr (+ lrate rate))
  681.       (if (= (gcd stps 2) 1)          ; if this stps is an odd number do this
  682.         (if (>= (/ stps 2) count2) 
  683.           (setq sr (+ lrate rate))
  684.           (setq sr (- lrate rate))            
  685.         )
  686.         ;; if it's an even number do this
  687.         (if (>= (1- (/ stps 2)) count2) 
  688.           (setq sr (+ lrate rate))
  689.           ;; if it's an even number hold it for a frame
  690.           (if (and (= (gcd stps 2) 2) (= count2 (1+ (/ stps 2)))) 
  691.             (setq sr lrate)                      
  692.             (setq sr (- lrate rate)) 
  693.           )           
  694.         )         
  695.       )
  696.     )
  697.   )
  698.   (setq scale (list switch rate sr))
  699.   (setq sr sr)
  700. )
  701.  
  702.  
  703. ;;; BLK_GET - Function for building block name list.
  704.  
  705. (defun blk_get (/ blknames blkname)
  706.   (setq name_get T)
  707.   (while name_get
  708.     ;; ask for a file to process
  709.     (prompt"\n\n[Block Name Setup]")
  710.     (setq bltfile (getstring 
  711.                     "\nBlock list file (press RETURN to enter names): ")
  712.     ) 
  713.     (if (= bltfile "") (setq bltfile nil))                
  714.     (if bltfile                       ; If you get a list.
  715.       (progn
  716.         (setq blklist (open bltfile "r"))
  717.         (if (not blklist)
  718.           (setq blklist (open (strcat fdir bltfile) "r"))
  719.         )
  720.         (if (not blklist)          
  721.           (setq blklist (open (strcat fdir bltfile ".blt") "r"))
  722.         )
  723.       )
  724.       (while name_get
  725.         (prompt "\n*press RETURN when finished*")
  726.         (setq blkname (getstring "\nBlock>> name: "))
  727.         (if (= blkname "")
  728.           (setq name_get nil)
  729.           (progn
  730.             (setq blktest (chkblock blkname))
  731.             (if blktest
  732.               (progn
  733.                 (setq blkname blktest)
  734.                 (if blknames
  735.                   (setq blknames (append blknames (list blkname)))
  736.                   (setq blknames (list blkname))
  737.                 )
  738.               )
  739.              (prompt (strcat "\nBlock "(strcase blkname)" not found."))          
  740.             )
  741.           )
  742.         )
  743.       )
  744.     )                                 ; end of while name_get
  745.  
  746.     (if (/= blkname "")
  747.       (if bltfile
  748.         (while (setq blkname (read-line blklist))
  749.           (if (/= (substr blkname 1 1) "*")
  750.             (progn
  751.               (setq blktest (chkblock blkname))
  752.               (if blktest
  753.                 (progn
  754.                   (setq blkname blktest)
  755.                   (if blknames
  756.                     (setq blknames (append blknames (list blkname)))
  757.                     (setq blknames (list blkname))
  758.                   )
  759.                 )
  760.                 (progn
  761.                  (prompt (strcat "\n"(strcase blkname)" block not found."))
  762.                  (setq blknames nil)
  763.                 )
  764.               )
  765.             )
  766.           )
  767.         )
  768.         (if (not blknames) (prompt "\nError: File not found"))
  769.       )
  770.     )                                 ; end of if blkname ""
  771.  
  772.     (if blknames
  773.       (progn
  774.         (setq name_get nil)
  775.         (if (> (length blknames) 1)
  776.           (setq blknames (append (list 0) blknames))
  777.         )
  778.       )
  779.     )                                 ; end of if blknames
  780.       
  781.   )                                   ; end of the name_get while
  782.   (setq blknames blknames)
  783. )
  784.  
  785. ;;; GETSCALE - Routine for getting block scale.
  786.  
  787. (defun getscale (x)
  788.   (setq str 0 end 0 sctype nil)
  789.   (while (= str 0)
  790.     (initget 6)
  791.     (setq str (getreal (strcat "\nScale>> Block " x " start <1>: ")))
  792.     (if (not str) (setq str 1 ))
  793.   )
  794.   (while (= end 0)
  795.     (initget 6)
  796.     (setq end (getreal (strcat "\nScale>> Block " x "  end  <1>: ")))
  797.     (if (not end) (setq end 1))
  798.   )
  799.   (if (/= str end)
  800.     (progn
  801.       (initget "S s P p")
  802.       (setq sctype (getkword 
  803.                      "\nScale>> Sequential or Palendromic <S>: ")
  804.       )
  805.       (if (or (not sctype) (= sctype "S"))
  806.         (setq sctype 0)
  807.         (setq sctype 1)
  808.       )
  809.     )
  810.   )
  811.  
  812.   ;; set the divide rate bases on the number of frames this block will move
  813.   (if r#  
  814.     (setq sdiv  r# )
  815.     (setq sdiv  f# )
  816.   )
  817.  
  818.   ;; Set the scale rate based on Sequential or Palendromic order
  819.   (if (= sctype 0)
  820.     (setq rate (/ (- end str) sdiv))
  821.     (setq rate (/ (- end str) (/ sdiv 2)))   
  822.   )
  823.  
  824.   ;; this is for the case when both scale values are the same.
  825.   (if (not sctype) (setq sctype 0))  
  826.  
  827.   (cond 
  828.     ((and (= str end) (/= str 1)) (list end)) ; if they are the same 
  829.     ((and (= str end) (= str 1)) nil)         ; if they are both one
  830.     (T (list sctype rate str))                ; if they are different
  831.   )
  832. )
  833.  
  834. ;;; BLOCK CHECK - Look to see if there is such a file.
  835. (defun chkblock (x)
  836.   (if (not (tblsearch "BLOCK" x))
  837.     (if (not (findfile (strcat x ".dwg")))
  838.       (if (findfile (strcat fdir x ".dwg"))
  839.         (setq x (strcat fdir x))
  840.         (setq x nil)
  841.       )
  842.     )
  843.   )
  844.   (setq x x)
  845. )
  846.     
  847. ;;;(doSTR) - function used to set scale values
  848.  
  849. (defun doSTR (sc1 / sstr)
  850.   (setq scvar (read (strcat sc1 "S")) ; set scale var name
  851.         scval (getscale sc1)          ; get scale info
  852.   )
  853.   (set scvar scval) ; set the value to the var
  854.   (if scval                           ; change scale string
  855.     (setq scstr (strcat "[" sc1 "] "(rtos str 2 2) "," 
  856.                          (rtos end 2 2) ","
  857.                          (if (= sctype 0) 
  858.                            (setq sstr "S ") 
  859.                            (setq sstr "P ")
  860.                           ))
  861.     )
  862.     (setq scstr (strcat "[" sc1 "] 1.0,1.0,S "))
  863.   )  
  864. )
  865.  
  866. ;;; Load support functions
  867. (setq loaded T)
  868. (if (not gather) (load "ptools"))
  869.  
  870. ;;; End of the load.
  871.  
  872. (princ "\C:BLOCKIT v1.01- Loaded!")
  873. (princ)
  874.  
  875.