home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / SUPPORT2.LIB / DDINSERT.LSP < prev    next >
Encoding:
Text File  |  1992-09-09  |  22.5 KB  |  679 lines

  1. ;;;----------------------------------------------------------------------------
  2. ;;;
  3. ;;;   DDINSERT.LSP   ¬⌐Ñ╗ 0.5
  4. ;;;
  5. ;;;   ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  6. ;;;
  7. ;;;   Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  8. ;;;   ¡∞½h :
  9. ;;;
  10. ;;;   1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  11. ;;;   2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  12. ;;;
  13. ;;;   Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  14. ;;;   Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  15. ;;;
  16. ;;;
  17. ;;;----------------------------------------------------------------------------
  18. ;;;   DESCRIPTION
  19. ;;;
  20. ;;;   An AutoLISP implementation of the AutoCAD INSERT command with a dialogue
  21. ;;;   interface.  Answers the oft requested feature of being able to select
  22. ;;;   at Insert time either an internal or external drawing.
  23. ;;;
  24. ;;;   The user is presented with a dialogue allowing the selection from nested
  25. ;;;   dialogues of either an internal or external block.  Edit fields can be
  26. ;;;   used to enter or preset the insertion point, scale, and rotation angle,
  27. ;;;   or alternatively, these can be set dynamically as in the INSERT command.
  28. ;;;
  29. ;;;
  30. ;;;----------------------------------------------------------------------------
  31. ;;;   Prefixes in command and keyword strings:
  32. ;;;      "."  specifies the built-in AutoCAD command in case it has been
  33. ;;;           redefined.
  34. ;;;      "_"  denotes an AutoCAD command or keyword in the native language
  35. ;;;           version, English.
  36. ;;;
  37. ;;;----------------------------------------------------------------------------
  38. ;;;
  39. ;;; ===========================================================================
  40. ;;; ===================== load-time error checking ============================
  41. ;;;
  42.  
  43.   (defun ai_abort (app msg)
  44.      (defun *error* (s)
  45.         (if old_error (setq *error* old_error))
  46.         (princ)
  47.      )
  48.      (if msg
  49.        (alert (strcat " └│Ñ╬╡{ªí┐∙╗~: "
  50.                       app
  51.                       " \n\n  "
  52.                       msg
  53.                       "  \n"
  54.               )
  55.        )
  56.      )
  57.      (exit)
  58.   )
  59.  
  60. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  61. ;;; and then try to load it.
  62. ;;;
  63. ;;; If it can't be found or it can't be loaded, then abort the
  64. ;;; loading of this file immediately, preserving the (autoload)
  65. ;;; stub function.
  66.  
  67.   (cond
  68.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  69.  
  70.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  71.         (ai_abort "DDINSERT"
  72.                   (strcat "ºΣñú¿∞íuAI_UTILS.LSPív└╔«╫;"
  73.                           "\n  ╜╨└╦¼díusupportívÑ╪┐²íC")))
  74.  
  75.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  76.         (ai_abort "DDINSERT" "╡L¬k╕ⁿñJíuAI_UTILS.LSPív└╔«╫"))
  77.   )
  78.  
  79.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  80.       (ai_abort "DDINSERT" nil)         ; a Nil <msg> supresses
  81.   )                                    ; ai_abort's alert box dialog.
  82.  
  83. ;;; ==================== end load-time operations ===========================
  84.  
  85.  
  86. ;;;----------------------------------------------------------------------------
  87. ;;;  The main dialogue.
  88. ;;;----------------------------------------------------------------------------
  89. (defun c:ddinsert(/
  90.                      $value           do_insert      old_cmd            x_pt
  91.                      blk_exists       do_selection   parse_path         x_scale
  92.                      blk_name         error_msg      pat                y_pt
  93.                      blk_name1        explode        path_name          y_scale
  94.                      bl_match         ex_name        path_name_exist1   z_pt
  95.                      bl_name          error_scale    pat_match          z_scale
  96.                      check_current    globals        redefine
  97.                      check_fd         good_value     reset
  98.                      check_i          ins_name       rotation
  99.                      check_input      int_blocks     range
  100.                      check_name       ins_var
  101.                      check_name_ok    just_name      table_item
  102.                      cmd              list1
  103.                                       list_blocks    table_name
  104.                      dcl_id           n              use_val
  105.                      ddinsert_main    name           use_val_tog
  106.                                       n_name         value
  107.                                                      what_next
  108.                   )
  109.  
  110.   ;;
  111.   ;; Routine that inserts the selected block.
  112.   ;;
  113.   (defun do_insert()
  114.     (cond
  115.       ((= 1 on_screen)
  116.         (command "_.insert" ins_name)
  117.       )
  118.       ((and (= 0 on_screen) (= 0 explode))
  119.         (command "_.insert" ins_name (list x_pt y_pt z_pt)
  120.                  "xyz" x_scale y_scale z_scale rotation)
  121.       )
  122.       ((and (= 0 on_screen) (= 1 explode))
  123.         (command "_.insert" ins_name (list x_pt y_pt z_pt)
  124.                  x_scale rotation)
  125.       )
  126.       (T (princ "íudo_insertívññª│╡{ªíñW¬║┐∙╗~"))
  127.     )
  128.   )
  129.   ;;
  130.   ;;  Call routine to display nested dialogue.  Set edit box to returned value
  131.   ;;  if not nil.
  132.   ;;
  133.   (defun int_blocks()
  134.     (list_blocks)
  135.     (if blk_name1
  136.       (progn
  137.         (set_tile "current_name" (setq blk_name (strcase blk_name1)))
  138.         (set_tile "path_name" "")
  139.       )
  140.     )
  141.   )
  142.   ;;
  143.   ;; Short hand error tile resetting.
  144.   ;;
  145.   (defun reset()
  146.     (set_tile "error" "")
  147.   )
  148.   ;;
  149.   ;; Check does the block exist, either internally or externally.
  150.   ;;
  151.   (defun check_current()
  152.     (setq blk_name (strcase (ai_strtrim (get_tile "current_name"))))
  153.     (setq path_name (ai_strtrim (get_tile "path_name")))
  154.     (if (and (> (strlen blk_name) 3)    ; strip ".dwg" if necessary
  155.              (= (substr blk_name (- (strlen blk_name) 3)) ".DWG")
  156.         )
  157.       (setq blk_name (substr blk_name 1 (- (strlen blk_name) 4)))
  158.     )
  159.     (cond
  160.       ;; Length less 32.
  161.       ((> (strlen blk_name) 32)
  162.         (set_tile "error" "íu╣╧╕sªW║┘ívñúÑi╢WÑX 31 ¡╙ªrñ╕íC")
  163.       )
  164.       ;; if the block exists in the drawing (necessary for logand).
  165.       ((and (setq xcheck (tblsearch "block" blk_name))
  166.             (not (zerop (logand 52 (cdr (assoc 70 xcheck)))))
  167.        )
  168.         (set_tile "error" "┐∙╗~ í╨ ╡L¬k┤íñ▐íuXrefív; ╜╨Ñ╬íuXref A│s╡▓ívÑ\»αíC")
  169.       )
  170.       ;; If the block is undefined give message.
  171.       ((and (= "" path_name)
  172.             (/= "" blk_name)
  173.             (not (member blk_name table_list))
  174.        )
  175.         (set_tile "error" "íu╣╧╕sªW║┘ív╡L«─íC")
  176.       )
  177.       ((and (= "" path_name)
  178.             (= "" blk_name)
  179.        )
  180.         (set_tile "error" "íu╣╧╕sªW║┘ív╡L«─íC")
  181.       )
  182.       ((not (or (member blk_name table_list) ; does name exist as an internal
  183.                  (findfile path_name) ; or external block ??
  184.             )
  185.        )
  186.         (set_tile "error" "íu╣╧╕sªW║┘ív╡L«─íC")
  187.       )
  188.       (t)
  189.     )
  190.   )
  191.   ;;
  192.   ;; Check all input via a cond.  If any error exists, display the relevant
  193.   ;; message. If no errors bring down the dialogue.
  194.   ;;
  195.   (defun check_name_ok(/ ex_found)
  196.     (setq blk_name (strcase (ai_strtrim (get_tile "current_name"))))
  197.     (setq path_name (ai_strtrim (get_tile "path_name")))
  198.     ;; Check to see if the path name is valid once here.
  199.     (if (findfile path_name) (setq ex_found 1))
  200.  
  201.     ;; It's acceptable for the user to type in a drawing name without
  202.     ;; entering a Block name in the Block field.  If there is a valid pathname
  203.     ;; and an empty block name field, use parse path to get the block name
  204.     ;; from the drawing name.
  205.     (if (and (= 1 ex_found) (= "" blk_name)) (parse_path))
  206.  
  207.     (setq redefine 1)
  208.     ;; Check once here to see if the block name already exists in the drawing.
  209.     (setq xcheck (tblsearch "block" blk_name))
  210.  
  211.     (cond
  212.       ((and (= "" path_name)             ; Internal
  213.             (member blk_name table_list)
  214.             (= 0 explode)                ; explode off
  215.        )
  216.         (setq ins_name blk_name)
  217.       )
  218.       ((and (= "" path_name)             ; Internal
  219.             (member blk_name table_list)
  220.             (= 1 explode)                ; explode on
  221.        )
  222.         (setq ins_name (strcat "*" blk_name))
  223.       )
  224.       ((and (= 1 ex_found)               ; External
  225.             (= explode 1)                ; Explode on
  226.        )
  227.         (setq ins_name (strcat "*" path_name))
  228.       )
  229.       ((and (= 1 ex_found)                       ; External
  230.             (check_name blk_name)                ; blk name valid
  231.             (not xcheck)                         ; unique
  232.         )
  233.         (setq ins_name (strcat blk_name "=" path_name))
  234.       )
  235.       ((and (= 1 ex_found)                                ; External
  236.             xcheck
  237.             (zerop (logand 53 (cdr (assoc 70 xcheck))))   ; Not an Xref
  238.             (blk_exists)                                  ; redefine yes
  239.        )
  240.         (setq ins_name (strcat blk_name "=" path_name))
  241.       )
  242.       (T
  243.         (cond
  244.           ((not redefine)
  245.           )
  246.           ((and xcheck
  247.                 (not (zerop (logand 53 (cdr (assoc 70 xcheck))))) ; is an Xref
  248.            )
  249.             (set_tile "error"
  250.                       "┐∙╗~ í╨ ╡L¬k┤íñ▐íuXrefív; ╜╨Ñ╬íuXref A│s╡▓ívÑ\»αíC"
  251.             )
  252.             ;; if the path_name in not "" set focus there on error.
  253.             (if (read path_name)
  254.               (mode_tile "path_name" 2)
  255.               (mode_tile "current_name" 2)
  256.             )
  257.           )
  258.           ((= "" path_name)
  259.             (set_tile "error" "íu╣╧╕sªW║┘ív╡L«─íC")
  260.             (mode_tile "current_name" 2)
  261.           )
  262.           ((and (/= "" path_name) (not (findfile path_name)))
  263.             (set_tile "error" "íu└╔«╫ªW║┘ív╡L«─íC")
  264.             (mode_tile "path_name" 2)
  265.           )
  266.           ((and (/= "" path_name) (findfile path_name))
  267.             (set_tile "error" "íu╣╧╕sªW║┘ív╡L«─íC")
  268.             (mode_tile "current_name" 2)
  269.           )
  270.           (T (princ "íu╣╧╕sªW║┘ív└╦«╓ª│╗~íC"))
  271.         )
  272.         nil
  273.       )
  274.     )
  275.   )
  276.   ;;
  277.   ;;  On OK all input is checked before the dialogue is dismissed.
  278.   ;;
  279.   (defun check_input()
  280.     (if (= 1 explode)
  281.       (progn
  282.         (setq range 6)                 ; non zero & non negative
  283.         (setq error_scale "íuX ñ±¿╥ív╢╖¼░ > 0 ¬║íuÑ┐¡╚ívíC")
  284.       )
  285.       (progn
  286.         (setq range 2)                 ; non zero
  287.         (setq error_scale "íuX ñ±¿╥ívñúÑi¼░ 0 íC")
  288.       )
  289.     )
  290.     (cond
  291.       ((not (check_name_ok)))
  292.       ((and (= 0 on_screen) (bad_xyzxr)))          ; check insert point coords.
  293.       ((and (= 0 on_screen)        ; check scale if explode is off
  294.             (= 0 explode)
  295.             (bad_yz)
  296.       ))
  297.       (t (done_dialog 1))           ; if all is well, bring down the dialogue.
  298.     )
  299.   )
  300.   ;;
  301.   ;; Check some input and set focus on error.  Return nil is nothing bad.
  302.   ;;
  303.   (defun bad_xyzxr()
  304.     (cond
  305.       ((not (setq x_pt (ai_num (get_tile "x_pt") "íuX «y╝╨ív╡L«─íC" 0)))
  306.         (mode_tile "x_pt" 2)
  307.       )
  308.       ((not (setq y_pt (ai_num (get_tile "y_pt") "íuY «y╝╨ív╡L«─íC" 0)))
  309.         (mode_tile "y_pt" 2)
  310.       )
  311.       ((not (setq z_pt (ai_num (get_tile "z_pt") "íuZ «y╝╨ív╡L«─íC" 0)))
  312.         (mode_tile "z_pt" 2)
  313.       )
  314.       ((not (setq x_scale (ai_num
  315.                             (get_tile "x_scale") error_scale range)))
  316.         (mode_tile "x_scale" 2)
  317.       )
  318.       ((not (setq rotation (ai_angle (get_tile "rotation")
  319.                                     "íu▒█┬α¿ñív╡L«─íC"
  320.                            )
  321.             )
  322.         )
  323.         (mode_tile "rotation" 2)
  324.       )
  325.       (t nil)
  326.     )
  327.   )
  328.   ;;
  329.   ;; Check the Y scale and Z scale.  Return nil if bad.
  330.   ;;
  331.   (defun bad_yz()
  332.     (cond
  333.       ((not (setq y_scale (ai_num (get_tile "y_scale")
  334.                                   "íuY ñ±¿╥ívñúÑi¼░ 0 íC" 2)))
  335.         (mode_tile "y_scale" 2)
  336.       )
  337.       ((not (setq z_scale (ai_num (get_tile "z_scale")
  338.                                   "íuZ ñ±¿╥ívñúÑi¼░ 0 íC" 2)))
  339.         (mode_tile "y_scale" 2)
  340.       )
  341.     )
  342.   )
  343.   ;;
  344.   ;; If called with 0, display getfiled for a drawing name. If called with 1
  345.   ;; get the string form the edit box.
  346.   ;;
  347.   (defun check_fd (bit)
  348.     (cond
  349.       ((and (= 0 bit)
  350.             (setq ex_name (getfiled "┐∩╛▄╣╧└╔" "" "dwg" 2))
  351.        )
  352.         (setq path_name ex_name)
  353.         (check_fd1)
  354.       )
  355.       ((= 1 bit)
  356.         (setq path_name (ai_strtrim (get_tile "path_name")))
  357.         (check_fd1)
  358.       )
  359.     )
  360.   )
  361.  
  362.   (defun check_fd1()
  363.     (cond
  364.       ;; if the length of the name is greater than 4 and the last 4 characters
  365.       ;; are not .dwg, then tag .dwg on.
  366.       ((and (> (strlen path_name) 4)
  367.              (not (= ".dwg"
  368.                      (strcase (substr path_name (- (strlen path_name) 3)) T)
  369.              ))
  370.         )
  371.          (setq path_name (strcat path_name ".dwg"))
  372.       )
  373.       ((and (> 0 (strlen path_name))
  374.                  (<= (strlen path_name) 4)
  375.        )
  376.         (setq path_name (strcat path_name ".dwg"))
  377.       )
  378.       (t)                             ; name must have .dwg already.
  379.     )
  380.     (cond
  381.      ((findfile path_name)           ; check to see if it exists
  382.         (set_tile "path_name" path_name)
  383.         (parse_path)
  384.         (set_tile "current_name" blk_name)
  385.         (check_current)
  386.      )
  387.      ((and (= "" path_name)              ; OK to have a null pathname if the
  388.            (member blk_name table_list)  ; Block name is valid
  389.       )
  390.      )
  391.      (t (set_tile "error" "íu└╔«╫ªW║┘ív╡L«─íC"))
  392.     )
  393.   )
  394.   ;;
  395.   ;;  Find dwg name from path name.
  396.   ;;
  397.   (defun parse_path( / a b)
  398.     (setq a 1)
  399.     (repeat (strlen path_name)
  400.       (if (member (substr path_name a 1) '("/" "\\" ":"))
  401.         (setq b a)
  402.       )
  403.       (setq a (1+ a))
  404.     )
  405.     (if b
  406.       (setq blk_name (strcase (substr path_name (1+ b))))
  407.       (setq blk_name (strcase path_name))
  408.     )
  409.     (if (and (> (strlen blk_name) 3)    ; strip ".dwg" if necessary
  410.              (= (substr blk_name (- (strlen blk_name) 3)) ".DWG"))
  411.         (setq blk_name (substr blk_name 1 (- (strlen blk_name) 4)))
  412.     )
  413.   )
  414.   ;;
  415.   ;; Enable/Disable for Insertion Point.
  416.   ;;
  417.   (defun on_screen_tog()
  418.     (cond
  419.       ((= 1 on_screen)
  420.         (mode_tile "x_pt" 1)
  421.         (mode_tile "y_pt" 1)
  422.         (mode_tile "z_pt" 1)
  423.         (mode_tile "x_scale" 1)
  424.         (mode_tile "y_scale" 1)
  425.         (mode_tile "z_scale" 1)
  426.         (mode_tile "rotation" 1)
  427.       )
  428.       ((and (= 0 on_screen)(= 0 explode))
  429.         (mode_tile "x_pt" 0)
  430.         (mode_tile "y_pt" 0)
  431.         (mode_tile "z_pt" 0)
  432.         (mode_tile "x_scale" 0)
  433.         (mode_tile "y_scale" 0)
  434.         (mode_tile "z_scale" 0)
  435.         (mode_tile "rotation" 0)
  436.       )
  437.       ((and (= 0 on_screen)(= 1 explode))
  438.         (mode_tile "x_pt" 0)
  439.         (mode_tile "y_pt" 0)
  440.         (mode_tile "z_pt" 0)
  441.         (mode_tile "x_scale" 0)
  442.         (mode_tile "y_scale" 1)
  443.         (mode_tile "z_scale" 1)
  444.         (mode_tile "rotation" 0)
  445.       )
  446.     )
  447.   )
  448.   ;;
  449.   ;; Displays a nested dialogue containing an edit box for wildcards and
  450.   ;; a list box of the defined blocks in the drawing.
  451.   ;;
  452.   (defun list_blocks()
  453.     (setq bl_match '())
  454.     (if (not (new_dialog "list_blocks" dcl_id)) (exit))
  455.     (if (not pat) (setq pat "*"))
  456.     (set_tile "pattern" pat)
  457.     (pat_match pat)
  458.  
  459.     (action_tile "bl_match"   "(bl_name)")
  460.     (action_tile "pattern"    "(pat_match (setq pat (strcase $value)))")
  461.     (action_tile "selection"  "(do_selection)")
  462.     (action_tile "accept"     "(if (check_i)(done_dialog 1))")
  463.     (action_tile "cancel"     "(setq blk_name1 nil)(done_dialog 0)")
  464.  
  465.     (start_dialog)
  466.   )
  467.   ;;
  468.   ;; If a name is typed, check to see if  block with that name exists in the
  469.   ;; drawing.
  470.   ;;
  471.   (defun do_selection()
  472.     (set_tile "bl_match" "")
  473.     (setq blk_name1 (strcase $value))
  474.     (check_i)
  475.   )
  476.   ;;
  477.   ;; Display the selected block name in the edit box.
  478.   ;;
  479.   (defun bl_name()
  480.     (set_tile "error" "")
  481.     (set_tile "selection" (setq blk_name1 (nth (atoi $value) bl_match)))
  482.   )
  483.   ;;
  484.   ;; Confirms that a block with the entered name exists in the drawing.
  485.   ;;
  486.   (defun check_i()
  487.     (if (member blk_name1 table_list)
  488.       (progn
  489.         (set_tile "error" "")
  490.         T
  491.       )
  492.       (progn
  493.         (set_tile "error" "íu╣╧╕sªW║┘ív╡L«─íC")
  494.         (mode_tile "selection" 2)
  495.         nil
  496.       )
  497.     )
  498.   )
  499.   ;;
  500.   ;; This function displays the block list based on the pattern.
  501.   ;;
  502.   (defun pat_match (pat)
  503.     (setq bl_match '())
  504.     (foreach n table_list
  505.       (if (wcmatch n pat)
  506.         (setq bl_match (cons n bl_match))
  507.       )
  508.     )
  509.     (if (>= (getvar "maxsort") (length bl_match)) ; Alphabetise if greater
  510.       (if bl_match (setq bl_match (acad_strlsort bl_match))) ; than maxsort.
  511.     )
  512.     (start_list "bl_match")
  513.     (mapcar 'add_list bl_match)
  514.     (end_list)
  515.   )
  516.   ;;
  517.   ;;  This function checks the validity of the Block name.  If legitimate, the
  518.   ;;  Block name is returned, nil otherwise.
  519.   ;;
  520.   (defun check_name(name)
  521.     (if (not (or (not name)
  522.                  (= "" name)
  523.                  (wcmatch name "*[]`#`@`.`?`*`~`[`,`'!%^&()+={}|`\\:;\"<>/]*")
  524.              )
  525.         )
  526.       name
  527.     )
  528.   )
  529.   ;;
  530.   ;; Post a message, when focus is changed from new name, stating that a block
  531.   ;; already exists with this name which will be redefined.
  532.   ;;
  533.   (defun path_name_exist1()
  534.     (if (member n_name table_list)
  535.       (set_tile "error" "ª╣ªW║┘¬║íu╣╧╕sív▒N¡½╖s⌐w╕qíC")
  536.     )
  537.   )
  538.   ;;
  539.   ;;  An Alert dialogue, called on OK to get confirmation of redefining block.
  540.   ;;  Return T if redefine and nil if Cancel.
  541.   ;;
  542.   (defun blk_exists()
  543.     (if (not (new_dialog "blk_exists" dcl_id)) (exit))
  544.     (action_tile "redefine" "(done_dialog 2)")
  545.     (action_tile "cancel" "(done_dialog 0)")
  546.     (if (= (start_dialog) 2)  T (setq redefine nil))
  547.   )
  548.  
  549.   ;;
  550.   ;; Update the Y and Z scale when X scale is changed.
  551.   ;;
  552.   (defun up_xscale(/ x_temp)
  553.     (reset)
  554.     (if (= 1 explode)
  555.       (progn
  556.         (setq range 6)                 ; non zero & non negative
  557.         (setq error_scale "íuX ñ±¿╥ív╢╖¼░ > 0 ¬║íuÑ┐¡╚ívíC")
  558.       )
  559.       (progn
  560.         (setq range 2)                 ; non zero
  561.         (setq error_scale "íuX ñ±¿╥ívñúÑi¼░ 0 íC")
  562.       )
  563.     )
  564.     (if (setq x_temp (ai_num (get_tile "x_scale") error_scale range))
  565.       (progn
  566.         (set_tile "y_scale" (rtos x_temp))
  567.         (set_tile "z_scale" (rtos (abs x_temp)))
  568.       )
  569.     )
  570.   )
  571.   ;;
  572.    ;; Put up the dialogue.
  573.   ;;
  574.   (defun ddinsert_main()
  575.  
  576.     (if (not (new_dialog "ddinsert" dcl_id)) (exit))
  577.  
  578.  
  579.     ;; Find the defined blocks in the drawing.
  580.     (setq table_list (ai_table "block" 14)) ; no anonymous, Xrefs or
  581.                                             ; Xref dependents.
  582.  
  583.     ;; Set up some defaults.
  584.     (setq x_pt 0.0)                     (set_tile "x_pt" (rtos x_pt))
  585.     (setq y_pt 0.0)                     (set_tile "y_pt" (rtos y_pt))
  586.     (setq z_pt (getvar "elevation"))    (set_tile "z_pt" (rtos z_pt))
  587.     (setq x_scale 1.0)                  (set_tile "x_scale" (rtos x_scale))
  588.     (setq y_scale 1.0)                  (set_tile "y_scale" (rtos y_scale))
  589.     (setq z_scale 1.0)                  (set_tile "z_scale" (rtos z_scale))
  590.     (setq rotation 0.0)                 (set_tile "rotation" (angtos rotation))
  591.  
  592.     ;; If a default exists for the on screen toggle, use it.  Else set the
  593.     ;; toggle to 1.
  594.     (if (setq on_screen (cadr (assoc "ddinsert" ai_defaults)))
  595.       (set_tile "on_screen" (itoa on_screen))
  596.       (set_tile "on_screen" (itoa (setq on_screen 1)))
  597.     )
  598.     (on_screen_tog)
  599.  
  600.     (set_tile "explode" "0") (setq explode 0)
  601.     ;; If the last insert was of a *block (explode on), then insname
  602.     ;; will have a * in front of the block name.  If the blk_name
  603.     ;; exists within the drawing, then put the name in the block field
  604.     ;; and leave the File field empty, else put the path in the file field
  605.     ;; and the block name in the block field.  In both cases, leave explode off.
  606.     (setq ins_var (getvar "insname"))
  607.     (if (= "*" (substr ins_var 1 1))
  608.       (setq path_name (substr ins_var 2))
  609.       (setq path_name ins_var)
  610.     )
  611.     (parse_path)
  612.     (set_tile "current_name" blk_name)
  613.     (if (member blk_name table_list)
  614.       (set_tile "path_name" (setq path_name ""))
  615.       (set_tile "path_name" path_name)
  616.     )
  617.  
  618.     (action_tile "int_blocks" "(reset)(int_blocks)")
  619.     (action_tile "ext_blocks" "(reset)(check_fd 0)")
  620.     (action_tile "current_name" "(reset)(check_current)")
  621.     (action_tile "path_name" "(reset)(check_fd 1)")
  622.     (action_tile "on_screen" "(reset)(setq on_screen (atoi $value))(on_screen_tog)")
  623.     (action_tile "x_pt" "(reset)(ai_num $value \"íuX «y╝╨ív╡L«─íC\" 0)")
  624.     (action_tile "y_pt" "(reset)(ai_num $value \"íuY «y╝╨ív╡L«─íC\" 0)")
  625.     (action_tile "z_pt" "(reset)(ai_num $value \"íuZ «y╝╨ív╡L«─íC\" 0)")
  626.     (action_tile "x_scale" "(up_xscale)")
  627.     (action_tile "y_scale"
  628.                  "(reset)(ai_num $value \"íuY ñ±¿╥ívñúÑi¼░ 0 íC\" 2)")
  629.     (action_tile "z_scale"
  630.                  "(reset)(ai_num $value \"íuZ ñ±¿╥ívñúÑi¼░ 0 íC\" 2)")
  631.     (action_tile "rotation"
  632.                  "(reset)(ai_angle $value \"íu▒█┬α¿ñív╡L«─íC\")"
  633.     )
  634.     (action_tile "explode" "(setq explode (atoi $value))(on_screen_tog)")
  635.     (action_tile "accept" "(check_input)")
  636.     (action_tile "cancel" "(done_dialog 0)")
  637.     (action_tile "help" "(acad_helpdlg \"acad.hlp\" \"ddinsert\")")
  638.  
  639.     (setq what_next (start_dialog))
  640.  
  641.     (if (= 1 what_next)
  642.       (progn
  643.         (do_insert)
  644.         (if (assoc "ddinsert" ai_defaults)
  645.           (setq ai_defaults (subst (list "ddinsert" on_screen)
  646.                                    (assoc "ddinsert" ai_defaults)
  647.                                    ai_defaults
  648.                             )
  649.           )
  650.           (setq ai_defaults (cons (list "ddinsert" on_screen) ai_defaults))
  651.         )
  652.        )
  653.     )
  654.   )
  655.  
  656.   ;; Set up error function.
  657.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  658.         old_error  *error*            ; save current error function
  659.         *error* ai_error              ; new error function
  660.   )
  661.  
  662.   (setvar "cmdecho" 0)
  663.  
  664.   (cond
  665.      (  (not (ai_notrans)))                       ; transparent not OK
  666.      (  (not (ai_acadapp)))                       ; ACADAPP.EXP xloaded?
  667.      (  (not (setq dcl_id (ai_dcl "ddinsert"))))  ; is .DCL file loaded?
  668.  
  669.      (t (ddinsert_main))                          ; proceed!
  670.   )
  671.  
  672.   (setq *error* old_error)
  673.   (setvar "cmdecho" old_cmd)
  674.   (princ)
  675. )
  676. ;;;----------------------------------------------------------------------------
  677. (princ "  íuDDINSERTívñw╕ⁿñJíC")
  678. (princ)
  679.