home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / SUPPORT2.LIB / DDMODIFY.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1993-02-08  |  80.6 KB  |  2,710 lines

  1. ;;;----------------------------------------------------------------------------
  2. ;;;   DDMODIFY.LSP
  3. ;;;   ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  4. ;;;
  5. ;;;   Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  6. ;;;   ¡∞½h :
  7. ;;;
  8. ;;;   1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  9. ;;;   2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  10. ;;;
  11. ;;;   Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  12. ;;;   Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  13. ;;;
  14. ;;;
  15. ;;;   Revision date: February 2, 1992
  16. ;;;
  17. ;;;----------------------------------------------------------------------------
  18. ;;;   DESCRIPTION
  19. ;;;
  20. ;;;   This function allows the user to get a listing comparable to the LIST
  21. ;;;   command for most entities.  In addition, most entity fields in the
  22. ;;;   dialogue box are editable.  Points can be specified dynamically by
  23. ;;;   temporarily dismissing the dialogue box.  Each entity has a unique
  24. ;;;   dialogue.
  25. ;;;
  26. ;;;   Naming conventions
  27. ;;;   Long function and widget names may use an underscore "_"
  28. ;;;   in their names to make them easier to read, long variable
  29. ;;;   names use a dash "-".
  30. ;;;----------------------------------------------------------------------------
  31. ;;;----------------------------------------------------------------------------
  32. ;;;   Prefixes in command and keyword strings:
  33. ;;;      "."  specifies the built-in AutoCAD command in case it has been
  34. ;;;           redefined.
  35. ;;;      "_"  denotes an AutoCAD command or keyword in the native language
  36. ;;;           version, English.
  37. ;;;----------------------------------------------------------------------------
  38. ;;;
  39. ;;;
  40. ;;;
  41. ;;; ===========================================================================
  42. ;;; ===================== load-time error checking ============================
  43.  
  44.   (defun ai_abort (app msg)
  45.      (defun *error* (s)
  46.         (if old_error (setq *error* old_error))
  47.         (princ)
  48.      )
  49.      (if msg
  50.        (alert (strcat " └│Ñ╬╡{ªí┐∙╗~: "
  51.                       app
  52.                       " \n\n  "
  53.                       msg
  54.                       "  \n"
  55.               )
  56.        )
  57.      )
  58.      (exit)
  59.   )
  60.  
  61. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  62. ;;; and then try to load it.  If it can't be found or can't be
  63. ;;; loaded, then abort the loading of this file immediately.
  64.  
  65.   (cond
  66.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  67.  
  68.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  69.         (ai_abort "DDMODIFY"
  70.                   (strcat "ºΣñú¿∞íuAI_UTILS.LSPív└╔«╫;"
  71.                           "\n  ╜╨└╦¼díusupportívÑ╪┐²íC")))
  72.  
  73.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  74.         (ai_abort "DDMODIFY" "╡L¬k╕ⁿñJíuAI_UTILS.LSPív└╔«╫"))
  75.   )
  76.  
  77. ;;; If we get this far, then AI_UTILS.LSP is loaded and it can
  78. ;;; be assumed that all functions defined therein are available.
  79.  
  80. ;;; Next, check to see if ACADAPP.EXP has been xloaded, and abort
  81. ;;; if the file can't be found or xloaded.  Note that AI_ACADAPP
  82. ;;; does not abort the running application itself (so that it can
  83. ;;; also be called from within the command without also stopping
  84. ;;; an AutoCAD command currently in progress).
  85.  
  86.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  87.       (ai_abort "DDMODIFY" nil)        ; a Nil <msg> supresses
  88.   )                                    ; ai_abort's alert box dialog.
  89.  
  90. ;;; ==================== end load-time operations ===========================
  91.  
  92. ;;; If we get this far, both ai_utils.lsp and acadapp.exp are
  93. ;;; assumed to be available.
  94.  
  95. ;;; Define and encapsulate all subroutines that are declared
  96. ;;; locals of the (ddmodify) function.
  97.  
  98. (defun ddmodify_init ()
  99.   ;;
  100.   ;; These two functions modify the enitity list for common properties.  Since
  101.   ;; color, ltype, and thickness are absent from the entity list when they are
  102.   ;; set to their defaults (i.e. color = bylayer), a simple substitution using
  103.   ;; SUBST is not possible.
  104.   ;;
  105.   (defun modify_properties ()
  106.     (emod ecolor 62)
  107.     (emod eltype 6)
  108.     (emod ethickness 39)
  109.     (tempmod elayer 8 nil)
  110.   )
  111.  
  112.   (defun emod (value bit)
  113.     (if (= bit 62)
  114.       (progn
  115.         (if (= value "BYLAYER") (setq value 256))
  116.         (if (= value "BYBLOCK") (setq value 0))
  117.       )
  118.     )
  119.     (if (setq oldlist (cdr (assoc bit elist)))
  120.       (tempmod value bit nil)
  121.       (setq elist (append elist (list (cons bit value))))
  122.     )
  123.   )
  124.   ;;
  125.   ;; Resets entity list to original values.  Called when the dialogue or function
  126.   ;; is cancelled.
  127.   ;;
  128.   (defun reset ()
  129.     (setq elist  old-elist
  130.           ecolor (cdr (assoc 62 old-elist))
  131.           eltype (cdr (assoc 6 old-elist))
  132.           elayer (cdr (assoc 8 old-elist))
  133.           ethickness (cdr (assoc 39 old-elist))
  134.     )
  135.     (if (not ecolor) (setq ecolor "BYLAYER"))
  136.     (if (not eltype) (setq eltype "BYLAYER"))
  137.     (if (not ethickness) (setq ethickness 0))
  138.     (modify_properties)
  139.     (setq reset_flag t)
  140.     (entmod elist)
  141.   )
  142.   ;;
  143.   ;; Modify entity when dialogue is temporarily dismissed to reflect latest
  144.   ;; settings of dialogue.  It converts the point from current UCS coordinates to
  145.   ;; the proper entity coordinates (world or entity).
  146.   ;;
  147.   ;; Arguments: value - in current UCS coordinates
  148.   ;;            bit   - entity code (i.e. 10 for start point)
  149.   ;;            ptype - point type  0=world 1=planar
  150.   ;;
  151.   (defun tempmod (value bit ptype / newpoint)
  152.     (cond
  153.       ((= ptype 1) (setq value (trans value 1 ename)))
  154.       ((= ptype 0) (setq value (trans value 1 0)))
  155.     )
  156.     (setq elist (subst (cons bit value)
  157.                        (assoc bit elist)
  158.                        elist
  159.                 )
  160.     )
  161.   )
  162.   ;;
  163.   ;; The following functions are called after a dialogue has been temporarily
  164.   ;; dismissed and the user is selecting a point.  If a point is selected the
  165.   ;; entity list is modified and new X,Y,Z values set.  If no point is selected
  166.   ;; (null response), then the point is reset back to its previous values.
  167.   ;;
  168.   (defun ver_pt1 (ptype)
  169.     (if pt1
  170.       (progn
  171.         (tempmod pt1 10 ptype)
  172.         (entmod elist)
  173.       )
  174.       (setq pt1 (list x1 y1 z1))
  175.     )
  176.   )
  177.  
  178.   ; (move_pt1 <ptype> )
  179.   ;
  180.   ; Called in liew of (ver_pt1) to translate block insertions which
  181.   ; might have variable attributes attached to them.  If the distance
  182.   ; the block is to be moved is < 1e-6, the move is deferred.
  183.  
  184.   (defun move_pt1 (ptype / basept hi)
  185.     (setq basept (trans (cdr (assoc 10 (entget ename))) ename 1))
  186.     (cond
  187.        (  (not pt1)
  188.           (setq pt1 (list x1 y1 z1)))
  189.  
  190.        (  (> 1e-6 (distance pt1 basept)))
  191.  
  192.        (t (tempmod pt1 10 ptype)
  193.           (setq hi (getvar "highlight"))
  194.           (setvar "highlight" 0)
  195.           (command "._move" ename "" basept pt1)
  196.           (setvar "highlight" hi))
  197.     )
  198.   )
  199.  
  200.   (defun ver_pt2 (ptype)
  201.     (if pt2
  202.       (progn
  203.         (tempmod pt2 11 ptype)
  204.         (entmod elist)
  205.       )
  206.       (setq pt2 (list x2 y2 z2))
  207.     )
  208.   )
  209.  
  210.   (defun ver_pt3 (ptype)
  211.     (if pt3
  212.       (progn
  213.         (tempmod pt3 12 ptype)
  214.         (entmod elist)
  215.       )
  216.       (setq pt3 (list x3 y3 z3))
  217.     )
  218.   )
  219.  
  220.   (defun ver_pt4 (ptype)
  221.     (if pt4
  222.       (progn
  223.         (tempmod pt4 13 ptype)
  224.         (entmod elist)
  225.       )
  226.       (setq pt4 (list x4 y4 z4))
  227.     )
  228.   )
  229.   ;;
  230.   ;; Common properties for all entities
  231.   ;;
  232.   (defun set_tile_props ()
  233.     (set_tile "error" "")
  234.     (setcolor)
  235.     (set_tile "t_ltype" (nth lt-idx ltnmlst))
  236.     (set_tile "t_layer" (nth lay-idx laynmlst))
  237.     (set_tile "eb_thickness" (rtos ethickness))
  238.   )
  239.   ;;
  240.   ;; XYZ Point values for all enitites
  241.   ;;
  242.   (defun set_tile_pt1 (ptype)
  243.     (if (= ptype 0)
  244.       (setq pt1 (trans (cdr (assoc 10 elist)) 0 1))
  245.       (setq pt1 (trans (cdr (assoc 10 elist)) ename 1))
  246.     )
  247.     (set_tile "x1_pt" (rtos (setq x1 (car pt1))))
  248.     (set_tile "y1_pt" (rtos (setq y1 (cadr pt1))))
  249.     (set_tile "z1_pt" (rtos (setq z1 (caddr pt1))))
  250.   )
  251.   (defun set_tile_pt2 (ptype)
  252.     (if (= ptype 0)
  253.       (setq pt2 (trans (cdr (assoc 11 elist)) 0 1))
  254.       (setq pt2 (trans (cdr (assoc 11 elist)) ename 1))
  255.     )
  256.     (set_tile "x2_pt" (rtos (setq x2 (car pt2))))
  257.     (set_tile "y2_pt" (rtos (setq y2 (cadr pt2))))
  258.     (set_tile "z2_pt" (rtos (setq z2 (caddr pt2))))
  259.   )
  260.   (defun set_tile_pt3 (ptype)
  261.     (if (= ptype 0)
  262.       (setq pt3 (trans (cdr (assoc 12 elist)) 0 1))
  263.       (setq pt3 (trans (cdr (assoc 12 elist)) ename 1))
  264.     )
  265.     (set_tile "x3_pt" (rtos (setq x3 (car pt3))))
  266.     (set_tile "y3_pt" (rtos (setq y3 (cadr pt3))))
  267.     (set_tile "z3_pt" (rtos (setq z3 (caddr pt3))))
  268.   )
  269.   (defun set_tile_pt4 (ptype)
  270.     (if (= ptype 0)
  271.       (setq pt4 (trans (cdr (assoc 13 elist)) 0 1))
  272.       (setq pt4 (trans (cdr (assoc 13 elist)) ename 1))
  273.     )
  274.     (set_tile "x4_pt" (rtos (setq x4 (car pt4))))
  275.     (set_tile "y4_pt" (rtos (setq y4 (cadr pt4))))
  276.     (set_tile "z4_pt" (rtos (setq z4 (caddr pt4))))
  277.   )
  278.   ;;
  279.   ;; Handle for all entities
  280.   ;;
  281.   (defun set_tile_handle ()
  282.     (if (setq hand (cdr (assoc 5 elist)))
  283.       (set_tile "Handle" hand)
  284.       (set_tile "Handle" "None")
  285.     )
  286.   )
  287.   ;;
  288.   ;; Radius for ARC and CIRCLE
  289.   ;;
  290.   (defun set_tile_rad ()
  291.     (setq radius (cdr (assoc 40 elist)))
  292.     (set_tile "radius" (rtos radius))
  293.   )
  294.   ;;
  295.   ;; Start angle for ARC
  296.   ;;
  297.   (defun set_tile_stang ()
  298.     (setq st_ang (cdr (assoc 50 elist)))
  299.     (set_tile "st_ang" (angtos st_ang))
  300.   )
  301.   ;;
  302.   ;; End angle for ARC
  303.   ;;
  304.   (defun set_tile_endang ()
  305.     (setq end_ang (cdr (assoc 51 elist)))
  306.     (set_tile "end_ang" (angtos end_ang))
  307.   )
  308.   ;;
  309.   ;; Width Factor - Text, Attributes, Block insertions and Shapes
  310.   ;;
  311.   (defun set_tile_rot ()
  312.     (setq rot (cdr (assoc 50 elist)))
  313.     (set_tile "rot" (angtos rot))
  314.   )
  315.   ;;
  316.   ;; Width Factor - Text, Attributes and Shapes
  317.   ;;
  318.   (defun set_tile_hght ()
  319.     (setq hght (cdr (assoc 40 elist)))
  320.     (set_tile "hght" (rtos hght))
  321.   )
  322.   ;;
  323.   ;; Width Factor - Text, Attributes and Shapes
  324.   ;;
  325.   (defun set_tile_wid ()
  326.     (setq wid (cdr (assoc 41 elist)))
  327.     (set_tile "wid" (rtos wid))
  328.   )
  329.   ;;
  330.   ;; Obliquing Angle - Text, Attributes and Shapes
  331.   ;;
  332.   (defun set_tile_obl ()
  333.     (setq obl (cdr (assoc 51 elist)))
  334.     (set_tile "obl" (angtos obl))
  335.   )
  336.   ;;
  337.   ;; Text string
  338.   ;;
  339.   (defun set_tile_text ()
  340.     (setq text (cdr (assoc 1 elist)))
  341.     (set_tile "t_string" text)
  342.   )
  343.   ;;
  344.   ;; Attribute Tag
  345.   ;;
  346.   (defun set_tile_tag ()
  347.     (if (= etype "ATTDEF")
  348.       (progn
  349.         (setq attag (cdr (assoc 2 elist)))
  350.         (set_tile "tag" attag)
  351.       )
  352.     )
  353.   )
  354.   ;;
  355.   ;; Attribute Definition
  356.   ;;
  357.   (defun set_tile_prompt ()
  358.     (if (= etype "ATTDEF")
  359.       (progn
  360.         (setq atprompt (cdr (assoc 3 elist)))
  361.         (set_tile "prompt" atprompt)
  362.       )
  363.     )
  364.   )
  365.   ;;
  366.   ;; Justification setting for Attributes and Text.  Initializes
  367.   ;; popup list box
  368.   ;;
  369.   (defun set_tile_just ()
  370.     (setq ha (cdr (assoc 72 elist)))  ; horizontal alignment
  371.     (setq va (cdr (assoc 73 elist)))  ; vertical alignment
  372.     (setq jlist
  373.           (list "Left"        "Center"        "Right"
  374.                 "Aligned"     "Middle"        "Fit"
  375.                 "Top left"    "Top center"    "Top right"
  376.                 "Middle left" "Middle center" "Middle right"
  377.                 "Bottom left" "Bottom center" "Bottom right"
  378.           )
  379.     )
  380.     (start_list "popup_just")
  381.     (mapcar 'add_list jlist)
  382.     (end_list)
  383.     (set_just_idx)
  384.     (set_tile "popup_just" (jlist_act just-idx))
  385.   )
  386.   ;;
  387.   ;; Style setting for Attributes and Text.  Reads symbol table for popup list
  388.   ;; box.
  389.   ;;
  390.   (defun set_tile_style (/ sname style-idx)
  391.     (setq slist (list (cdr (assoc 2 (tblnext "STYLE" T)))))
  392.     (while (setq sname (cdr (assoc 2 (tblnext "STYLE"))))
  393.       (if (/= sname "") (setq slist (cons sname slist)))
  394.     )
  395.     (setq slist (acad_strlsort slist))  ; alphabetize style list
  396.     (start_list "style")
  397.     (mapcar 'add_list slist)
  398.     (end_list)
  399.     (setq tstyle (cdr (assoc 7 elist)))
  400.     (setq style-idx (getindex tstyle slist))
  401.     (set_tile "style" (itoa style-idx))
  402.   )
  403.   ;;
  404.   ;; Text and Attribute setting - upside-down, backwards
  405.   ;;
  406.   (defun set_tile_bk-up ()
  407.     (setq bk-up (cdr (assoc 71 elist)))
  408.     (if (= (logand bk-up 2) 2)
  409.       (set_tile "bkwd" (itoa (setq bkwd 1)))
  410.       (set_tile "bkwd" (itoa (setq bkwd 0)))
  411.     )
  412.     (if (= (logand bk-up 4) 4)
  413.       (set_tile "upsd" (itoa (setq upsd 1)))
  414.       (set_tile "upsd" (itoa (setq upsd 0)))
  415.     )
  416.   )
  417.   ;;
  418.   ;; Attribute setting - invisible, constant, verify, preset
  419.   ;;
  420.   (defun set_tile_icvp ()
  421.     (if (not (setq icvp (cdr (assoc 70 elist))))
  422.       (setq icvp 0)
  423.     )
  424.     (if (= (logand icvp 1) 1)
  425.       (set_tile "inv" (itoa (setq inv 1)))
  426.       (set_tile "inv" (itoa (setq inv 0)))
  427.     )
  428.     (if (= (logand icvp 2) 2)
  429.       (set_tile "con" (itoa (setq con 1)))
  430.       (set_tile "con" (itoa (setq con 0)))
  431.     )
  432.     (if (= (logand icvp 4) 4)
  433.       (set_tile "ver" (itoa (setq ver 1)))
  434.       (set_tile "ver" (itoa (setq ver 0)))
  435.     )
  436.     (if (= (logand icvp 8) 8)
  437.       (set_tile "pre" (itoa (setq pre 1)))
  438.       (set_tile "pre" (itoa (setq pre 0)))
  439.     )
  440.   )
  441.   ;;
  442.   ;; Scale factors for block insertions
  443.   ;;
  444.   (defun set_tile_scale ()
  445.     (setq xscale (cdr (assoc 41 elist)))
  446.     (set_tile "xscale" (rtos xscale))
  447.     (setq yscale (cdr (assoc 42 elist)))
  448.     (set_tile "yscale" (rtos yscale))
  449.     (setq zscale (cdr (assoc 43 elist)))
  450.     (set_tile "zscale" (rtos zscale))
  451.   )
  452.   ;;
  453.   ;; Rows and columns for block insertions
  454.   ;;
  455.   (defun set_tile_rc ()
  456.     (setq columns (cdr (assoc 70 elist)))
  457.     (set_tile "columns" (itoa columns ))
  458.     (setq rows (cdr (assoc 71 elist)))
  459.     (set_tile "rows" (itoa rows))
  460.     (setq col-sp (cdr (assoc 44 elist)))
  461.     (set_tile "col_sp" (rtos col-sp))
  462.     (setq row-sp (cdr (assoc 45 elist)))
  463.     (set_tile "row_sp" (rtos row-sp))
  464.   )
  465.   ;;
  466.   ;; Invisible edges for 3DFACE
  467.   ;;
  468.   (defun set_tile_edges ()
  469.     (setq f-vis (cdr (assoc 70 elist)))
  470.     (if (= (logand f-vis 1) 1)
  471.       (set_tile "edge_1" (setq edge1 "0"))
  472.       (set_tile "edge_1" (setq edge1 "1"))
  473.     )
  474.     (if (= (logand f-vis 2) 2)
  475.       (set_tile "edge_2" (setq edge2 "0"))
  476.       (set_tile "edge_2" (setq edge2 "1"))
  477.     )
  478.     (if (= (logand f-vis 4) 4)
  479.       (set_tile "edge_3" (setq edge3 "0"))
  480.       (set_tile "edge_3" (setq edge3 "1"))
  481.     )
  482.     (if (= (logand f-vis 8) 8)
  483.       (set_tile "edge_4" (setq edge4 "0"))
  484.       (set_tile "edge_4" (setq edge4 "1"))
  485.     )
  486.   )
  487.   ;;
  488.   ;; XYZ Point values for polyline vertex
  489.   ;;
  490.   (defun set_tile_vpt (ptype)
  491.     (if (= ptype 0)
  492.       (setq vpt (trans (cdr (assoc 10 vlist)) 0 1))
  493.       (setq vpt (trans (cdr (assoc 10 vlist)) ename 1))
  494.     )
  495.     (set_tile "xtext" (rtos (setq x1 (car vpt))))
  496.     (set_tile "ytext" (rtos (setq y1 (cadr vpt))))
  497.     (set_tile "ztext" (rtos (setq z1 (caddr vpt))))
  498.   )
  499.   ;;
  500.   ;; Fit curve, fit spline, or smooth spline surface setting
  501.   ;;
  502.   (defun set_tile_fitsmooth ()
  503.     (cond
  504.       ((= (logand bit70 4) 4)
  505.        (cond
  506.          ((= bit75 0)
  507.            (set_tile "none" "1")
  508.            (setq spltype 0)
  509.          )
  510.          ((= bit75 5)
  511.            (set_tile "quad" "1")
  512.            (setq spltype 5)
  513.          )
  514.          ((= bit75 6)
  515.            (set_tile "cubic" "1")
  516.            (setq spltype 6)
  517.          )
  518.          ((= bit75 8)
  519.            (set_tile "bezier" "1")
  520.            (setq spltype 8)
  521.          )
  522.        )
  523.       )
  524.       ((= (logand bit70 2) 2)
  525.         (set_tile "fit" "1")
  526.         (setq spltype 1)
  527.       )
  528.       (T (set_tile "none" "1"))
  529.     )
  530.   )
  531.   ;;
  532.   ;; Closed or Open mesh and polyline setting
  533.   ;;
  534.   (defun set_tile_closed ()
  535.       (if (= pltype "3D mesh")
  536.         (progn
  537.           (if (= (logand bit70 32) 32)
  538.             (set_tile "closedn" (setq closedn "1"))
  539.             (set_tile "closedn" (setq closedn "0"))
  540.           )
  541.           (if (= (logand bit70 1) 1)
  542.             (set_tile "closedm" (setq closed "1"))
  543.             (set_tile "closedm" (setq closed "0"))
  544.           )
  545.           (setq old-closedm closedm old-closedn closedn)
  546.         )
  547.       )
  548.       (if (or (= pltype "2D polyline")
  549.               (= pltype "3D polyline")
  550.           )
  551.         (progn
  552.           (if (= (logand bit70 1) 1)
  553.             (set_tile "closed" (setq closed "1"))
  554.             (set_tile "closed" (setq closed "0"))
  555.           )
  556.           (setq old-closed closed)
  557.         )
  558.       )
  559.   )
  560.   ;; Set common action tiles
  561.   ;;
  562.   ;; Defines action to be taken when pressing various widgets.  It is called
  563.   ;; for every entity dialogue.  Not all widgets exist for each entity dialogue,
  564.   ;; but defining an action for a non-existent widget does no harm.
  565.   (defun set_action_tiles ()
  566.     (action_tile "cancel"       "(dismiss_dialog 0)")
  567.     (action_tile "accept"       "(dismiss_dialog 1)")
  568.     (action_tile "help"         "(acad_helpdlg \"acad.hlp\" help_entry)")
  569.     (action_tile "b_color"      "(getcolor)")
  570.     (action_tile "show_image"   "(getcolor)")
  571.     (action_tile "b_name"       "(setq elayer (getlayer))")
  572.     (action_tile "b_line"       "(setq eltype (getltype))")
  573.     (action_tile "eb_thickness" "(getthickness $value)")
  574.  
  575.     (action_tile "pick_1"       "(dismiss_dialog 3)")
  576.     (action_tile "pick_2"       "(dismiss_dialog 4)")
  577.     (action_tile "pick_3"       "(dismiss_dialog 5)")
  578.     (action_tile "pick_4"       "(dismiss_dialog 6)")
  579.     (action_tile "x1_pt"        "(ver_x1 $value)")
  580.     (action_tile "y1_pt"        "(ver_y1 $value)")
  581.     (action_tile "z1_pt"        "(ver_z1 $value)")
  582.     (action_tile "x2_pt"        "(ver_x2 $value)")
  583.     (action_tile "y2_pt"        "(ver_y2 $value)")
  584.     (action_tile "z2_pt"        "(ver_z2 $value)")
  585.     (action_tile "x3_pt"        "(ver_x3 $value)")
  586.     (action_tile "y3_pt"        "(ver_y3 $value)")
  587.     (action_tile "z3_pt"        "(ver_z3 $value)")
  588.     (action_tile "x4_pt"        "(ver_x4 $value)")
  589.     (action_tile "y4_pt"        "(ver_y4 $value)")
  590.     (action_tile "z4_pt"        "(ver_4 $value)")
  591.  
  592.     (action_tile "edge_1"       "(setq edge1 $value)")
  593.     (action_tile "edge_2"       "(setq edge2 $value)")
  594.     (action_tile "edge_3"       "(setq edge3 $value)")
  595.     (action_tile "edge_4"       "(setq edge4 $value)")
  596.  
  597.     (action_tile "radius"       "(ver_rad $value)")
  598.     (action_tile "st_ang"       "(ver_ang1 $value)")
  599.     (action_tile "end_ang"      "(ver_ang2 $value)")
  600.  
  601.     (action_tile "xscale"       "(ver_xscl $value)")
  602.     (action_tile "yscale"       "(ver_yscl $value)")
  603.     (action_tile "zscale"       "(ver_zscl $value)")
  604.     (action_tile "rot"          "(ver_rot $value)")
  605.     (action_tile "columns"      "(ver_col $value)")
  606.     (action_tile "rows"         "(ver_row $value)")
  607.     (action_tile "col_sp"       "(ver_colsp $value)")
  608.     (action_tile "row_sp"       "(ver_rowsp $value)")
  609.  
  610.     (action_tile "hght"         "(ver_hght $value)")
  611.     (action_tile "wid"          "(ver_wid $value)")
  612.     (action_tile "obl"          "(ver_obl $value)")
  613.     (action_tile "style"        "(style_act $value)")
  614.  
  615.     (action_tile "t_string"     "(setq text $value)")
  616.     (action_tile "tag"          "(ver_tag $value)")
  617.     (action_tile "prompt"       "(setq atprompt $value)")
  618.     (action_tile "bkwd"         "(setq bkwd (atoi $value))")
  619.     (action_tile "upsd"         "(setq upsd (atoi $value))")
  620.     (action_tile "inv"          "(setq inv (atoi $value))")
  621.     (action_tile "con"          "(setq con (atoi $value))")
  622.     (action_tile "ver"          "(setq ver (atoi $value))")
  623.     (action_tile "pre"          "(setq pre (atoi $value))")
  624.     (action_tile "popup_just"   "(jlist_act $value)")
  625.  
  626.     (action_tile "closed"       "(setq closed $value)")
  627.     (action_tile "ltgen"        "(setq ltgen $value)")
  628.     (action_tile "closedm"      "(setq closedm $value)")
  629.     (action_tile "closedn"      "(setq closedn $value)")
  630.     (action_tile "next_v"       "(next_vertex)")
  631.  
  632.     (action_tile "none"         "(if (radio_gaga \"none\")(set_uv 0))")
  633.     (action_tile "fit"          "(if (radio_gaga \"fit\")(set_uv 1))")
  634.     (action_tile "quad"         "(if (radio_gaga \"quad\")(set_uv 5))")
  635.     (action_tile "cubic"        "(if (radio_gaga \"cubic\")(set_uv 6))")
  636.     (action_tile "bezier"       "(if (radio_gaga \"bezier\")(set_uv 8))")
  637.  
  638.     (action_tile "u"            "(ver_u $value)")
  639.     (action_tile "v"            "(ver_v $value)")
  640.   )
  641.   ;; As OW doesn't support disabling of individual radio buttons within
  642.   ;; clusters, a check must be performed as to the legitimacy of the
  643.   ;; button pushed and reset if necessary.
  644.   (defun radio_gaga (pushed)
  645.     (cond
  646.       ((and (= pltype "3D polyline")
  647.             (or (= pushed "fit")
  648.                 (= pushed "bezier")
  649.             )
  650.        )
  651.         (set_tile "none" "1")
  652.         nil
  653.       )
  654.       ((and (= pltype "3D mesh")
  655.             (= "fit" pushed)
  656.        )
  657.         (set_tile "none" "1")
  658.         nil
  659.       )
  660.       ((= pltype "Polyface mesh")
  661.         (set_tile "none" "1")
  662.         nil
  663.       )
  664.       ((and (= pltype "2D polyline")
  665.             (= "bezier" pushed)
  666.        )
  667.         (set_tile "none" "1")
  668.         nil
  669.       )
  670.       (T)
  671.     )
  672.   )
  673.   ;;
  674.   (defun set_uv (type)
  675.     (setq spltype type)
  676.     (if (= pltype "3D mesh")
  677.       (if (= spltype 0)
  678.         (progn
  679.           (set_tile "u" (itoa (setq u 0)))
  680.           (set_tile "v" (itoa (setq v 0)))
  681.         )
  682.         (progn
  683.           (if (= u 0)
  684.             (set_tile "u" (itoa (setq u (getvar "surfu"))))
  685.           )
  686.           (if (= v 0)
  687.             (set_tile "v" (itoa (setq v (getvar "surfv"))))
  688.           )
  689.         )
  690.       )
  691.     )
  692.   )
  693.  
  694.  
  695.   ;;
  696.   ;; Verification functions
  697.   ;;
  698.   ;; Verify distance function.  This takes a new X, Y, or Z coordinate or
  699.   ;; distance value, the tile name, and the previous value as arguments.
  700.   ;; If the distance is valid, it returns the distance and resets the tile.
  701.   ;; Otherwise, it returns the previous value, sets the error tile and keeps
  702.   ;; focus on the tile.  Shifting focus to the tile with invalid value can
  703.   ;; trigger a callback from another tile whose value is valid.  In order
  704.   ;; to keep the error message from being cleared by this secondary callback,
  705.   ;; the variable errchk is set and checked.  The last-tile variable is set
  706.   ;; and checked to ensure the error message is properly cleared when the
  707.   ;; user corrects the value and hits return.
  708.   ;;
  709.   (defun verify_d (tile value old-value / coord valid errmsg)
  710.     (setq valid nil errmsg "┐ΘñJ¡╚╡L«─íC")
  711.     (if (setq coord (distof value))
  712.       (progn
  713.         (cond
  714.           ((or (= tile "radius")
  715.                (= tile "hght")
  716.                (= tile "wid")
  717.            )
  718.            (if (> coord 0)
  719.              (setq valid T)
  720.              (setq errmsg "╝╞¡╚╢╖¼░ > 0 ¬║íuÑ┐¡╚ívíC")
  721.            )
  722.           )
  723.           ((or (= tile "xscale")
  724.                (= tile "yscale")
  725.                (= tile "zscale")
  726.            )
  727.            (if (/= coord 0)
  728.              (setq valid T)
  729.              (setq errmsg "╝╞¡╚ñúÑi¼░ 0 íC")
  730.            )
  731.           )
  732.           (T (setq valid T))
  733.         )
  734.       )
  735.       (setq valid nil)
  736.     )
  737.     (if valid
  738.       (progn
  739.         (if (or (= errchk 0) (= tile last-tile))
  740.           (set_tile "error" "")
  741.         )
  742.         (set_tile tile (rtos coord))
  743.         (setq errchk 0)
  744.         (setq last-tile tile)
  745.         coord
  746.       )
  747.       (progn
  748.         (mode_tile tile 2)
  749.         (set_tile "error" errmsg)
  750.         (setq errchk 1)
  751.         (setq last-tile tile)
  752.         old-value
  753.       )
  754.     )
  755.   )
  756.   ;;
  757.   ;; Verify angle function.  This takes an angle and a tile name as arguments.
  758.   ;; If the angle is valid, it returns the angle and resets the tile.
  759.   ;; Otherwise, it sets the error tile and keeps focus on the tile.
  760.   ;;
  761.   (defun verify_a (tile value old-value / ang)
  762.     (if (setq ang (angtof value))
  763.       (progn
  764.         (if (or (= errchk 0) (= tile last-tile))
  765.           (set_tile "error" "")
  766.         )
  767.         (set_tile tile (angtos ang))
  768.         (setq errchk 0)
  769.         (setq last-tile tile)
  770.         ang
  771.       )
  772.       (progn
  773.         (mode_tile tile 2)
  774.         (setq last-tile tile)
  775.         (setq errchk 1)
  776.         (set_tile "error" "┐ΘñJ¡╚ñúªX▓zíC")
  777.         old-value
  778.       )
  779.     )
  780.   )
  781.   ;;
  782.   ;; Verify integer function.  This takes an integer and a tile name as
  783.   ;; arguments.  If the integer is valid, it returns the integer and resets the
  784.   ;; tile.  Otherwise, it sets the error tile and keeps focus on the tile.
  785.   ;;
  786.   (defun verify_i (tile value old-value / int valid errmsg)
  787.     (setq valid nil)
  788.     (setq errmsg "╝╞¡╚╢╖¼░íu╛π╝╞ívíC")
  789.     (setq int (atoi value))
  790.     (if (setq intchk (distof value))
  791.       (cond
  792.         ((or (= tile "columns") (= tile "rows"))
  793.          (if (and (= int intchk)
  794.                   (>= int 0)
  795.                   (< int 32767)
  796.              )
  797.            (setq valid T)
  798.            (setq errmsg "╝╞¡╚╢╖¼░ñ╢⌐≤ 1 í╨ 32767 ñº╢í¬║íu╛π╝╞ívíC")
  799.          )
  800.         )
  801.         ((and (or (= tile "u") (= tile "v")))
  802.          (if (and (= int intchk)
  803.                   (>= int 0)
  804.                   (< int 201)
  805.              )
  806.            (setq valid T)
  807.            (setq errmsg "╝╞¡╚╢╖¼░ñ╢⌐≤ 0 í╨ 200 ñº╢í¬║íu╛π╝╞ívíC")
  808.          )
  809.         )
  810.       )
  811.     )
  812.     (if valid
  813.       (progn
  814.         (if (or (= errchk 0) (= tile last-tile))
  815.             (set_tile "error" "")
  816.         )
  817.         (set_tile tile (itoa int))
  818.         (setq errchk 0)
  819.         (setq last-tile tile)
  820.         int
  821.       )
  822.       (progn
  823.         (mode_tile tile 2)
  824.         (set_tile "error" errmsg)
  825.         (setq errchk 1)
  826.         (setq last-tile tile)
  827.         old-value
  828.       )
  829.     )
  830.   )
  831.   ;;
  832.   ;; Functions that verify tile values for integers
  833.   ;;
  834.   (defun ver_col (value)
  835.     (setq columns (verify_i "columns" value columns))
  836.   )
  837.   (defun ver_row (value)
  838.     (setq rows (verify_i "rows" value rows))
  839.   )
  840.   (defun ver_u (value)
  841.     (setq u (verify_i "u" value u))
  842.   )
  843.   (defun ver_v (value)
  844.     (setq v (verify_i "v" value v))
  845.   )
  846.   ;;
  847.   ;; Functions that verify tile values for reals
  848.   ;;
  849.   (defun ver_x1 (value)
  850.     (if (setq x1 (verify_d "x1_pt" value x1)) (calc))
  851.   )
  852.   (defun ver_y1 (value)
  853.     (if (setq y1 (verify_d "y1_pt" value y1)) (calc))
  854.   )
  855.   (defun ver_z1 (value)
  856.     (if (setq z1 (verify_d "z1_pt" value z1)) (calc))
  857.   )
  858.   (defun ver_x2 (value)
  859.     (if (setq x2 (verify_d "x2_pt" value x2)) (calc))
  860.   )
  861.   (defun ver_y2 (value)
  862.     (if (setq y2 (verify_d "y2_pt" value y2)) (calc))
  863.   )
  864.   (defun ver_z2 (value)
  865.     (if (setq z2 (verify_d "z2_pt" value z2)) (calc))
  866.   )
  867.   (defun ver_x3 (value)
  868.     (setq x3 (verify_d "x3_pt" value x3))
  869.   )
  870.   (defun ver_y3 (value)
  871.     (setq y3 (verify_d "y3_pt" value y3))
  872.   )
  873.   (defun ver_z3 (value)
  874.     (setq z3 (verify_d "z3_pt" value z3))
  875.   )
  876.   (defun ver_x4 (value)
  877.     (setq x4 (verify_d "x4_pt" value x4))
  878.   )
  879.   (defun ver_y4 (value)
  880.     (setq y4 (verify_d "y4_pt" value y4))
  881.   )
  882.   (defun ver_4 (value)
  883.     (setq z4 (verify_d "z4_pt" value z4))
  884.   )
  885.   (defun ver_xscl (value)
  886.     (setq xscale (verify_d "xscale" value xscale))
  887.   )
  888.   (defun ver_yscl (value)
  889.     (setq yscale (verify_d "yscale" value yscale))
  890.   )
  891.   (defun ver_zscl (value)
  892.     (setq zscale (verify_d "zscale" value zscale))
  893.   )
  894.   (defun ver_colsp (value)
  895.     (setq col-sp (verify_d "col_sp" value col-sp))
  896.   )
  897.   (defun ver_rowsp (value)
  898.     (setq row-sp (verify_d "row_sp" value row-sp))
  899.   )
  900.   (defun ver_rad (value)
  901.     (if (setq radius (verify_d "radius" value radius))
  902.       (calc)
  903.     )
  904.   )
  905.   (defun ver_hght (value)
  906.     (setq hght (verify_d "hght" value hght))
  907.   )
  908.   (defun ver_wid (value)
  909.     (setq wid (verify_d "wid" value wid))
  910.   )
  911.   ;;
  912.   ;; Functions that verify tile values for angles
  913.   ;;
  914.   (defun ver_ang1 (value)
  915.     (if (setq st_ang (verify_a "st_ang" value st_ang))
  916.       (calc)
  917.     )
  918.   )
  919.   (defun ver_ang2 (value)
  920.     (if (setq end_ang (verify_a "end_ang" value end_ang))
  921.       (calc)
  922.     )
  923.   )
  924.   (defun ver_rot (value)
  925.     (setq rot (verify_a "rot" value rot))
  926.   )
  927.   (defun ver_obl (value)
  928.     (setq obl (verify_a "obl" value obl))
  929.   )
  930.   ;;
  931.   ;; Function that verifies attribute tag field for null string,
  932.   ;; or a string that contains one or more spaces.  Tile value
  933.   ;; is also converted to upper-case as well.
  934.   ;;
  935.   ;;
  936.   (defun ver_tag (value / tval)
  937.      (set_tile "error" "")
  938.      (cond
  939.         (  (or (eq "" (setq tval (strcase (ai_strtrim value))))
  940.                (wcmatch tval "* *"))
  941.            (set_tile "error" "Invalid attribute tag.")
  942.            (mode_tile "tag" 2))
  943.         (t (set_tile "error" "")
  944.            (set_tile "tag" tval)
  945.            (setq attag tval)))
  946.   )
  947.   ;;
  948.   ;; Calculation functions
  949.   ;;
  950.   (defun calc ()
  951.     (if (= etype "LINE") (line_calc))
  952.     (if (= etype "ARC") (arc_calc))
  953.     (if (= etype "CIRCLE") (cir_calc))
  954.   )
  955.   ;;
  956.   ;; Calculation functions for lines, arcs, and circles
  957.   ;;
  958.   (defun line_calc ()
  959.     (setq stpt  (list x1 y1 z1))
  960.     (setq endpt (list x2 y2 z2))
  961.     (set_tile "delta_x" (rtos (- x2 x1)))
  962.     (set_tile "delta_y" (rtos (- y2 y1)))
  963.     (set_tile "delta_z" (rtos (- z2 z1)))
  964.     (set_tile "l_length" (rtos (distance stpt endpt)))
  965.     (set_tile "l_angle" (angtos (angle stpt endpt)))
  966.   )
  967.  
  968.   (defun cir_calc ()
  969.         (setq radtest radius)
  970.         (set_tile "Dia" (rtos (* 2 radius)))
  971.         (set_tile "Circum" (rtos (* 2 pi radius)))
  972.         (set_tile "Area" (rtos (* pi (* radius radius))))
  973.   )
  974.  
  975.   (defun arc_calc ()
  976.     (setq totang (- end_ang st_ang))
  977.     (while (< totang 0)
  978.       (setq totang (+ totang (* 2 pi)))
  979.     )
  980.     (while (> totang (* 2 pi))
  981.       (setq totang (- totang (* 2 pi)))
  982.     )
  983.     (set_tile "tot_angle" (angtos totang))
  984.     (setq arclen (* (* 2 pi radius) (/ totang (* 2 pi))))
  985.     (set_tile "arclen" (rtos arclen))
  986.   )
  987.   ;;
  988.   ;; Modify POINT
  989.   ;;
  990.   (defun modify_point ()
  991.     (modify_properties)
  992.     (setq pt1 (list x1 y1 z1))
  993.     (tempmod pt1 10 0)
  994.     (entmod elist)
  995.   )
  996.  
  997.   (defun ddpoint ()
  998.     (if (not (new_dialog "ddpoint" dcl_id)) (exit))
  999.     ;; Set initial tile values
  1000.     (set_tile_props)
  1001.     (set_tile_handle)
  1002.     (set_tile_pt1 0)
  1003.     ;; Define action for tiles
  1004.     (set_action_tiles)
  1005.     (setq dialog-state (start_dialog))
  1006.     (if (= dialog-state 0)
  1007.       (reset)
  1008.     )
  1009.     (if (= dialog-state 3)
  1010.       (progn
  1011.         (modify_point)
  1012.         (setq pt1 (getpoint (list x1 y1 z1)  "\n┬I: "))
  1013.         (ver_pt1 0)
  1014.         (ddpoint)
  1015.       )
  1016.     )
  1017.     (if (= dialog-state 1)
  1018.       (modify_point)
  1019.     )
  1020.   )
  1021.   ;;
  1022.   ;; Modify LINE
  1023.   ;;
  1024.   (defun modify_line ()
  1025.     (modify_properties)
  1026.     (setq pt1 (list x1 y1 z1))
  1027.     (setq pt2 (list x2 y2 z2))
  1028.     (tempmod pt1 10 0)
  1029.     (tempmod pt2 11 0)
  1030.     (entmod elist)
  1031.   )
  1032.   (defun ddline ()
  1033.     (if (not (new_dialog "ddline" dcl_id)) (exit))
  1034.     ;; Set initial tile values
  1035.     (set_tile_props)
  1036.     (set_tile_handle)
  1037.     (set_tile_pt1 0)
  1038.     (set_tile_pt2 0)
  1039.     (line_calc)
  1040.     ;; Define action for tiles
  1041.     (set_action_tiles)
  1042.     (setq dialog-state (start_dialog))
  1043.     (if (= dialog-state 0)
  1044.       (reset)
  1045.     )
  1046.     (if (= dialog-state 3)
  1047.       (progn
  1048.         (modify_line)
  1049.         (setq pt1 (getpoint (list x1 y1 z1)  "\n░_⌐l┬I: "))
  1050.         (ver_pt1 0)
  1051.         (ddline)
  1052.       )
  1053.     )
  1054.     (if (= dialog-state 4)
  1055.       (progn
  1056.         (modify_line)
  1057.         (setq pt2 (getpoint (list x2 y2 z2) "\nñUñ@┬I: "))
  1058.         (ver_pt2 0)
  1059.         (ddline)
  1060.       )
  1061.     )
  1062.     (if (= dialog-state 1)
  1063.       (modify_line)
  1064.     )
  1065.   )
  1066.   ;;
  1067.   ;; Modify CIRCLE
  1068.   ;;
  1069.   (defun modify_circle ()
  1070.     (modify_properties)
  1071.     (setq pt1 (list x1 y1 z1))
  1072.     (tempmod pt1 10 1)
  1073.     (tempmod radius 40 nil)
  1074.     (entmod elist)
  1075.   )
  1076.  
  1077.   (defun ddcircle ()
  1078.     (if (not (new_dialog "ddcircle" dcl_id)) (exit))
  1079.     ;; Set initial tile values
  1080.     (set_tile_props)
  1081.     (set_tile_handle)
  1082.     (set_tile_pt1 1)
  1083.     (set_tile_rad)
  1084.     (cir_calc)
  1085.     ;; Define action for tiles
  1086.     (set_action_tiles)
  1087.     (set_tile_pt1 1)
  1088.     (setq dialog-state (start_dialog))
  1089.     (if (= dialog-state 0)
  1090.       (reset)
  1091.     )
  1092.     (if (= dialog-state 1)
  1093.       (modify_circle)
  1094.     )
  1095.     (if (= dialog-state 3)
  1096.       (progn
  1097.         (modify_circle)
  1098.         (setq pt1 (getpoint (list x1 y1 z1)  "\nñññ▀┬I: "))
  1099.         (ver_pt1 1)
  1100.         (ddcircle)
  1101.       )
  1102.     )
  1103.   )
  1104.   ;;
  1105.   ;; Modify ARC
  1106.   ;;
  1107.   (defun modify_arc ()
  1108.     (modify_properties)
  1109.     (setq pt1 (list x1 y1 z1))
  1110.     (tempmod pt1 10 1)
  1111.     (tempmod radius 40 nil)
  1112.     (tempmod st_ang 50 nil)
  1113.     (tempmod end_ang 51 nil)
  1114.     (entmod elist)
  1115.   )
  1116.   (defun ddarc ()
  1117.     (if (not (new_dialog "ddarc" dcl_id)) (exit))
  1118.     ;; Set initial tile values
  1119.     (set_tile_props)
  1120.     (set_tile_handle)
  1121.     (set_tile_pt1 1)
  1122.     (set_tile_rad)
  1123.     (set_tile_stang)
  1124.     (set_tile_endang)
  1125.     (arc_calc)
  1126.     ;; Define action for tiles
  1127.     (set_action_tiles)
  1128.     (setq dialog-state (start_dialog))
  1129.     (if (= dialog-state 0)
  1130.       (reset)
  1131.     )
  1132.     (if (= dialog-state 1)
  1133.       (modify_arc)
  1134.     )
  1135.     (if (= dialog-state 3)
  1136.       (progn
  1137.         (modify_arc)
  1138.         (setq pt1 (getpoint (list x1 y1 z1) "\nñññ▀┬I: "))
  1139.         (ver_pt1 1)
  1140.         (ddarc)
  1141.       )
  1142.     )
  1143.   )
  1144.   ;;
  1145.   ;; Modify SOLID or TRACE
  1146.   ;; Note the Z value of the entity is determined by the Z value of the fourth
  1147.   ;; point - code 13.  Changing the point values of a solid or trace from a UCS
  1148.   ;; that is nonplanar to the UCS the entity was created may confuse the user.
  1149.   (defun modify_solid ()
  1150.     (modify_properties)
  1151.     (setq pt1 (list x1 y1 z1))
  1152.     (setq pt2 (list x2 y2 z2))
  1153.     (setq pt3 (list x3 y3 z3))
  1154.     (setq pt4 (list x4 y4 z4))
  1155.     (tempmod pt1 10 1)
  1156.     (tempmod pt2 11 1)
  1157.     (tempmod pt3 12 1)
  1158.     (tempmod pt4 13 1)
  1159.     (entmod elist)
  1160.   )
  1161.  
  1162.   (defun ddsolid ()
  1163.     (if (= etype "SOLID")
  1164.         (if (not (new_dialog "ddsolid" dcl_id)) (exit))
  1165.         (if (not (new_dialog "ddtrace" dcl_id)) (exit))
  1166.     )
  1167.     ;; Set initial tile values
  1168.     (set_tile_props)
  1169.     (set_tile_handle)
  1170.     (set_tile_pt1 1)
  1171.     (set_tile_pt2 1)
  1172.     (set_tile_pt3 1)
  1173.     (set_tile_pt4 1)
  1174.     ;; Define action for tiles
  1175.     (set_action_tiles)
  1176.     (setq dialog-state (start_dialog))
  1177.     (if (= dialog-state 0)
  1178.       (reset)
  1179.     )
  1180.     (if (= dialog-state 1)
  1181.       (modify_solid)
  1182.     )
  1183.     (if (= dialog-state 3)
  1184.       (progn
  1185.         (modify_solid)
  1186.         (setq pt1 (getpoint (list x1 y1 z1) "\n▓─ 1 ┬I: "))
  1187.         (ver_pt1 1)
  1188.         (ddsolid)
  1189.       )
  1190.     )
  1191.     (if (= dialog-state 4)
  1192.       (progn
  1193.         (modify_solid)
  1194.         (entmod elist)
  1195.         (setq pt2 (getpoint (list x2 y2 z2) "\n▓─ 2 ┬I: "))
  1196.         (ver_pt2 1)
  1197.         (ddsolid)
  1198.       )
  1199.     )
  1200.     (if (= dialog-state 5)
  1201.       (progn
  1202.         (modify_solid)
  1203.         (setq pt3 (getpoint (list x3 y3 z3) "\n▓─ 3 ┬I: "))
  1204.         (ver_pt3 1)
  1205.         (ddsolid)
  1206.       )
  1207.     )
  1208.     (if (= dialog-state 6)
  1209.       (progn
  1210.         (modify_solid)
  1211.         (setq pt4 (getpoint (list x4 y4 z4) "\n▓─ 4 ┬I: "))
  1212.         (ver_pt4 1)
  1213.         (ddsolid)
  1214.       )
  1215.     )
  1216.   )
  1217.   ;;
  1218.   ;; Modify 3DFACE
  1219.   ;;
  1220.   ;; Check visibility of edges
  1221.   ;;
  1222.   (defun edgetest (/ bit1 bit2 bit3 bit4)
  1223.     (if (= edge1 "1") (setq bit1 0) (setq bit1 1))
  1224.     (if (= edge2 "1") (setq bit2 0) (setq bit2 2))
  1225.     (if (= edge3 "1") (setq bit3 0) (setq bit3 4))
  1226.     (if (= edge4 "1") (setq bit4 0) (setq bit4 8))
  1227.     (+ bit1 bit2 bit3 bit4)
  1228.   )
  1229.  
  1230.   (defun modify_3dface ()
  1231.     (modify_properties)
  1232.     (setq pt1 (list x1 y1 z1))
  1233.     (setq pt2 (list x2 y2 z2))
  1234.     (setq pt3 (list x3 y3 z3))
  1235.     (setq pt4 (list x4 y4 z4))
  1236.     (tempmod pt1 10 0)
  1237.     (tempmod pt2 11 0)
  1238.     (tempmod pt3 12 0)
  1239.     (tempmod pt4 13 0)
  1240.     (tempmod (edgetest) 70 nil)
  1241.     (entmod elist)
  1242.   )
  1243.  
  1244.   (defun dd3dface ()
  1245.     (if (not (new_dialog "dd3dface" dcl_id)) (exit))
  1246.     (set_tile_props)
  1247.     (set_tile_handle)
  1248.     (set_tile_pt1 0)
  1249.     (set_tile_pt2 0)
  1250.     (set_tile_pt3 0)
  1251.     (set_tile_pt4 0)
  1252.     (set_tile_edges)
  1253.     ;; Define action for tiles
  1254.     (set_action_tiles)
  1255.     (setq dialog-state (start_dialog))
  1256.     (if (= dialog-state 0)
  1257.       (reset)
  1258.     )
  1259.     (if (= dialog-state 1)
  1260.       (modify_3dface)
  1261.     )
  1262.     (if (= dialog-state 3)
  1263.       (progn
  1264.         (modify_3dface)
  1265.         (setq pt1 (getpoint (list x1 y1 z1) "\n▓─ 1 ┬I: "))
  1266.         (ver_pt1 0)
  1267.         (dd3dface)
  1268.       )
  1269.     )
  1270.     (if (= dialog-state 4)
  1271.       (progn
  1272.         (modify_3dface)
  1273.         (setq pt2 (getpoint (list x2 y2 z2) "\n▓─ 2 ┬I: "))
  1274.         (ver_pt2 0)
  1275.         (dd3dface)
  1276.       )
  1277.     )
  1278.     (if (= dialog-state 5)
  1279.       (progn
  1280.         (modify_3dface)
  1281.         (setq pt3 (getpoint (list x3 y3 z3) "\n▓─ 3 ┬I: "))
  1282.         (ver_pt3 0)
  1283.         (dd3dface)
  1284.       )
  1285.     )
  1286.     (if (= dialog-state 6)
  1287.       (progn
  1288.         (modify_3dface)
  1289.         (setq pt4 (getpoint (list x4 y4 z4) "\n▓─ 4 ┬I: "))
  1290.         (ver_pt4 0)
  1291.         (dd3dface)
  1292.       )
  1293.     )
  1294.   )
  1295.   ;;
  1296.   ;; Modify BLOCK
  1297.   ;;
  1298.   (defun modify_block ()
  1299.     (modify_properties)
  1300.     (setq pt1 (list x1 y1 z1))
  1301.     (tempmod xscale 41 nil)
  1302.     (tempmod yscale 42 nil)
  1303.     (tempmod zscale 43 nil)
  1304.     (tempmod col-sp 44 nil)
  1305.     (tempmod row-sp 45 nil)
  1306.     (tempmod rot 50 nil)
  1307.     (tempmod columns 70 nil)
  1308.     (tempmod rows 71 nil)
  1309.     (entmod elist)
  1310.     (move_pt1 1)
  1311.     (setq elist (entget ename))
  1312.   )
  1313.  
  1314.   (defun ddblock ()
  1315.     (setq blkname (cdr (assoc 2 elist)))
  1316.     (setq blklist (tblsearch "block" blkname))
  1317.     (setq blktype (cdr (assoc 70 blklist)))
  1318.     (if (= (logand blktype 4) 4)
  1319.       (progn
  1320.         (setq xrefpath (cdr (assoc 1 blklist)))
  1321.         (setq help_entry "ddmodify,Modify_External_Reference")
  1322.         (if (not (new_dialog "ddxref" dcl_id)) (exit))
  1323.         (set_tile "path" xrefpath)
  1324.       )
  1325.       (progn
  1326.         (if (not (new_dialog "ddblock" dcl_id)) (exit))
  1327.         (setq help_entry "ddmodify,Modify_Block_Insertion")
  1328.       )
  1329.     )
  1330.     (set_tile_handle)
  1331.     (set_tile_pt1 1)
  1332.     (set_tile_rot)
  1333.     (set_tile "Bl_name" blkname)
  1334.     (set_tile_scale)
  1335.     (set_tile_rc)
  1336.     (if (= (logand blktype 1) 1)
  1337.       (progn
  1338.         (set_tile "Bl_name" (strcat blkname " - ░╬ªW╣╧╕s"))
  1339.         (mode_tile "xscale" 1)
  1340.         (mode_tile "yscale" 1)
  1341.         (mode_tile "zscale" 1)
  1342.         (mode_tile "rot" 1)
  1343.         (mode_tile "columns" 1)
  1344.         (mode_tile "rows" 1)
  1345.         (mode_tile "col_sp" 1)
  1346.         (mode_tile "row_sp" 1)
  1347.       )
  1348.     )
  1349.     ;; Define action for tiles
  1350.     (set_action_tiles)
  1351.     (setq dialog-state (start_dialog))
  1352.     (cond
  1353.        (  (eq dialog-state 0)
  1354.           (setq pt1 (cdr (assoc 10 old-elist)))
  1355.           (move_pt1 1)
  1356.           (reset))
  1357.        (  (eq dialog-state 1)
  1358.           (modify_block))
  1359.        (  (eq dialog-state 3)
  1360.           (modify_block)
  1361.           (setq pt1 (getpoint (list x1 y1 z1)  "\n┤íñ▐┬I: "))
  1362.           (move_pt1 1)
  1363.           (ddblock))
  1364.     )
  1365.   )
  1366.   ;;
  1367.   ;; Modify SHAPE
  1368.   ;;
  1369.   (defun modify_shape ()
  1370.     (modify_properties)
  1371.     (setq pt1 (list x1 y1 z1))
  1372.     (tempmod pt1 10 1)
  1373.     (tempmod hght 40 nil)
  1374.     (tempmod wid 41 nil)
  1375.     (tempmod rot 50 nil)
  1376.     (tempmod obl 51 nil)
  1377.     (entmod elist)
  1378.   )
  1379.  
  1380.   (defun ddshape ()
  1381.     (if (not (new_dialog "ddshape" dcl_id)) (exit))
  1382.     (set_tile_props)
  1383.     (set_tile_handle)
  1384.     (set_tile_pt1 1)
  1385.     (set_tile_rot)
  1386.     (set_tile_hght)
  1387.     (set_tile_wid)
  1388.     (set_tile_obl)
  1389.     (set_tile "sh_name" (cdr (assoc 2 elist)))
  1390.     ;; Define action for tiles
  1391.     (set_action_tiles)
  1392.     (setq dialog-state (start_dialog))
  1393.     (if (= dialog-state 0)
  1394.       (reset)
  1395.     )
  1396.     (if (= dialog-state 1)
  1397.       (modify_shape)
  1398.     )
  1399.     (if (= dialog-state 3)
  1400.       (progn
  1401.         (modify_shape)
  1402.         (setq pt1 (getpoint (list x1 y1 z1)  "\n┤íñJ┬I: "))
  1403.         (ver_pt1 1)
  1404.         (ddshape)
  1405.       )
  1406.     )
  1407.   )
  1408.   ;;
  1409.   ;; Modify TEXT or ATTDEF
  1410.   ;;
  1411.   ;; Set bit code for upside-down and backwards setting
  1412.   ;;
  1413.   (defun code_71 ()
  1414.     (cond ((and (= bkwd "0") (= upsd "0")) 0)
  1415.           ((and (= bkwd "1") (= upsd "0")) 2)
  1416.           ((and (= bkwd "0") (= upsd "1")) 4)
  1417.           ((and (= bkwd "1") (= upsd "1")) 6)
  1418.     )
  1419.   )
  1420.   ;;
  1421.   ;; Style action.  Reset widget values to style defaults
  1422.   ;;
  1423.   (defun style_act (index / style-list)
  1424.     (setq style-idx (atoi index))
  1425.     (setq tstyle (nth style-idx slist))
  1426.     (setq style-idx (itoa style-idx))
  1427.     (set_tile "style" style-idx)
  1428.     (setq style-list (tblsearch "style" tstyle))
  1429.     (setq shght (cdr (assoc 40 style-list)))
  1430.     (if (/= shght 0)
  1431.       (progn
  1432.         (setq hght shght)
  1433.         (set_tile "hght" (rtos hght))
  1434.       )
  1435.     )
  1436.     (setq wid (cdr (assoc 41 style-list)))
  1437.     (set_tile "wid" (rtos wid))
  1438.     (setq obl (cdr (assoc 50 style-list)))
  1439.     (set_tile "obl" (angtos obl))
  1440.     (setq bk-up (cdr (assoc 71 style-list)))
  1441.     (if (= (logand bk-up 2) 2)
  1442.       (set_tile "bkwd" (itoa (setq bkwd 1)))
  1443.       (set_tile "bkwd" (itoa (setq bkwd 0)))
  1444.     )
  1445.     (if (= (logand bk-up 4) 4)
  1446.       (set_tile "upsd" (itoa (setq upsd 1)))
  1447.       (set_tile "upsd" (itoa (setq upsd 0)))
  1448.     )
  1449.   )
  1450.   ;;
  1451.   ;; Justification action.  Set vertical and horizontal alignment variables,
  1452.   ;; grey out rotation and height if alignment = "aligned", grey out rotation
  1453.   ;; if alignment = "fit".
  1454.   ;;
  1455.   (defun jlist_act (index / templist)
  1456.     (setq just-idx (atoi index))
  1457.     (cond
  1458.       ((= just-idx 0) (setq va 0 ha 0))
  1459.       ((= just-idx 1) (setq va 0 ha 1))
  1460.       ((= just-idx 2) (setq va 0 ha 2))
  1461.       ((= just-idx 3) (setq va 0 ha 3))
  1462.       ((= just-idx 4) (setq va 0 ha 4))
  1463.       ((= just-idx 5) (setq va 0 ha 5))
  1464.       ((= just-idx 6) (setq va 3 ha 0))
  1465.       ((= just-idx 7) (setq va 3 ha 1))
  1466.       ((= just-idx 8) (setq va 3 ha 2))
  1467.       ((= just-idx 9) (setq va 2 ha 0))
  1468.       ((= just-idx 10) (setq va 2 ha 1))
  1469.       ((= just-idx 11) (setq va 2 ha 2))
  1470.       ((= just-idx 12) (setq va 1 ha 0))
  1471.       ((= just-idx 13) (setq va 1 ha 1))
  1472.       ((= just-idx 14) (setq va 1 ha 2))
  1473.     )
  1474.     (if (or (= ha 3) (= ha 5))  ; If Aligned or Fit text
  1475.       (mode_tile "rot" 1)
  1476.       (mode_tile "rot" 0)
  1477.     )
  1478.     (if (= ha 3)                ; If Aligned text
  1479.       (mode_tile "hght" 1)
  1480.       (mode_tile "hght" 0)
  1481.     )
  1482.     (setq just-idx (itoa just-idx))
  1483.   )
  1484.   ;;
  1485.   ;; Set intitial alignment setting based on vertical and horizontal alignment
  1486.   ;; bit codes.
  1487.   ;;
  1488.   (defun set_just_idx ()
  1489.     (cond
  1490.       ((= ha 0)             ; Horiz alignment = Left
  1491.         (cond
  1492.           ((= va 0) (setq just-idx "0"))
  1493.           ((= va 1) (setq just-idx "12"))
  1494.           ((= va 2) (setq just-idx "9"))
  1495.           ((= va 3) (setq just-idx "6"))
  1496.         )
  1497.       )
  1498.       ((= ha 1)             ; Horiz alignment = Center
  1499.         (cond
  1500.           ((= va 0) (setq just-idx "1"))
  1501.           ((= va 1) (setq just-idx "13"))
  1502.           ((= va 2) (setq just-idx "10"))
  1503.           ((= va 3) (setq just-idx "7"))
  1504.         )
  1505.       )
  1506.       ((= ha 2)             ; Horiz alignment = Right
  1507.         (cond
  1508.           ((= va 0) (setq just-idx "2"))
  1509.           ((= va 1) (setq just-idx "14"))
  1510.           ((= va 2) (setq just-idx "11"))
  1511.           ((= va 3) (setq just-idx "8"))
  1512.         )
  1513.       )
  1514.       ((= ha 3) (setq just-idx "3"))   ; Aligned
  1515.       ((= ha 4) (setq just-idx "4"))   ; Middle
  1516.       ((= ha 5) (setq just-idx "5"))   ; Fit
  1517.       (T (setq just-idx "0"))
  1518.     )
  1519.     just-idx
  1520.   )
  1521.  
  1522.   (defun modify_text ()
  1523.     (if (or (and (= ha 0) (= va 0))
  1524.             (= ha 3)
  1525.             (= ha 5)
  1526.         )
  1527.       (progn
  1528.         (setq bit-10 (trans showpt 1 ename))
  1529.         (setq alipt (trans alipt 1 ename))
  1530.         (setq bit-11 (list
  1531.                        (car alipt)
  1532.                        (cadr alipt)
  1533.                        (caddr showpt)
  1534.                      )
  1535.         )
  1536.       )
  1537.       (progn
  1538.         (setq bit-11 (trans showpt 1 ename))
  1539.         (setq bit-10 pt1)
  1540.       )
  1541.     )
  1542.     (modify_properties)
  1543.     (tempmod tstyle 7 nil)
  1544.     (tempmod bit-10 10 nil)
  1545.     (tempmod bit-11 11 nil)
  1546.     (tempmod text 1 nil)
  1547.     (tempmod hght 40 nil)
  1548.     (tempmod wid 41 nil)
  1549.     (tempmod rot 50 nil)
  1550.     (tempmod obl 51 nil)
  1551.     (setq bk-up (+ (* bkwd 2) (* upsd 4)))
  1552.     (tempmod bk-up 71 nil)
  1553.     (tempmod ha 72 nil)
  1554.     (tempmod va 73 nil)
  1555.     (if (= etype "ATTDEF")
  1556.       (progn
  1557.         (tempmod attag 2 nil)
  1558.         (tempmod atprompt 3 nil)
  1559.         (setq icvp (+ inv (* 2 con) (* 4 ver) (* 8 pre)))
  1560.         (tempmod icvp 70 nil)
  1561.       )
  1562.     )
  1563.     (entmod elist)
  1564.   )
  1565.  
  1566.   (defun ddtext (/ 2ndpt slist)
  1567.     (if (= etype "TEXT")
  1568.       (if (not (new_dialog "ddtext" dcl_id)) (exit))
  1569.       (if (not (new_dialog "ddattdef" dcl_id)) (exit))
  1570.     )
  1571.     (set_tile_props)
  1572.     (set_tile_handle)
  1573.     (set_tile_text)
  1574.     (set_tile_tag)
  1575.     (set_tile_prompt)
  1576.     (set_tile_hght)
  1577.     (set_tile_wid)
  1578.     (set_tile_rot)
  1579.     (set_tile_obl)
  1580.     (set_tile_bk-up)
  1581.     (set_tile_icvp)
  1582.     (set_tile_style)
  1583.     (set_tile_just)
  1584.     (setq pt1 (trans (cdr (assoc 10 elist)) ename 1))
  1585.     (setq pt2 (trans (cdr (assoc 11 elist)) ename 1))
  1586.     (if (or (and (= ha 0) (= va 0))
  1587.                  (= ha 3)
  1588.                  (= ha 5)
  1589.         )
  1590.       (setq showpt pt1 alipt pt2)
  1591.       (setq showpt pt2 alipt '(0.0 0.0 0.0))
  1592.     )
  1593.  
  1594.     (set_tile "x1_pt" (rtos (setq x1 (car showpt))))
  1595.     (set_tile "y1_pt" (rtos (setq y1 (cadr showpt))))
  1596.     (set_tile "z1_pt" (rtos (setq z1 (caddr showpt))))
  1597.  
  1598.     ;; Define action for tiles
  1599.     (set_action_tiles)
  1600.     ;; Set focus initially to the text edit box.
  1601.     (if (not i) (progn (mode_tile "t_string" 2)(setq i 1)))
  1602.     (setq dialog-state (start_dialog))
  1603.     (if (= dialog-state 0)
  1604.       (reset)
  1605.     )
  1606.     (if (= dialog-state 1)
  1607.       (modify_text)
  1608.     )
  1609.     (if (= dialog-state 3)
  1610.       (progn
  1611.         (modify_text)
  1612.         (if (or (= ha 3) (= ha 5))
  1613.           (progn
  1614.             (setq showpt (getpoint (list x1 y1 z1) "\n▓─ 1 ┬I: "))
  1615.             (if (not showpt)
  1616.               (setq showpt (list x1 y1 z1))
  1617.             )
  1618.             (setq 2ndpt (getpoint showpt "\n▓─ 2 ┬I: "))
  1619.             (if 2ndpt
  1620.               (progn
  1621.                 (setq alipt 2ndpt)
  1622.                 (tempmod showpt 10 1)
  1623.                 (tempmod alipt 11 1)
  1624.                 (entmod elist)
  1625.               )
  1626.             )
  1627.             (setq elist (entget ename))
  1628.           )
  1629.           (progn
  1630.             (setq showpt (getpoint (list x1 y1 z1) "\n┤íñJ┬I: "))
  1631.             (if showpt
  1632.               (progn
  1633.                 (if (and (= ha 0) (= va 0))
  1634.                   (tempmod showpt 10 1)
  1635.                   (tempmod showpt 11 1)
  1636.                 )
  1637.                 (entmod elist)
  1638.               )
  1639.               (setq showpt (list x1 y1 z1))
  1640.             )
  1641.           )
  1642.         )
  1643.         (ddtext)
  1644.       )
  1645.     )
  1646.   )
  1647.   ;;
  1648.   ;; Modify VIEWPORT
  1649.   ;;
  1650.  
  1651.   (defun ddvport ()
  1652.     (if (not (new_dialog "ddvport" dcl_id)) (exit))
  1653.     (set_tile_props)
  1654.     (set_tile_handle)
  1655.     (setq vpt (cdr (assoc 10 elist)))
  1656.     (set_tile "xtext" (rtos (setq x1 (car vpt))))
  1657.     (set_tile "ytext" (rtos (setq y1 (cadr vpt))))
  1658.     (set_tile "ztext" (rtos (setq z1 (caddr vpt))))
  1659.     (setq wid (cdr (assoc 40 elist)))
  1660.     (set_tile "wid" (rtos wid))
  1661.     (setq hght (cdr (assoc 41 elist)))
  1662.     (set_tile "hght" (rtos hght))
  1663.     (setq vpid (cdr (assoc 69 elist)))
  1664.     (set_tile "vpid" (itoa vpid))
  1665.     (setq on-off (cdr (assoc 68 elist)))
  1666.     (cond
  1667.       ((= on-off 0) (set_tile "on-off" "OFF"))
  1668.       ((> on-off 0) (set_tile "on-off" "ON ÑBíuº@Ñ╬ív"))
  1669.       (T (set_tile "on-off" "ON and Inactive"))
  1670.     )
  1671.  
  1672.     ;; Define action for tiles
  1673.     (set_action_tiles)
  1674.  
  1675.     (setq dialog-state (start_dialog))
  1676.     (if (= dialog-state 0)
  1677.       (reset)
  1678.     )
  1679.     (if (= dialog-state 1)
  1680.       (progn
  1681.         (if (= ecolor 0) (setq ecolor "byblock"))
  1682.         (if (= ecolor 256) (setq ecolor "bylayer"))
  1683.         (command "_.chprop" ename ""
  1684.                  "_la" elayer
  1685.                  "_c" ecolor ""
  1686.         )
  1687.       )
  1688.     )
  1689.   )
  1690.   ;;
  1691.   ;; Modify POLYLINE
  1692.   ;;
  1693.   (defun modify_polyline ()
  1694.     (modify_properties)
  1695.     (if (= ltgen "1")
  1696.       (if (/= (logand bit70 128) 128)
  1697.         (setq bit70 (+ bit70 128))
  1698.       )
  1699.     )
  1700.     (if (= ltgen "0")
  1701.       (if (= (logand bit70 128) 128)
  1702.         (setq bit70 (- bit70 128))
  1703.       )
  1704.     )
  1705.     (setq elist (subst (cons 70 bit70) (assoc 70 elist) elist))
  1706.     (entmod elist)
  1707.   )
  1708.  
  1709.   ;; Increment vertex.  Set tile values to next vertex
  1710.   ;;
  1711.   (defun next_vertex ()
  1712.     (setq vname (entnext vname))
  1713.     (setq vlist (entget vname))
  1714.     (if (= (cdr (assoc 0 vlist)) "VERTEX")
  1715.       (progn
  1716.         (set_tile "ctr" (itoa (setq ctr (+ 1 ctr))))
  1717.         (set_tile_vpt pointype)
  1718.       )
  1719.       (progn
  1720.         (setq vname (entnext ename))
  1721.         (setq vlist (entget vname))
  1722.         (set_tile_vpt pointype)
  1723.         (set_tile "ctr" (itoa (setq ctr 1)))
  1724.       )
  1725.     )
  1726.   )
  1727.  
  1728.   (defun ddpline ()
  1729.     (if (not (new_dialog "ddpline" dcl_id)) (exit))
  1730.     (set_tile_props)
  1731.     (set_tile_handle)
  1732.     (setq bit70 (cdr (assoc 70 elist)))
  1733.     (setq bit75 (cdr (assoc 75 elist)))
  1734.     (cond
  1735.       ((= (logand bit70 8) 8)   ; 3DPOLY
  1736.         (set_tile "ptype" (setq pltype"3D polyline"))
  1737.         (setq pointype 0)       ; WCS or ECS point values
  1738.         (mode_tile "fit" 1)
  1739.         (mode_tile "mesh" 1)
  1740.         (mode_tile "bezier" 1)
  1741.         (mode_tile "ltgen" 1)
  1742.         (set_tile "none" "1")
  1743.         (set_tile_closed)
  1744.         (set_tile_fitsmooth)
  1745.       )
  1746.       ((= (logand bit70 16) 16) ; 3DMESH
  1747.         (set_tile "ptype" (setq pltype"3D mesh"))
  1748.         (setq pointype 0)
  1749.         (mode_tile "pline" 1)
  1750.         (mode_tile "fit" 1)
  1751.         (mode_tile "ltgen" 1)
  1752.         (setq m (1- (cdr (assoc 71 elist))))
  1753.         (setq n (1-(cdr (assoc 72 elist))))
  1754.         (setq u (1- (cdr (assoc 73 elist))))
  1755.         (if (< u 0) (setq u 0))
  1756.         (setq v (1- (cdr (assoc 74 elist))))
  1757.         (if (< v 0) (setq v 0))
  1758.         (set_tile "m" (itoa m))
  1759.         (set_tile "n" (itoa n))
  1760.         (set_tile "u" (itoa u))
  1761.         (set_tile "v" (itoa v))
  1762.         (set_tile_closed)
  1763.         (set_tile_fitsmooth)
  1764.       )
  1765.       ((= (logand bit70 64) 64) ; POLYFACE MESH
  1766.         (set_tile "ptype" (setq pltype "Polyface mesh"))
  1767.         (setq pointype 0)
  1768.         (mode_tile "f-s" 1)
  1769.         (mode_tile "mesh" 1)
  1770.         (mode_tile "pline" 1)
  1771.       )
  1772.       (T                        ; 2D POLYLINE
  1773.         (set_tile "ptype" (setq pltype "2D polyline"))
  1774.         (setq pointype 1)
  1775.         (mode_tile "bezier" 1)
  1776.         (mode_tile "mesh" 1)
  1777.         (if (= (logand bit70 128) 128)
  1778.           (set_tile "ltgen" (setq ltgen "1"))
  1779.         )
  1780.         (set_tile_closed)
  1781.         (set_tile_fitsmooth)
  1782.       )
  1783.     )
  1784.     (if (not next) (setq vname (entnext ename)))
  1785.     (setq next T)
  1786.     (set_tile "ctr" (itoa (setq ctr 1)))
  1787.     (setq vlist (entget vname))
  1788.     (set_tile_vpt pointype)
  1789.     ;; Define action for tiles
  1790.     (set_action_tiles)
  1791.     (setq dialog-state (start_dialog))
  1792.  
  1793.     (if (= dialog-state 0)
  1794.       (reset)
  1795.     )
  1796.     (if (= dialog-state 1)
  1797.       (progn
  1798.         (modify_polyline)
  1799.         (if (or (= pltype "2D polyline")
  1800.                 (= pltype "3D polyline")
  1801.             )
  1802.           (progn
  1803.             (command "_.pedit" ename)
  1804.             (if (= spltype 0) (command "_d"))
  1805.             (if (= spltype 1) (command "_f"))
  1806.             (if (or (= spltype 5)
  1807.                     (= spltype 6)
  1808.                     (= spltype 8)
  1809.                 )
  1810.               (progn
  1811.                 (setvar "splinetype" spltype)
  1812.                 (command "_s")
  1813.               )
  1814.             )
  1815.             (if (= closed "0")
  1816.               (command "_o")
  1817.               (command "_c")
  1818.             )
  1819.             (command "")
  1820.           )
  1821.         )
  1822.         (if (= pltype "3D mesh")
  1823.           (progn
  1824.             (command "_.pedit" ename)
  1825.             (if (= spltype 0) (command "_d"))
  1826.             (if (or (= spltype 5)
  1827.                     (= spltype 6)
  1828.                     (= spltype 8)
  1829.                 )
  1830.               (progn
  1831.                 (setvar "splinetype" spltype)
  1832.                 (setvar "surfu" u)
  1833.                 (setvar "surfv" v)
  1834.                 (command "_s")
  1835.               )
  1836.             )
  1837.             (if (/= closedm old-closedm)
  1838.               (command "_m")
  1839.             )
  1840.             (if (/= closedn old-closedn)
  1841.               (command "_n")
  1842.             )
  1843.             (command "")
  1844.           )
  1845.         )
  1846.       )
  1847.     )
  1848.   )
  1849.   ;;
  1850.   ;; Modify DIMENSION
  1851.   ;;
  1852.   (defun ddimen (/ dtypebit blkname bename sublist a)
  1853.     (if (not (new_dialog "ddimen" dcl_id)) (exit))
  1854.     (set_tile_props)
  1855.     (set_tile_handle)
  1856.     (set_tile "dstyle" (cdr (assoc 3 elist)))
  1857.     (setq dtypebit (cdr (assoc 70 elist)))
  1858.  
  1859.     ;; (logand) for bits, but these aren't really bits...
  1860.     (if (<= 128 dtypebit) (setq dtypebit (- dtypebit 128)))
  1861.     (cond
  1862.       ((= dtypebit 0) (set_tile "dtype" "Linear"))
  1863.       ((= dtypebit 1) (set_tile "dtype" "Linear"))
  1864.       ((= dtypebit 2) (set_tile "dtype" "Angular"))
  1865.       ((= dtypebit 3) (set_tile "dtype" "Diameter"))
  1866.       ((= dtypebit 4) (set_tile "dtype" "Radius"))
  1867.       ((= dtypebit 5) (set_tile "dtype" "Angular"))
  1868.       ((= dtypebit 6) (set_tile "dtype" "Y Ordinate"))
  1869.       ((= dtypebit 70)(set_tile "dtype" "X Ordinate"))
  1870.       (T (set_tile "dtype" " "))
  1871.     )
  1872.     (setq blkname (cdr (assoc 2 elist)))
  1873.     (setq blklist (tblsearch "block" blkname))
  1874.     (setq dimtext (cdr (assoc 1 elist)))
  1875.     (if (= " " dimtext) (setq dimtext "Suppressed"))
  1876.     (if (= "" dimtext) (setq dimtext "Default Text"))
  1877.  
  1878.     (if (> (strlen dimtext) 14)
  1879.       (setq dimtext (strcat (substr dimtext 1 14) "~"))
  1880.     )
  1881.  
  1882.     (set_tile "dtext" dimtext)
  1883.  
  1884.     ;; Define action for tiles
  1885.     (set_action_tiles)
  1886.     (setq dialog-state (start_dialog))
  1887.     (if (= dialog-state 0)
  1888.       (reset)
  1889.     )
  1890.     (if (= dialog-state 1)
  1891.       (progn
  1892.         (modify_properties)
  1893.         (entmod elist)
  1894.       )
  1895.     )
  1896.   )
  1897.  
  1898.   ;;
  1899.   ;; Sub-dialogues for properties.  Common to all entity dialogues
  1900.   ;;
  1901.   ;; This function pops a dialogue box consisting of a list box,image tile, and
  1902.   ;; edit box to allow the user to select or type a color number.  It returns
  1903.   ;; the color number selected.
  1904.   (defun getcolor (/ old-idx colorno cname)
  1905.     (if (= (get_tile "error") "")
  1906.       (if (numberp (setq temp_color (acad_colordlg ecolor t)))
  1907.         (progn
  1908.           (setq ecolor temp_color)
  1909.           (setcolor)
  1910.         )
  1911.         (setq testcolor temp_color)
  1912.       )
  1913.     )
  1914.     ecolor
  1915.   )
  1916.   ;;
  1917.   ;; Function to set the color tiles.
  1918.   (defun setcolor()
  1919.     (cond
  1920.       ((= 0 ecolor)
  1921.         (set_tile "t_color" "BYBLOCK")
  1922.         (col_tile "show_image" 0 nil)
  1923.       )
  1924.       ((= 1 ecolor)
  1925.         (set_tile "t_color" "1 red")
  1926.         (col_tile "show_image" 1 nil)
  1927.       )
  1928.       ((= 2 ecolor)
  1929.         (set_tile "t_color" "2 yellow")
  1930.         (col_tile "show_image" 2 nil)
  1931.       )
  1932.       ((= 3 ecolor)
  1933.         (set_tile "t_color" "3 green")
  1934.         (col_tile "show_image" 3 nil)
  1935.       )
  1936.       ((= 4 ecolor)
  1937.         (set_tile "t_color" "4 cyan")
  1938.         (col_tile "show_image" 4 nil)
  1939.       )
  1940.       ((= 5 ecolor)
  1941.         (set_tile "t_color" "5 blue")
  1942.         (col_tile "show_image" 5 nil)
  1943.       )
  1944.       ((= 6 ecolor)
  1945.         (set_tile "t_color" "6 magenta")
  1946.         (col_tile "show_image" 6 nil)
  1947.       )
  1948.       ((= 7 ecolor)
  1949.         (set_tile "t_color" "7 white")
  1950.         (col_tile "show_image" 7 nil)
  1951.       )
  1952.       ((= 256 ecolor)
  1953.         (set_tile "t_color" "BYLAYER")
  1954.         (col_tile "show_image" (bylayer_col) nil)
  1955.       )
  1956.       (T
  1957.         (set_tile "t_color" (itoa ecolor))
  1958.         (col_tile "show_image" ecolor nil)
  1959.       )
  1960.     )
  1961.   )
  1962.   ;;
  1963.   ;; This function pops a dialogue box consisting of a list box, image tile, and
  1964.   ;; edit box to allow the user to select or  type a linetype.  It returns the
  1965.   ;; linetype selected.
  1966.   ;;
  1967.   (defun getltype (/ old-idx ltname)
  1968.     (if (= (get_tile "error") "")
  1969.      (progn
  1970.       (if (not (new_dialog "setltype" dcl_id)) (exit))
  1971.       (start_list "list_lt")
  1972.       (mapcar 'add_list ltnmlst)  ; initialize list box
  1973.       (end_list)
  1974.       (setq old-idx lt-idx)
  1975.       (ltlist_act (itoa lt-idx))
  1976.  
  1977.       (action_tile "list_lt" "(ltlist_act $value)")
  1978.       (action_tile "edit_lt" "(ltedit_act $value)")
  1979.       (action_tile "accept" "(test_ok)")
  1980.       (action_tile "cancel" "(reset_lt)")
  1981.  
  1982.       (if (= (start_dialog) 1) ; User pressed OK
  1983.         (cond
  1984.           ((= lt-idx 0)
  1985.             (set_tile "t_ltype" (bylayer_lt))
  1986.             "BYLAYER"
  1987.           )
  1988.           ((= lt-idx 1)
  1989.             (set_tile "t_ltype" "BYBLOCK")
  1990.             "BYBLOCK"
  1991.           )
  1992.           (T  (set_tile "t_ltype" ltname) ltname)
  1993.         )
  1994.         eltype
  1995.       )
  1996.      )
  1997.      eltype
  1998.     )
  1999.   )
  2000.   ;;
  2001.   ;; Edit box entries end up here
  2002.   (defun ltedit_act (ltvalue)
  2003.     (setq ltvalue (strcase ltvalue))
  2004.     (if (or (= ltvalue "BYLAYER") (= ltvalue "BY LAYER"))
  2005.       (setq ltvalue "BYLAYER")
  2006.     )
  2007.     (if (or (= ltvalue "BYBLOCK") (= ltvalue "BY BLOCK"))
  2008.       (setq ltvalue "BYBLOCK")
  2009.     )
  2010.     (if (setq lt-idx (getindex ltvalue ltnmlst))
  2011.       (progn
  2012.         (set_tile "error" "")
  2013.         (ltlist_act (itoa lt-idx))
  2014.         (mode_tile "list_lt" 2)
  2015.       )
  2016.       (progn
  2017.         (set_tile "error" "íu╜u½¼ív╡L«─íC")
  2018.         (setq lt-idx old-idx)
  2019.         (mode_tile "edit_lt" 2)
  2020.       )
  2021.     )
  2022.   )
  2023.   ;;
  2024.   ;; List selections end up here.  Update the list box, edit box, and color
  2025.   ;; tile.
  2026.   ;;
  2027.   (defun ltlist_act (index / dashdata)
  2028.     (set_tile "error" "")
  2029.     (setq lt-idx (atoi index))
  2030.     (setq ltname (nth lt-idx ltnmlst))
  2031.     (setq dashdata (nth lt-idx mdashlist))
  2032.     (col_tile "show_image" 0 dashdata)
  2033.     (set_tile "list_lt" (itoa lt-idx))
  2034.     (set_tile "edit_lt" ltname)
  2035.   )
  2036.   ;;
  2037.   ;; Reset to original linetype when cancel it selected
  2038.   ;;
  2039.   (defun reset_lt ()
  2040.     (setq lt-idx old-idx)
  2041.     (done_dialog 0)
  2042.   )
  2043.   ;;
  2044.   ;; This function pops a dialogue box consisting of a list box,image tile, and
  2045.   ;; edit box to allow the user to select or type a layer name.  It returns the
  2046.   ;; layer name selected.  It also has a button to find the status (On, Off,
  2047.   ;; Frozen, etc.) of any layer selected.
  2048.   ;;
  2049.   (defun getlayer (/ old-idx layname on off frozth linetype)
  2050.     (if (= (get_tile "error") "")
  2051.      (progn
  2052.       (if (not (new_dialog "setlayer" dcl_id)) (exit))
  2053.       (set_tile "cur_layer" (getvar "clayer"))
  2054.       (start_list "list_lay")
  2055.       (mapcar 'add_list longlist)  ; initialize list box
  2056.       (end_list)
  2057.       (setq old-idx lay-idx)
  2058.       (laylist_act (itoa lay-idx))
  2059.       (action_tile "list_lay" "(laylist_act $value)")
  2060.       (action_tile "edit_lay" "(layedit_act $value)")
  2061.       (action_tile "accept" "(test_ok)")
  2062.       (action_tile "cancel" "(reset_lay)")
  2063.       (if (= (start_dialog) 1) ; User pressed OK
  2064.         (progn
  2065.           (set_tile "t_layer" layname)
  2066.           ;; If layer equals bylayer reset color tile
  2067.           (if (= ecolor 256)
  2068.             (col_tile "show_image" (bylayer_col) nil)
  2069.           )
  2070.           layname
  2071.         )
  2072.         elayer
  2073.       )
  2074.      )
  2075.      elayer
  2076.     )
  2077.   )
  2078.   ;;
  2079.   ;; Edit box selections end up here.  Convert layer entry to upper case.  If
  2080.   ;; layer name is valid, clear error string, call (laylist_act) function,
  2081.   ;; and change focus to list box.  Else print error message.
  2082.   ;;
  2083.   (defun layedit_act (layvalue)
  2084.     (setq layvalue (strcase layvalue))
  2085.     (if (setq lay-idx (getindex layvalue laynmlst))
  2086.       (progn
  2087.         (set_tile "error" "")
  2088.         (laylist_act (itoa lay-idx))
  2089.       )
  2090.       (progn
  2091.         (set_tile "error" "íu╝hªWív╡L«─íC")
  2092.         (mode_tile "edit_lay" 2)
  2093.         (setq lay-idx old-idx)
  2094.       )
  2095.     )
  2096.   )
  2097.   ;;
  2098.   ;; List entry selections end up here.
  2099.   ;;
  2100.   (defun laylist_act (index / layinfo color dashdata)
  2101.     ;; Update the list box, edit box, and color tile.
  2102.     (set_tile "error" "")
  2103.     (setq lay-idx (atoi index))
  2104.     (setq layname (nth lay-idx laynmlst))
  2105.     (setq layinfo (tblsearch "layer" layname))
  2106.     (if (= (logand (cdr (assoc 70 layinfo)) 4) 4)
  2107.       (set_tile "error" "╡L¬k▒N╣╧ñ╕┼▄º≤ª▄íu┬Ω┼@ív¬║╣╧╝hñWíC")
  2108.       (progn
  2109.         (setq color (cdr (assoc 62 layinfo)))
  2110.         (setq color (abs color))
  2111.         (setq colname (colorname color))
  2112.         (set_tile "list_lay" (itoa lay-idx))
  2113.         (set_tile "edit_lay" layname)
  2114.         (mode_tile "list_lay" 2)
  2115.       )
  2116.     )
  2117.   )
  2118.   ;;
  2119.   ;; Reset to original layer when cancel is selected.
  2120.   ;;
  2121.   (defun reset_lay ()
  2122.     (setq lay-idx old-idx)
  2123.     (done_dialog 0)
  2124.   )
  2125.   ;;
  2126.   ;; Checks validity of thickness from edit box.
  2127.   (defun getthickness (value)
  2128.     (setq ethickness (verify_d "eb_thickness" value ethickness))
  2129.   )
  2130.   ;;
  2131.   ;; This function makes a list called laynmlst which consists of all the layer
  2132.   ;; names in the drawing.  It also creates a list called longlist which
  2133.   ;; consists of strings which contain the layer name, color, linetype, etc.
  2134.   ;; Longlist is later mapped into the layer listbox.  Both are ordered the
  2135.   ;; same.
  2136.   ;;
  2137.   (defun make_lay_lists (/ layname onoff frozth color linetype vpf vpn ss
  2138.                            cvpname xdlist vpldata sortlist name templist
  2139.                            bit-70
  2140.                         )
  2141.     (if (= (setq tilemode (getvar "tilemode")) 0)
  2142.       (progn
  2143.         (setq ss (ssget "x" (list (cons 0 "VIEWPORT")
  2144.                                   (cons 69 (getvar "CVPORT"))
  2145.                             )
  2146.                  )
  2147.         )
  2148.         (setq cvpname (ssname ss 0))
  2149.         (setq xdlist (assoc -3 (entget cvpname '("acad"))))
  2150.         (setq vpldata (cdadr xdlist))
  2151.       )
  2152.     )
  2153.     (setq sortlist nil)
  2154.     (setq templist (tblnext "LAYER" T))
  2155.     (while templist
  2156.       (setq name (cdr (assoc 2 templist)))
  2157.       (setq sortlist (cons name sortlist))
  2158.       (setq templist (tblnext "LAYER"))
  2159.     )
  2160.     (if (>= (getvar "maxsort") (length sortlist))
  2161.       (setq sortlist (acad_strlsort sortlist))
  2162.       (setq sortlist (reverse sortlist))
  2163.     )
  2164.     (setq laynmlst sortlist)
  2165.     (setq longlist nil)
  2166.     (setq layname (car sortlist))
  2167.     (while layname
  2168.       (setq laylist (tblsearch "LAYER" layname))
  2169.       (setq color (cdr (assoc 62 laylist)))
  2170.       (if (minusp color)
  2171.         (setq onoff ".")
  2172.         (setq onoff "On")
  2173.       )
  2174.       (setq color (abs color))
  2175.       (setq colname (colorname color))
  2176.       (setq bit-70 (cdr (assoc 70 laylist)))
  2177.       (if (= (logand bit-70 1) 1)
  2178.         (setq frozth "F")
  2179.         (setq frozth ".")
  2180.       )
  2181.       (if (= (logand bit-70 2) 2)
  2182.         (setq vpn "N")
  2183.         (setq vpn ".")
  2184.       )
  2185.       (if (= (logand bit-70 4) 4)
  2186.         (setq lock "L")
  2187.         (setq lock ".")
  2188.       )
  2189.       (setq linetype (cdr (assoc 6 laylist)))
  2190.       (setq layname (substr layname 1 31))
  2191.       (if (= tilemode 0)
  2192.         (progn
  2193.           (if (member (cons 1003 layname) vpldata)
  2194.             (setq vpf "C")
  2195.             (setq vpf ".")
  2196.           )
  2197.         )
  2198.         (setq vpf ".")
  2199.       )
  2200.       (setq ltabstr (strcat layname "\t"
  2201.                               onoff "\t"
  2202.                              frozth "\t"
  2203.                                lock "\t"
  2204.                                 vpf "\t"
  2205.                                 vpn "\t"
  2206.                             colname "\t"
  2207.                            linetype
  2208.                     )
  2209.       )
  2210.       (setq longlist (append longlist (list ltabstr)))
  2211.       (setq sortlist (cdr sortlist))
  2212.       (setq layname (car sortlist))
  2213.     )
  2214.   )
  2215.   ;;
  2216.   ;; This function makes 2 list - ltnmlst & mdashlist.
  2217.   ;; Ltnmlst is a list of linetype names read from the symbol table.  Mdashlist
  2218.   ;; is list consisting of lists which define the linetype pattern - numbers
  2219.   ;; that indicate dots, dashes, and spaces taken from group code 49.  The list
  2220.   ;; corresponds to the order of names in ltnmlst.
  2221.   ;;
  2222.   (defun make_lt_lists (/ ltlist ltname)
  2223.     (setq mdashlist nil)
  2224.     (setq ltlist (tblnext "LTYPE" T))
  2225.     (setq ltname (cdr (assoc 2 ltlist)))
  2226.     (setq ltnmlst (list ltname))
  2227.     (if (= ltname "CONTINUOUS")
  2228.       (setq mdashlist (list "CONT"))
  2229.       (setq mdashlist
  2230.             (append mdashlist (list (add_mdash ltlist)))
  2231.       )
  2232.     )
  2233.     (while (setq ltlist (tblnext "LTYPE"))
  2234.       (setq ltname (cdr (assoc 2 ltlist)))
  2235.       (setq ltnmlst (append ltnmlst (list ltname)))
  2236.       (setq mdashlist
  2237.             (append mdashlist (list (add_mdash ltlist)))
  2238.       )
  2239.     )
  2240.     (setq ltnmlst (cons "BYBLOCK" ltnmlst))
  2241.     (setq mdashlist  (cons nil mdashlist))
  2242.     (setq ltnmlst (cons "BYLAYER" ltnmlst))
  2243.     (setq mdashlist  (cons nil mdashlist))
  2244.   )
  2245.   ;;
  2246.   ;; Get all the group code 49 values for a linetype and put them in a list
  2247.   ;; (pen-up, pen-down info).
  2248.   ;;
  2249.   (defun add_mdash (ltlist1 / dashlist assoclist dashsize)
  2250.     (setq dashlist nil)
  2251.     (while (setq assoclist (car ltlist1))
  2252.       (if (= (car assoclist) 49)
  2253.         (progn
  2254.           (setq dashsize (cdr assoclist))
  2255.           (setq dashlist (cons dashsize dashlist))
  2256.         )
  2257.       )
  2258.       (setq ltlist1 (cdr ltlist1))
  2259.     )
  2260.     (setq dashlist (reverse dashlist))
  2261.   )
  2262.   ;;
  2263.   ;; Color a tile, draw linetype, and draw a border around it
  2264.   ;;
  2265.   (defun col_tile (tile color patlist / x y)
  2266.     (setq x (dimx_tile tile))
  2267.     (setq y (dimy_tile tile))
  2268.     (start_image tile)
  2269.     (fill_image 0 0 x y color)
  2270.     (if (= color 7)
  2271.       (progn
  2272.         (if patlist (drawpattern x (/ y 2) patlist 0))
  2273.         (tile_rect 0 0 x y 0)
  2274.       )
  2275.       (progn
  2276.         (if patlist (drawpattern x (/ y 2) patlist 7))
  2277.         (tile_rect 0 0 x y 7)
  2278.       )
  2279.     )
  2280.     (end_image)
  2281.   )
  2282.   ;;
  2283.   ;; Draw a border around a tile
  2284.   ;;
  2285.   (defun tile_rect (x1 y1 x2 y2 color)
  2286.     (setq x2 (- x2 1))
  2287.     (setq y2 (- y2 1))
  2288.     (vector_image x1 y1 x2 y1 color)
  2289.     (vector_image x2 y1 x2 y2 color)
  2290.     (vector_image x2 y2 x1 y2 color)
  2291.     (vector_image x1 y2 x1 y1 color)
  2292.   )
  2293.   ;;
  2294.   ;; Draw the linetype pattern in a tile.  Boxlength is the length of the image
  2295.   ;; tile, y2 is the midpoint of the height of the image tile, pattern is a
  2296.   ;; list of numbers that define the linetype, and color is the color of the
  2297.   ;; tile.
  2298.   ;;
  2299.   (defun drawpattern (boxlength y2 pattern color / x1 x2
  2300.                       patlist dash)
  2301.     (setq x1 0 x2 0)
  2302.     (setq patlist pattern)
  2303.     (if (= patlist "CONT")
  2304.       (progn (setq dash boxlength)
  2305.         (vi)
  2306.         (setq x1 boxlength)
  2307.       )
  2308.     )
  2309.     (while (< x1 boxlength)
  2310.       (if (setq dash (car patlist))
  2311.         (progn
  2312.           (setq dash (fix (* 30 dash)))
  2313.           (cond
  2314.             ((= dash 0) (setq dash 1) (vi))
  2315.             ((> dash 0) (vi))
  2316.             (T
  2317.               (if (< (abs dash) 2)
  2318.                (setq dash 2)
  2319.               )
  2320.               (setq x2 (+ x2 (abs dash)))
  2321.             )
  2322.           )
  2323.           (setq patlist (cdr patlist))
  2324.           (setq x1 x2)
  2325.         )
  2326.         (setq patlist pattern)
  2327.       )
  2328.     )
  2329.   )
  2330.   ;;
  2331.   ;; Draw a dash or dot in image tile
  2332.   ;;
  2333.   (defun vi ()
  2334.     (setq x2 (+ x2 dash))
  2335.     (vector_image x1 y2 x2 y2 color)
  2336.   )
  2337.   ;;
  2338.   ;; If an item is a member of the list, then return its index number, else
  2339.   ;; return nil.
  2340.   ;;
  2341.   (defun getindex (item itemlist / m n)
  2342.     (setq n (length itemlist))
  2343.     (if (> (setq m (length (member item itemlist))) 0)
  2344.       (- n m)
  2345.       nil
  2346.     )
  2347.   )
  2348.   ;;
  2349.   ;; This function is called if the linetype is set "BYLAYER". It finds the
  2350.   ;; ltype of the layer so it can be displayed  beside the linetype button.
  2351.   ;;
  2352.   (defun bylayer_lt (/ layname layinfo ltype)
  2353.     (if lay-idx
  2354.       (progn
  2355.         (setq layname (nth lay-idx laynmlst))
  2356.         (setq layinfo (tblsearch "layer" layname))
  2357.         (setq ltype (cdr (assoc 6 layinfo)))
  2358.         "BYLAYER"
  2359.       )
  2360.       "BYLAYER"
  2361.     )
  2362.   )
  2363.   ;;
  2364.   ;; This function is called if the color is set "BYLAYER".  It finds the color
  2365.   ;; of the layer so it can be displayed beside the color button.
  2366.   ;;
  2367.   (defun bylayer_col (/ layname layinfo color)
  2368.     (if lay-idx
  2369.       (progn
  2370.         (setq layname (nth lay-idx laynmlst))
  2371.         (setq layinfo (tblsearch "layer" layname))
  2372.         (setq color (abs (cdr (assoc 62 layinfo))))
  2373.       )
  2374.       0
  2375.     )
  2376.   )
  2377.   ;;
  2378.   ;; Used to set the color name in layer subdialogue.
  2379.   ;;
  2380.   (defun colorname (colnum / cn)
  2381.     (setq cn (abs colnum))
  2382.     (cond ((= cn 1) "red")
  2383.           ((= cn 2) "yellow")
  2384.           ((= cn 3) "green")
  2385.           ((= cn 4) "cyan")
  2386.           ((= cn 5) "blue")
  2387.           ((= cn 6) "magenta")
  2388.           ((= cn 7) "white")
  2389.           (T (itoa cn))
  2390.     )
  2391.   )
  2392.   ;;
  2393.   ;; If their is no error message, then close the dialogue.
  2394.   ;;
  2395.   (defun dismiss_dialog (action)
  2396.     (if (= action 0)
  2397.       (done_dialog 0)
  2398.       (if (= (get_tile "error") "")
  2399.         (done_dialog action)
  2400.       )
  2401.     )
  2402.   )
  2403.  
  2404.   (defun test_ok ()
  2405.     (if (= (get_tile "error") "")
  2406.       (done_dialog 1)
  2407.     )
  2408.   )
  2409.  
  2410.   (defun cancel ()
  2411.     (done_dialog 0)
  2412.   )
  2413.  
  2414. ;;; =======================================================================
  2415. ;;; SETUP layer and linetype lists for application, and initialize all
  2416. ;;; program variables.
  2417.  
  2418.   (make_lay_lists)                   ; layer list - laynmlst
  2419.   (make_lt_lists)                    ; linetype lists - ltnmlst, mdashlist
  2420.   (setq elist       (entget ename)
  2421.         old-elist   elist
  2422.         modlist     elist
  2423.         etype       (cdr (assoc 0 elist))
  2424.         extru       (cdr (assoc 210 elist))
  2425.         ecolor      (cdr (assoc 62 elist))
  2426.         elayer      (cdr (assoc 8 elist))
  2427.         ethickness  (cdr (assoc 39 elist))
  2428.         eltype      (cdr (assoc 6 elist))
  2429.   )
  2430.   (if (not ecolor) (setq ecolor 256))
  2431.   (if (not eltype) (setq eltype "BYLAYER"))
  2432.   (if (not ethickness) (setq ethickness 0))
  2433.  
  2434.   ;; Find index of linetype and layer lists
  2435.  
  2436.   (cond
  2437.      (  (= eltype "BYLAYER")
  2438.         (setq lt-idx (getindex "BYLAYER" ltnmlst)))
  2439.      (  (= eltype "BYBLOCK")
  2440.         (setq lt-idx (getindex "BYBLOCK" ltnmlst)))
  2441.      (t (setq lt-idx (getindex eltype ltnmlst)))
  2442.   )
  2443.  
  2444.   (setq lay-idx (getindex elayer laynmlst))
  2445. ) ; end ddmodify_init
  2446.  
  2447. ;;; --------------------------------------------------------------------------
  2448. ;;; Function: DDMODIFY_SELECT
  2449. ;;;
  2450. ;;; Entity aquisition function.
  2451. ;;;
  2452. ;;; (ddmodify_select)
  2453. ;;;
  2454. ;;; Obtains entity to be modified, in one of three ways:
  2455. ;;;
  2456. ;;;   1 - Autoselected.
  2457. ;;;   2 - Prompted for.
  2458. ;;;   3 - Passed as an argument in a call to (ddmodify <ename> )
  2459. ;;;
  2460. ;;; The (ddmodify_select) function also sets the value of the
  2461. ;;; global symbol AI_SELTYPE to one of the above three values to
  2462. ;;; indicate the method thru which the entity was aquired.
  2463. ;;;
  2464. ;;; This value can be useful to applications that want to RESTORE
  2465. ;;; an entity that was autoselected to its previous selected state
  2466. ;;; when they terminate, although there doesn't appear to be any
  2467. ;;; way to do this right now.
  2468.  
  2469. (defun ddmodify_select ()
  2470.    (cond
  2471.       (  ename                             ; (ddmodify) was called
  2472.          (cond                             ; with an <ename> argument
  2473.             (  (entget ename)              ;   If entity is non-deleted
  2474.                (setq ai_seltype 3)         ;   then return its ename.
  2475.                (ai_return ename))))
  2476.  
  2477.  
  2478.       (  (ai_aselect1 "\n┐∩╛▄¬½┼Θ¿╙╢iªµ¡╫º∩: ")) ; return autoselected
  2479.                                                       ; entity (if only one
  2480.                                                       ; entity is selected)
  2481.                                                       ; or prompt for entity
  2482.       (t (princ "\nÑ╝┐∩¿∞¬½┼ΘíC")
  2483.          (ai_return nil))
  2484.    )
  2485. )
  2486.  
  2487. ;;; ============= Command line interface function =======================
  2488.  
  2489. (defun C:DDMODIFY ()
  2490.    (ddmodify nil)
  2491.    (princ)
  2492. )
  2493.  
  2494. ;;; ================== (ddmodify) - Main program ========================
  2495. ;;;
  2496. ;;; (ddmodify <ename> )
  2497. ;;;
  2498. ;;; Main program function, callable as a subroutine.
  2499. ;;;
  2500. ;;; <ename> = entity name of the object to modify.
  2501. ;;;
  2502. ;;; If <ename> is nil, then user is prompted to select
  2503. ;;; the object interactively.
  2504. ;;;
  2505. ;;; Before (ddmodify) can be called as a subroutine, it must
  2506. ;;; be loaded first.  It is up to the calling application to
  2507. ;;; first determine this, and load it if necessary.
  2508.  
  2509.  
  2510. (defun ddmodify (ename /
  2511.  
  2512.        2ndpt            eltype              old-elist        totang
  2513.        add_mdash        emod                old-fit          tstyle
  2514.        alipt            endpt               old-idx          u
  2515.        ang              end_ang             old-spltype      upsd
  2516.        arclen           ethickness          old-u            v
  2517.        arc_calc         etype               old-v            va
  2518.        assoclist        extru               olderr           value
  2519.        atprompt         f-vis               oldlist          verify_a
  2520.        attag            fchk                on               verify_d
  2521.        attprompt        fit                 on-off           verify_i
  2522.        bit              frozth              onoff            ver_4
  2523.        bit-10           getcolor            patlist          ver_ang1
  2524.        bit-11           getindex            pattern          ver_ang2
  2525.        bit-70           getlayer            pltype           ver_col
  2526.        bit1             getltype            polytype         ver_colsp
  2527.        bit2             getthickness        pre              ver_hght
  2528.        bit3             get_color           proplist         ver_obl
  2529.        bit4             globals             pt               ver_pt1
  2530.        bit70            ha                  pt1              ver_pt2
  2531.        bit75            hght                pt2              ver_pt3
  2532.        bk-up            icvp                pt3              ver_pt4
  2533.        bkwd             index               pt4              ver_rad
  2534.        boxlength        inv                 ptype            ver_rot
  2535.        bylayer_col      item                radius           ver_row
  2536.        bylayer_lt       item1               reset            ver_rowsp
  2537.        calc             item2               reset_lay        ver_u
  2538.        cancel           itemlist            reset_lt         ver_v
  2539.        cir_calc         jlist               rot              ver_wid
  2540.        closed           jlist_act           row-sp           ver_x1
  2541.        closedm          just-idx            rows             ver_x2
  2542.        closedn          lay-idx             s                ver_x3
  2543.        cmd              layedit_act         set_action_tiles ver_x4
  2544.        cn               layinfo             set_just_idx     ver_xscl
  2545.        cname            laylist             set_tile_bk-up   ver_y1
  2546.        code_71          laylist_act         set_tile_edges   ver_y2
  2547.        col-idx          layname             set_tile_endang  ver_y3
  2548.        col-sp           laynmlst            set_tile_hght    ver_y4
  2549.        colname          layvalue            set_tile_icvp    ver_yscl
  2550.        colnmlst         linetype            set_tile_just    ver_z1
  2551.        colnolst         line_calc           set_tile_obl     ver_z2
  2552.        colnum           list1               set_tile_prompt  ver_z3
  2553.        color            longlist            set_tile_props   ver_zscl
  2554.        colorname        lt-idx              set_tile_pt1     vi
  2555.        colorno          ltabstr             set_tile_pt2     vlist
  2556.        columns          ltedit_act          set_tile_pt3     vname
  2557.        col_tile         ltidx               set_tile_pt4     vpf
  2558.        con              ltlist              set_tile_rad     vpid
  2559.        coord            ltlist1             set_tile_rc      vpldata
  2560.        ctr              ltlist_act          set_tile_rot     vpn
  2561.        cvpname          ltname              set_tile_scale   vpt
  2562.        dash             ltnmlst             set_tile_stang   wid
  2563.        dashdata         ltvalue             set_tile_style   x
  2564.        dashlist         ltype               set_tile_tag     x1
  2565.        dashsize         m                   set_tile_text    x2
  2566.        dcl_id           make_lay_lists      set_tile_vpt     x3
  2567.        dd3dface         make_lt_lists       set_tile_wid     x4
  2568.        ddarc            mdashlist           shght            xdlist
  2569.        ddblock          modify_3dface       showpt           xscale
  2570.        ddcircle         modify_arc          size             y
  2571.        ddline           modify_block        slist            y1
  2572.        ddlist           modify_circle       sname            y2
  2573.        ddmodify_err     modify_line                          y3
  2574.        ddpline          modify_point        sortlist         y4
  2575.        ddpoint          modify_polyline     spltype          yscale
  2576.        ddshape          modify_properties   ss               z1
  2577.        ddsolid          modify_shape        stpt             z2
  2578.        ddtext           modify_solid        style-idx        z3
  2579.        ddvport          modify_text         style-list       z4
  2580.        dialog-state     modify_vport        style_act        zscale
  2581.        modlist          st_ang              setcolor         reset_flag
  2582.        drawpattern      n                   temp             reset_uv
  2583.        echo             name                templist         ver_tag
  2584.        ecolor           newpoint            tempmod          move_pt1
  2585.        edge1            next                temp_color       undo_init
  2586.        edge2            next_vertex         test_ok          help_entry
  2587.        edge3            obl                 text
  2588.        edge4            off                 th-value
  2589.        edgetest         old-closed          tile
  2590.        elayer           old-closedm         tilemode
  2591.        elist            old-closedn         tile_rect
  2592.        ddimen           errchk              dismiss_dialog
  2593.  
  2594.   )
  2595.  
  2596.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  2597.         old_error  *error*            ; save current error function
  2598.         *error* ai_error              ; new error function
  2599.   )
  2600.  
  2601.   (setvar "cmdecho" (cond (  (or (not *debug*) (zerop *debug*)) 0)
  2602.                           (t 1)))
  2603.  
  2604.   (cond
  2605.      (  (not (ai_notrans)))                      ; Not transparent?
  2606.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  2607.      (  (not (setq dcl_id (ai_dcl "ddmodify")))) ; is .DLG file loaded?
  2608.      (  (not (setq ename (ddmodify_select))))    ; entity to modify?
  2609.  
  2610.      (t (ai_undo_push)
  2611.         (ddmodify_init)                          ; everything okay, proceed.
  2612.         (cond
  2613.            ((= etype "ARC")
  2614.              (setq help_entry "ddmodify,Modify_Arc")
  2615.              (ddarc)
  2616.            )
  2617.            ((= etype "ATTDEF")
  2618.              (setq help_entry "ddmodify,Modify_Attribute_Definition")
  2619.              (ddtext)
  2620.            )
  2621.            ((= etype "CIRCLE")
  2622.              (setq help_entry "ddmodify,Modify_Circle")
  2623.              (ddcircle)
  2624.            )
  2625.            ((= etype "INSERT")    ; see ddblock for help_entry
  2626.              (ddblock)
  2627.            )
  2628.            ((= etype "LINE")
  2629.              (setq help_entry "ddmodify,Modify_Line")
  2630.              (ddline)
  2631.            )
  2632.            ((= etype "POINT")
  2633.              (setq help_entry "ddmodify,Modify_Point")
  2634.              (ddpoint)
  2635.            )
  2636.            ((= etype "POLYLINE")
  2637.              (setq help_entry "ddmodify,Modify_Polyline")
  2638.  
  2639.              ;; If a 2D pline, check to see if it is planar to the current
  2640.              ;; UCS, reject if not.   To see if the pline is parallel,
  2641.              ;; the 210 group (WCS) is added to the current UCS origin (WCS)
  2642.              ;; and then converted to the current UCS and checked to see if
  2643.              ;; it is equal to (0,0,1).
  2644.              (if (and (zerop (logand 120 (cdr (assoc 70 (entget ename)))))
  2645.                       (not (equal '(0.0 0.0 1.0)
  2646.                                    (trans (mapcar '+
  2647.                                              (cdr (assoc 210 (entget ename)))
  2648.                                              (trans '(0.0 0.0 0.0) 1 0)
  2649.                                           )
  2650.                                      0 1
  2651.                                    )
  2652.                                    0.0000000001            ; fuzz
  2653.                            )
  2654.                       )
  2655.                  )
  2656.                (princ "\níu2D╗EªX╜uív╗PíuÑ╪½e UCSívñúÑ¡ªµíC")
  2657.                (ddpline)
  2658.              )
  2659.            )
  2660.  
  2661.            ((= etype "SHAPE")
  2662.              (setq help_entry "ddmodify,Modify_Shape")
  2663.              (ddshape)
  2664.            )
  2665.            ((= etype "SOLID")
  2666.              (setq help_entry "ddmodify,Modify_Solid")
  2667.              (ddsolid)
  2668.            )
  2669.            ((= etype "TEXT")
  2670.              (setq help_entry "ddmodify,Modify_Text")
  2671.              (ddtext)
  2672.            )
  2673.            ((= etype "TRACE")
  2674.              (setq help_entry "ddmodify,Modify_Trace")
  2675.              (ddsolid)
  2676.            )
  2677.            ((= etype "VIEWPORT")
  2678.              (setq help_entry "ddmodify,Modify_Viewport")
  2679.              (ddvport)
  2680.            )
  2681.            ((= etype "3DFACE")
  2682.              (setq help_entry "ddmodify,Modify_3D_Face")
  2683.              (dd3dface)
  2684.            )
  2685.            ((= etype "DIMENSION")
  2686.              (setq help_entry "ddmodify,Modify_Dimension")
  2687.              (ddimen)
  2688.            )
  2689.            (t (princ (strcat "╣∩╕▄«╪Ñ╝ñΣ┤⌐íu╣╧ñ╕├■ºO: "
  2690.                              etype "ívíC"
  2691.                      )
  2692.               )
  2693.            )
  2694.            (ai_undo_pop)
  2695.         )
  2696.      )
  2697.   )
  2698.  
  2699.   (setq *error* old_error)
  2700.   (setvar "cmdecho" old_cmd)
  2701.   (if (not reset_flag)            ; if entity was modified, then
  2702.       (ai_return ename)           ; return it's ename to caller
  2703.   )
  2704. )
  2705.  
  2706.  
  2707. (princ "  íuDDMODIFYívñw╕ⁿñJíC  ")
  2708. (princ)
  2709.  
  2710.