home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR506.ZIP / ACAD2.EXE / IMDEFINE.V12 < prev    next >
Text File  |  1989-02-16  |  6KB  |  174 lines

  1. ; IMDEFINE V 1.2 for use with INSERT MANAGER
  2. ; COPYRIGHT 1989 CADD Masters
  3. ; ALL RIGHTS RESERVED
  4. ;
  5. ; Revision record:
  6. ; V1.2 - Layer "M" and "F" employed instead of (grclear) because Mslide
  7. ; does a redraw before making the slide and any underlying entities will
  8. ; appear.
  9.  
  10. (defun c:imdefine (/ err acaderr blkdata resterr counter pos ce e obj tar fil d ansr f sld blknm ptx pty insx insy ptxless1 ptxplus1 ptyless1 ptyplus1 tmp strpos getdir)
  11.  
  12. (defun err (msg)
  13.   (command "undo" "e")
  14.   (command "undo" "b")
  15.   (setq *error* acaderr)
  16.   (princ (strcat "error:" msg))
  17.   (prin1)
  18. )
  19.  
  20. (defun strpos (obj tar / lobj ltar pos)
  21.   (setq lobj (strlen obj))
  22.   (setq ltar (strlen tar))
  23.   (setq pos 1)
  24.   (while (and (<= pos ltar) (/= obj (substr tar pos lobj)))
  25.     (setq pos (+ pos 1))
  26.   )
  27.   (if (> pos ltar)
  28.     (setq pos 0)
  29.   )
  30.   pos
  31. )
  32.  
  33. (defun getdir (fil / dr)
  34.   (setq dr (substr fil 1 (setq j (strlen fil))))
  35.   (while (and (/= (substr dr j 1) "\\") (>= j 1))
  36.     (setq j (- j 1))
  37.   )
  38.   (if (not (and (= j 1) (= (substr dr j 1) "\\")))
  39.     (setq dr (substr fil 1 j))
  40.     (setq dr "")
  41.   )
  42.   dr
  43. )
  44.  
  45.   (setq ce (getvar "cmdecho"))
  46.   (setvar "cmdecho" 0)
  47.   (setq acaderr *error*)
  48.   (setq *error* err)
  49.   (setq sld (strcase (getstring (strcat "\nMatrix file name (enter to abort): <" (getvar "dwgprefix") ">"))))
  50.   (if (/= sld "")
  51.   (progn
  52.     (command "undo" "m")
  53.     (if (/= (setq postn (strpos "." sld)) 0)
  54.       (setq sld (substr sld 1 (- postn 1)))
  55.     )
  56.     (if (setq f (open (strcat sld ".DAT") "r"))
  57.     (progn
  58.       (close f)
  59.       (setq ansr (strcase (getstring (strcat "\nFile: " sld " exists!  Overwrite? (Y/N): <N>"))))
  60.       (if (/= ansr "Y")
  61.         (setq ansr "N")
  62.       )
  63.     )
  64.     )
  65.     (if (or (not f) (= ansr "Y"))
  66.     (progn  
  67.       (setvar "dragmode" 2)
  68.       (setvar "pdmode" 3)
  69.       (setvar "pdsize" 0.5)
  70.       (command "layer" "m" "insertmanagerdefinitionlayer" "c" "white" "" "f" "*" "")
  71.       (command "zoom" "c" (list 0.0 0.0) 11.0)
  72.       (command "color" "red")
  73.       (setq ptx -5.0 pty 4.0)
  74.       (write-line "\nBEGIN SLIDE DEFINITION:")
  75.       (setq d (getvar "dwgprefix"))
  76.       (while (>= pty -4.0)
  77.         (while (<= ptx 5.0)
  78.           (setq blknm (strcase (getstring (strcat "\nInsert file name (enter/Undo/?): <" d ">"))))
  79.           (cond
  80.             ((= blknm "")
  81.               (setq ptx 7.0)
  82.               (setq pty -4.0)
  83.             )
  84.             ((= blknm "?")
  85.               (command "sh" (strcat "dir " d "*.dwg/w"))
  86.               (terpri)
  87.               (getstring "Strike enter to continue . . .")
  88.               (graphscr)
  89.             )
  90.             ((or (= blknm "U") (= blknm "UNDO"))
  91.               (if (and (<= ptx -5.0) (>= pty 4.0))
  92.               (progn
  93.                 (setq ptx 7.0)
  94.                 (setq pty -4.0)
  95.               )
  96.               (progn
  97.                 (if (<= ptx -5.0)
  98.                 (progn
  99.                   (setq ptx 5.0)
  100.                   (setq pty (+ pty 2.0))
  101.                 )
  102.                   (setq ptx (- ptx 2.0))
  103.                 )
  104.                 (entdel (entlast))
  105.                 (entdel (entlast))
  106.                 (entdel (entlast))
  107.                 (setq blkdata (cddr blkdata))
  108.               )
  109.               )
  110.  
  111.             )
  112.             (t
  113.               (if (/= (setq postn (strpos "." blknm)) 0)
  114.                 (setq blknm (substr blknm 1 (- postn 1)))
  115.               )
  116.               (if (= (strpos "\\" blknm) 0)
  117.                 (setq blknm (strcat d blknm))
  118.                 (setq d (getdir blknm))
  119.               )
  120.               (if (setq tmp (open (strcat blknm ".DWG") "r"))
  121.               (progn
  122.                 (close tmp)
  123.         (setq blkdata (cons (strcat (rtos ptx 2 1) " " (rtos pty 2 1)) blkdata))
  124.                 (setq blkdata (cons blknm blkdata))
  125.                 (command "pline" (list (setq ptxless1 (- ptx 1.0)) (setq ptyless1 (- pty 1.0))) (list (setq ptxplus1 (+ ptx 1.0)) ptyless1) (list ptxplus1 (setq ptyplus1 (+ pty 1.0))) (list ptxless1 ptyplus1) "c")
  126.                 (redraw (setq hlbox (entlast)) 3)
  127.                 (prompt "\nInsertion point:")
  128.                 (command "insert" blknm pause 1.0 1.0 0.0)
  129.                 (setq insx (nth 0 (getvar "lastpoint")))
  130.                 (setq insy (nth 1 (getvar "lastpoint")))
  131.                 (terpri)
  132.                 (while (or (< insx ptxless1) (< insy ptyless1) (> insx ptxplus1) (> insy ptyplus1))
  133.                   (entdel (entlast))
  134.                   (prompt "\nerror: insertion point must be within highlighted lines.")
  135.                   (prompt "\nInsertion point:")
  136.                   (command "insert" blknm pause 1.0 1.0 0.0)
  137.                   (setq insx (nth 0 (getvar "lastpoint")))
  138.                   (setq insy (nth 1 (getvar "lastpoint")))
  139.                   (terpri)
  140.                 )
  141.                 (prompt "\nX scale factor:")
  142.         (command "scale" "last" "" (list insx insy) pause)
  143.                 (terpri)
  144.                 (command "point" (list insx insy))
  145.                 (setq ptx (+ ptx 2.0))
  146.                 (redraw hlbox 4)
  147.               )
  148.                 (write-line (strcat "\nERROR: " blknm ".DWG not found."))
  149.               )
  150.             )
  151.           )
  152.         )
  153.         (setq ptx -5.0)
  154.         (setq pty (- pty 2.0))
  155.       )
  156.       (if blkdata
  157.       (progn
  158.     (setq f (open (strcat sld ".DAT") "w"))
  159.         (command "mslide" sld)
  160.         (setq blkdata (reverse blkdata))
  161.         (foreach n blkdata (write-line n f))
  162.         (close f)
  163.       )
  164.       )
  165.     )
  166.     )
  167.     (command "undo" "e")
  168.     (command "undo" "b")
  169.   )
  170.   )
  171.   (setvar "cmdecho" ce)
  172.   (prin1)
  173. )
  174.