home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 v2.4 Fix / W95-v2.4fix.iso / ACADWIN / SUPPORT / DDMODIFY.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1995-02-08  |  129.1 KB  |  4,202 lines

  1. ;--------------------------------ddmodify.lsp----------------------------------
  2. ; Next available MSG number is    95 
  3. ; MODULE_ID DDMODIFY_LSP_
  4. ;;;----------------------------------------------------------------------------
  5. ;;;    DDMODIFY.LSP
  6. ;;;
  7. ;;;    Copyright (C) 1991, 1992, 1993, 1994 by Autodesk, Inc.
  8. ;;;
  9. ;;;    Permission to use, copy, modify, and distribute this software
  10. ;;;    for any purpose and without fee is hereby granted, provided
  11. ;;;    that the above copyright notice appears in all copies and
  12. ;;;    that both that copyright notice and the limited warranty and
  13. ;;;    restricted rights notice below appear in all supporting
  14. ;;;    documentation.
  15. ;;;
  16. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  17. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  18. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  19. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  20. ;;;    UNINTERRUPTED OR ERROR FREE.
  21. ;;;
  22. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  23. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  24. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
  25. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  26. ;;;
  27. ;;;.
  28. ;;;    Revision date: February 2, 1992
  29. ;;;
  30. ;;;----------------------------------------------------------------------------
  31. ;;;   DESCRIPTION
  32. ;;;
  33. ;;;   This function allows the user to get a listing comparable to the LIST 
  34. ;;;   command for most objects.  In addition, most object fields in the 
  35. ;;;   dialogue box are editable.  Points can be specified dynamically by 
  36. ;;;   temporarily dismissing the dialogue box.  Each object has a unique 
  37. ;;;   dialogue.
  38. ;;;
  39. ;;;   Naming conventions
  40. ;;;   Long function and widget names may use an underscore "_"
  41. ;;;   in their names to make them easier to read, long variable
  42. ;;;   names use a dash "-".
  43. ;;;----------------------------------------------------------------------------
  44. ;;;----------------------------------------------------------------------------
  45. ;;;   Prefixes in command and keyword strings: 
  46. ;;;      "."  specifies the built-in AutoCAD command in case it has been        
  47. ;;;           redefined.
  48. ;;;      "_"  denotes an AutoCAD command or keyword in the native language
  49. ;;;           version, English.
  50. ;;;----------------------------------------------------------------------------
  51. ;;;
  52. ;;; Avoid (gc)s on load to improve load time.
  53. ;;;
  54. (defun do_alloc (/ old_allod new_alloc)
  55.   (setq old_alloc (alloc 2000) new_alloc (alloc 2000))
  56.   (expand (1+ (/ 17000 new_alloc)))
  57.   (alloc old_alloc)
  58. )
  59. (do_alloc)
  60. (setq do_alloc nil)
  61.  
  62. ;;;
  63. ;;;
  64. ;;; ===========================================================================
  65. ;;; ===================== load-time error checking ============================
  66.  
  67.   (defun ai_abort (app msg)
  68.      (defun *error* (s)
  69.         (if old_error (setq *error* old_error))
  70.         (princ)
  71.      )
  72.      (if msg
  73.        (alert (strcat " Error en la aplicaci≤n: "
  74.                       app
  75.                       " \n\n  "
  76.                       msg
  77.                       "  \n"
  78.               )
  79.        )
  80.      )
  81.      (exit)
  82.   )
  83.  
  84. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  85. ;;; and then try to load it.  If it can't be found or can't be
  86. ;;; loaded, then abort the loading of this file immediately.
  87.  
  88.   (cond
  89.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  90.  
  91.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  92.         (ai_abort "DDMODIFY"
  93.                   (strcat "Imposible localizar el archivo AI_UTILS.LSP."
  94.                           "\n Compruebe el directorio de soporte.")))
  95.  
  96.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  97.         (ai_abort "DDMODIFY" "Imposible cargar el archivo AI_UTILS.LSP"))
  98.   )
  99.  
  100. ;;; If we get this far, then AI_UTILS.LSP is loaded and it can
  101. ;;; be assumed that all functions defined therein are available.
  102.  
  103. ;;; Next, check to see if ACADAPP.EXP has been xloaded, and abort
  104. ;;; if the file can't be found or xloaded.  Note that AI_ACADAPP
  105. ;;; does not abort the running application itself (so that it can
  106. ;;; also be called from within the command without also stopping
  107. ;;; an AutoCAD command currently in progress).
  108.  
  109.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  110.       (ai_abort "DDMODIFY" nil)        ; a Nil <msg> supresses
  111.   )                                    ; ai_abort's alert box dialog.
  112.  
  113. ;;; ==================== end load-time operations ===========================
  114.  
  115. ;;; If we get this far, both ai_utils.lsp and acadapp.exp are
  116. ;;; assumed to be available.
  117.  
  118. ;;; Define and encapsulate all subroutines that are declared
  119. ;;; locals of the (ddmodify) function.
  120.  
  121. (defun ddmodify_init ()
  122.   ;;
  123.   ;; These three functions modify the enitity list for common properties.  Since
  124.   ;; color, ltype, and thickness are absent from the object list when they are 
  125.   ;; set to their defaults (i.e. color = bylayer), a simple substitution using 
  126.   ;; SUBST is not possible.
  127.   ;;
  128.   (defun modify_properties ()
  129.     (emod ecolor 62)
  130.     (emod eltype 6)
  131.     (emod ethickness 39)
  132.     (emod eltscale 48)
  133.     (tempmod elayer 8 nil)
  134.   )
  135.   ;;
  136.   ;; This function is used for modifying common properties of the ACIS
  137.   ;; based geometry objects. Thickness is not valid for these objects
  138.   ;; so it is left out.
  139.   ;;
  140.   (defun modify_prop_geom ()
  141.     (emod ecolor 62)
  142.     (emod eltype 6)
  143.     (emod eltscale 48)
  144.     (tempmod elayer 8 nil)
  145.   )
  146.  
  147.   (defun emod (value bit)
  148.     (if (= bit 62)
  149.       (progn
  150.         (if (or (= value "PORCAPA")
  151.                 (= value ;|MSG0|;"BYLAYER")) (setq value 256))
  152.         (if (or (= value "PORBLOQUE")
  153.                 (= value ;|MSG0|;"BYBLOCK")) (setq value 0))
  154.       )
  155.     )
  156.     (if (setq oldlist (cdr (assoc bit elist)))
  157.       (tempmod value bit nil)
  158.       (setq elist (append elist (list (cons bit value))))
  159.     )
  160.   )
  161.   ;;
  162.   ;; Resets object list to original values.  Called when the dialogue or  
  163.   ;; function is cancelled.
  164.   ;;
  165.   (defun reset ()
  166.     (setq elist  old-elist
  167.           ecolor (cdr (assoc 62 old-elist))
  168.           eltype (cdr (assoc 6 old-elist))
  169.           elayer (cdr (assoc 8 old-elist))
  170.           ethickness (cdr (assoc 39 old-elist))
  171.           eltscale (cdr (assoc 48 old-elist))
  172.     )
  173.     (if (not ecolor) (setq ecolor ;|MSG0|;"BYLAYER"))
  174.     (if (not eltype) (setq eltype ;|MSG0|;"BYLAYER"))
  175.     (if (not ethickness) (setq ethickness 0))
  176.     (if (not eltscale) (setq eltscale 1))
  177.     (modify_properties)
  178.     (setq reset_flag t)
  179.     (entmod elist)
  180.   )
  181.   ;;
  182.   ;; Modify object when dialogue is temporarily dismissed to reflect latest 
  183.   ;; settings of dialogue.  It converts the point from current UCS coordinates to 
  184.   ;; the proper object coordinates (world or object).
  185.   ;;
  186.   ;; Arguments: value - in current UCS coordinates
  187.   ;;            bit   - object code (i.e. 10 for start point)
  188.   ;;            ptype - point type  0=world 1=planar
  189.   ;;
  190.   (defun tempmod (value bit ptype / newpoint)
  191.     (cond
  192.       ((= ptype 1) (setq value (trans value 1 ename)))
  193.       ((= ptype 0) (setq value (trans value 1 0)))
  194.     )
  195.     (setq elist (subst (cons bit value)
  196.                        (assoc bit elist)
  197.                        elist
  198.                 )
  199.     )
  200.   )
  201.   ;;
  202.   ;; The following functions are called after a dialogue has been temporarily 
  203.   ;; dismissed and the user is selecting a point.  If a point is selected the 
  204.   ;; object list is modified and new X,Y,Z values set.  If no point is selected 
  205.   ;; (null response), then the point is reset back to its previous values.
  206.   ;;
  207.   (defun ver_pt1 (ptype)
  208.     (if pt1
  209.       (progn
  210.         (tempmod pt1 10 ptype)
  211.         (entmod elist)
  212.       )
  213.       (setq pt1 (list x1 y1 z1))
  214.     )
  215.   )
  216.  
  217.   ; (move_pt1 <ptype> )
  218.   ;
  219.   ; Called in liew of (ver_pt1) to translate block insertions which
  220.   ; might have variable attributes attached to them.  If the distance
  221.   ; the block is to be moved is < 1e-6, the move is deferred.
  222.  
  223.   (defun move_pt1 (ptype / basept hi)
  224.     (setq basept (trans (cdr (assoc 10 (entget ename))) ename 1))
  225.     (cond
  226.        (  (not pt1)
  227.           (setq pt1 (list x1 y1 z1)))
  228.  
  229.        (  (> 1e-6 (distance pt1 basept)))
  230.  
  231.        (t (tempmod pt1 10 ptype)
  232.           (setq hi (getvar "highlight"))
  233.           (setvar "highlight" 0)
  234.           (command "._move" ename "" basept pt1)
  235.           (setvar "highlight" hi))
  236.     )
  237.   )
  238.  
  239.   (defun ver_pt2 (ptype)
  240.     (if pt2
  241.       (progn
  242.         (tempmod pt2 11 ptype)
  243.         (entmod elist)
  244.       )
  245.       (setq pt2 (list x2 y2 z2))
  246.     )
  247.   )
  248.  
  249.   (defun ver_pt3 (ptype)
  250.     (if pt3
  251.       (progn
  252.         (tempmod pt3 12 ptype)
  253.         (entmod elist)
  254.       )
  255.       (setq pt3 (list x3 y3 z3))
  256.     )
  257.   )
  258.  
  259.   (defun ver_pt4 (ptype)
  260.     (if pt4
  261.       (progn
  262.         (tempmod pt4 13 ptype)
  263.         (entmod elist)
  264.       )
  265.       (setq pt4 (list x4 y4 z4))
  266.     )
  267.   )
  268.   ;; Xline/Ray
  269.   (defun ver_xline_pt1()
  270.     (if xline_pt1
  271.       (progn
  272.         ;; convert to WCS.
  273.         (setq value (trans xline_pt1 1 0))
  274.         (setq elist (subst (cons 10 value)
  275.                           (assoc 10 elist)
  276.                            elist
  277.                     )
  278.         )        
  279.       )
  280.       (setq xline_pt1 (list xline_x1 xline_y1 xline_z1))
  281.     )
  282.   )
  283.  
  284.   (defun ver_xline_pt2()
  285.     (if xline_pt2
  286.       (progn
  287.     ;; 
  288.     ;; Calculate new Direction Vector WCS
  289.     ;; x / (sqrt ( (x**2) + (y**2) + (z**2)    ))
  290.     (setq temp_dir (trans xline_pt2 1 0))
  291.     (setq temp_dir_x (car temp_dir))
  292.     (setq temp_dir_y (cadr temp_dir))
  293.     (setq temp_dir_z (caddr temp_dir))
  294.  
  295.     (setq temp_xline_pt1 (trans xline_pt1 1 0))
  296.     (setq temp_xline_x1 (car temp_xline_pt1))
  297.     (setq temp_xline_y1 (cadr temp_xline_pt1))
  298.     (setq temp_xline_z1 (caddr temp_xline_pt1))
  299.  
  300.     (setq denom (sqrt (+ (expt (- temp_dir_x temp_xline_x1) 2)
  301.                          (expt (- temp_dir_y temp_xline_y1) 2)
  302.                          (expt (- temp_dir_z temp_xline_z1) 2)
  303.     )))
  304.     (setq temp_dir_x (/ (- temp_dir_x temp_xline_x1) denom))
  305.     (setq temp_dir_y (/ (- temp_dir_y temp_xline_y1) denom))
  306.     (setq temp_dir_z (/ (- temp_dir_z temp_xline_z1) denom))
  307.     (setq elist (subst (cons 11 (list temp_dir_x temp_dir_y temp_dir_z))
  308.                        (assoc 11 elist)
  309.                        elist
  310.                 )
  311.     )        
  312.     (entmod elist)
  313.         (setq xline_x2 (car xline_pt2))
  314.         (setq xline_y2 (cadr xline_pt2))
  315.         (setq xline_z2 (caddr xline_pt2))
  316.  
  317.  
  318.       )
  319.       (setq xline_pt2 (list xline_x2 xline_y2 xline_z2))
  320.     )
  321.   )
  322.  
  323.   ;;
  324.   ;; Common properties for all objects
  325.   ;;
  326.   (defun set_tile_props ()
  327.     (set_tile "error" "")
  328.     (setcolor)
  329.     (cond
  330.       ((= eltype ;|MSG0|;"BYLAYER")
  331.          (set_tile "t_ltype" (bylayer_lt)))
  332.       ((= eltype ;|MSG0|;"BYBLOCK")
  333.          (set_tile "t_ltype" "PORBLOQUE"))
  334.       (T (set_tile "t_ltype" eltype))
  335.     )
  336.     (set_tile "t_layer" elayer)
  337.     (set_tile "eb_thickness" (ai_rtos ethickness))
  338.     (set_tile "eb_ltscale" (ai_rtos eltscale))
  339.     (setq which_tiles (ai_common_state etype))
  340.     ;; Disable tiles if need be...
  341.  
  342.     ;; Layer Button and Text Field
  343.     (if (/= 1 (logand 1 which_tiles))
  344.       (progn
  345.         (mode_tile "t_layer" 1)
  346.         (mode_tile "b_name" 1)
  347.       )
  348.     )
  349.     ;; Color Button and Text Field
  350.     (if (/= 2 (logand 2 which_tiles))
  351.       (progn
  352.         (mode_tile "t_color" 1)
  353.         (mode_tile "b_color" 1)
  354.         (mode_tile "show_image" 1)
  355.       )
  356.     )
  357.     ;; Linetype Button and Text Field
  358.     (if (/= 4 (logand 4 which_tiles))
  359.       (progn
  360.         (mode_tile "t_ltype" 1)
  361.         (mode_tile "b_line" 1)
  362.       )
  363.     )
  364.     ;; Linetype Scale Edit Field
  365.     (if (/= 8 (logand 8 which_tiles))
  366.       (progn
  367.         (mode_tile "eb_ltscale" 1)
  368.       )
  369.     )
  370.     ;; Thickness Edit Field.
  371.     (if (/= 16 (logand 16 which_tiles))
  372.       (progn
  373.         (mode_tile "eb_thickness" 1)
  374.       )
  375.     )
  376.  
  377.   )
  378.   ;;
  379.   ;; XYZ Point values for all enitites
  380.   ;;
  381.   (defun set_tile_pt1 (ptype)
  382.     (if (= ptype 0)
  383.       (setq pt1 (trans (cdr (assoc 10 elist)) 0 1))
  384.       (setq pt1 (trans (cdr (assoc 10 elist)) ename 1))
  385.     )
  386.     (set_tile "x1_pt" (ai_rtos (setq x1 (car pt1))))
  387.     (set_tile "y1_pt" (ai_rtos (setq y1 (cadr pt1))))
  388.     (set_tile "z1_pt" (ai_rtos (setq z1 (caddr pt1))))
  389.   )
  390.   (defun set_tile_pt2 (ptype)
  391.     (if (= ptype 0)
  392.       (setq pt2 (trans (cdr (assoc 11 elist)) 0 1))
  393.       (setq pt2 (trans (cdr (assoc 11 elist)) ename 1))
  394.     )
  395.     (set_tile "x2_pt" (ai_rtos (setq x2 (car pt2))))
  396.     (set_tile "y2_pt" (ai_rtos (setq y2 (cadr pt2))))
  397.     (set_tile "z2_pt" (ai_rtos (setq z2 (caddr pt2))))
  398.   )
  399.   (defun set_tile_pt3 (ptype)
  400.     (if (= ptype 0)
  401.       (setq pt3 (trans (cdr (assoc 12 elist)) 0 1))
  402.       (setq pt3 (trans (cdr (assoc 12 elist)) ename 1))
  403.     )
  404.     (set_tile "x3_pt" (ai_rtos (setq x3 (car pt3))))
  405.     (set_tile "y3_pt" (ai_rtos (setq y3 (cadr pt3))))
  406.     (set_tile "z3_pt" (ai_rtos (setq z3 (caddr pt3))))
  407.   )
  408.   (defun set_tile_pt4 (ptype)
  409.     (if (= ptype 0)
  410.       (setq pt4 (trans (cdr (assoc 13 elist)) 0 1))
  411.       (setq pt4 (trans (cdr (assoc 13 elist)) ename 1))
  412.     )
  413.     (set_tile "x4_pt" (ai_rtos (setq x4 (car pt4))))
  414.     (set_tile "y4_pt" (ai_rtos (setq y4 (cadr pt4))))
  415.     (set_tile "z4_pt" (ai_rtos (setq z4 (caddr pt4))))
  416.   )
  417.   ;;
  418.   ;; Xline/Ray 
  419.   ;; 
  420.   (defun set_tile_xline_pt1 ()
  421.    
  422.     (setq xline_pt1 (trans (cdr (assoc 10 elist)) 0 1))
  423.       
  424.     (set_tile "xline_x1" (ai_rtos (setq xline_x1 (car xline_pt1))))
  425.     (set_tile "xline_y1" (ai_rtos (setq xline_y1 (cadr xline_pt1))))
  426.     (set_tile "xline_z1" (ai_rtos (setq xline_z1 (caddr xline_pt1))))
  427.   )
  428.   (defun set_tile_dirv ()
  429.     ;; Convert 11 group to local UCS (displacement)
  430.     (setq dir_pt (trans (cdr (assoc 11 elist)) 0 1 1))
  431.  
  432.     (set_tile "dir_x" (rtos (setq dir_ptx (car dir_pt))))
  433.     (set_tile "dir_y" (rtos (setq dir_pty (cadr dir_pt))))
  434.     (set_tile "dir_z" (rtos (setq dir_ptz (caddr dir_pt))))
  435.   )
  436.   (defun set_tile_xline_pt2 ()
  437.     (if (not xline_pt2)
  438.       ;; Initial second point is Root Point + Direction Vector
  439.       (setq xline_pt2 (mapcar '+ xline_pt1 dir_pt))
  440.     )
  441.     (set_tile "xline_x2" (ai_rtos (setq xline_x2 (car xline_pt2))))
  442.     (set_tile "xline_y2" (ai_rtos (setq xline_y2 (cadr xline_pt2))))
  443.     (set_tile "xline_z2" (ai_rtos (setq xline_z2 (caddr xline_pt2))))
  444.   )
  445.  
  446.   ;; 
  447.   ;; Handle for all objects
  448.   ;;
  449.   (defun set_tile_handle ()
  450.     (if (setq hand (cdr (assoc 5 elist)))
  451.       (set_tile "Handle" hand)
  452.       (set_tile "Handle" "Ninguno")
  453.     )
  454.   )
  455.   ;; 
  456.   ;; Radius for ARC and CIRCLE
  457.   ;;
  458.   (defun set_tile_rad ()
  459.     (setq radius (cdr (assoc 40 elist)))
  460.     (set_tile "radius" (ai_rtos radius))
  461.   )
  462.   ;;
  463.   ;; Start angle for ARC
  464.   ;;
  465.   (defun set_tile_stang ()
  466.     (setq st_ang (cdr (assoc 50 elist)))
  467.     (set_tile "st_ang" (ai_angtos st_ang))
  468.   )
  469.   ;;
  470.   ;; End angle for ARC
  471.   ;;
  472.   (defun set_tile_endang ()
  473.     (setq end_ang (cdr (assoc 51 elist)))
  474.     (set_tile "end_ang" (ai_angtos end_ang))
  475.   ) 
  476.   ;;
  477.   ;; Rotation Angle - Text, Attributes, Block insertions and Shapes
  478.   ;;
  479.   (defun set_tile_rot ()
  480.     (setq rot (cdr (assoc 50 elist)))
  481.     (set_tile "rot" (ai_angtos rot))
  482.   )
  483.   ;;
  484.   ;; Height - Text, Attributes and Shapes
  485.   ;;
  486.   (defun set_tile_hght ()
  487.     (setq hght (cdr (assoc 40 elist)))
  488.     (set_tile "hght" (ai_rtos hght))
  489.   )
  490.   ;;
  491.   ;; Width Factor - Text, Attributes and Shapes
  492.   ;;
  493.   (defun set_tile_wid ()
  494.     (setq wid (cdr (assoc 41 elist)))
  495.     (set_tile "wid" (ai_rtos wid))
  496.   )
  497.   ;;
  498.   ;; Obliquing Angle - Text, Attributes and Shapes
  499.   ;;
  500.   (defun set_tile_obl ()
  501.     (setq obl (cdr (assoc 51 elist)))
  502.     (set_tile "obl" (ai_angtos obl))
  503.   )
  504.   ;;
  505.   ;; Text string
  506.   ;;
  507.   (defun set_tile_text ()
  508.     (setq text (cdr (assoc 1 elist)))
  509.     (set_tile "t_string" text)
  510.   )
  511.   ;;
  512.   ;; Attribute Tag
  513.   ;;
  514.   (defun set_tile_tag ()
  515.     (if (= etype "ATTDEF")
  516.       (progn
  517.         (setq attag (cdr (assoc 2 elist)))
  518.         (set_tile "tag" attag)
  519.       )
  520.     )
  521.   )
  522.   ;;
  523.   ;; Attribute Definition
  524.   ;;
  525.   (defun set_tile_prompt ()
  526.     (if (= etype "ATTDEF")
  527.       (progn
  528.         (setq atprompt (cdr (assoc 3 elist)))
  529.         (set_tile "prompt" atprompt)
  530.       )
  531.     )
  532.   )
  533.   ;;
  534.   ;; Justification setting for Attributes and Text.  Initializes
  535.   ;; popup list box
  536.   ;;
  537.   (defun set_tile_just ()
  538.     (setq ha (cdr (assoc 72 elist)))  ; horizontal alignment
  539.     (setq va (cdr (assoc 73 elist)))  ; vertical alignment
  540.     (setq ha-prev ha)
  541.     (if (= etype "ATTDEF")
  542.         (setq va (cdr (assoc 74 elist)))  ; vertical alignment
  543.     )
  544.     (setq jlist
  545.           (list "Izquierda"        "Centro"        "Derecha"
  546.                 "Alineado"     "Medio"        "Ajustar"
  547.                 "Superior izq."    "Sup. centro"    "Superior der."
  548.                 "Medio izq." "Medio centro" "Medio derecho"
  549.                 "Inferior izq." "Inf. centro" "Inferior der."
  550.           )
  551.     )
  552.     (start_list "popup_just")
  553.     (mapcar 'add_list jlist)
  554.     (end_list)
  555.     (set_just_idx)
  556.     (set_tile "popup_just" (jlist_act just-idx))
  557.   )
  558.   ;;
  559.   ;; Style setting for Attributes and Text.  Reads symbol table for popup list 
  560.   ;; box.
  561.   ;;
  562.   (defun set_tile_style (/ sname style-idx)
  563.     (setq slist (list (cdr (assoc 2 (tblnext "STYLE" T)))))
  564.     (while (setq sname (cdr (assoc 2 (tblnext "STYLE"))))
  565.       (if (/= sname "") (setq slist (cons sname slist)))
  566.     )
  567.     (setq slist (acad_strlsort slist))  ; alphabetize style list
  568.     (start_list "style")
  569.     (mapcar 'add_list slist)
  570.     (end_list)
  571.     (setq tstyle (cdr (assoc 7 elist)))
  572.     (setq style-idx (getindex tstyle slist))
  573.     (set_tile "style" (itoa style-idx))
  574.   )
  575.   ;;
  576.   ;; Text and Attribute setting - upside-down, backwards
  577.   ;;
  578.   (defun set_tile_bk-up ()
  579.     (setq bk-up (cdr (assoc 71 elist)))
  580.     (if (= (logand bk-up 2) 2)
  581.       (set_tile "bkwd" (itoa (setq bkwd 1)))
  582.       (set_tile "bkwd" (itoa (setq bkwd 0)))
  583.     )
  584.     (if (= (logand bk-up 4) 4)
  585.       (set_tile "upsd" (itoa (setq upsd 1)))
  586.       (set_tile "upsd" (itoa (setq upsd 0)))
  587.     )
  588.   )
  589.   ;;
  590.   ;; Attribute setting - invisible, constant, verify, preset
  591.   ;; 
  592.   (defun set_tile_icvp ()
  593.     (if (not (setq icvp (cdr (assoc 70 elist))))
  594.       (setq icvp 0)
  595.     )
  596.     (if (= (logand icvp 1) 1)
  597.       (set_tile "inv" (itoa (setq inv 1)))
  598.       (set_tile "inv" (itoa (setq inv 0)))
  599.     )
  600.     (if (= (logand icvp 2) 2)
  601.       (set_tile "con" (itoa (setq con 1)))
  602.       (set_tile "con" (itoa (setq con 0)))
  603.     )
  604.     (if (= (logand icvp 4) 4)
  605.       (set_tile "ver" (itoa (setq vfy 1)))
  606.       (set_tile "ver" (itoa (setq vfy 0)))
  607.     )
  608.     (if (= (logand icvp 8) 8)
  609.       (set_tile "pre" (itoa (setq pre 1)))
  610.       (set_tile "pre" (itoa (setq pre 0)))
  611.     )
  612.   )
  613.   ;;
  614.   ;; Scale factors for block insertions
  615.   ;;
  616.   (defun set_tile_scale ()
  617.     (setq xscale (cdr (assoc 41 elist)))
  618.     (set_tile "xscale" (ai_rtos xscale))
  619.     (setq yscale (cdr (assoc 42 elist)))
  620.     (set_tile "yscale" (ai_rtos yscale))
  621.     (setq zscale (cdr (assoc 43 elist)))
  622.     (set_tile "zscale" (ai_rtos zscale))
  623.   )
  624.   ;;
  625.   ;; Rows and columns for block insertions
  626.   ;;
  627.   (defun set_tile_rc ()
  628.     (setq columns (cdr (assoc 70 elist)))
  629.     (set_tile "columns" (itoa columns ))
  630.     (setq rows (cdr (assoc 71 elist)))
  631.     (set_tile "rows" (itoa rows))
  632.     (setq col-sp (cdr (assoc 44 elist)))
  633.     (set_tile "col_sp" (ai_rtos col-sp))
  634.     (setq row-sp (cdr (assoc 45 elist)))
  635.     (set_tile "row_sp" (ai_rtos row-sp))
  636.   )
  637.   ;;
  638.   ;; Invisible edges for 3DFACE
  639.   ;;
  640.   (defun set_tile_edges ()
  641.     (setq f-vis (cdr (assoc 70 elist)))
  642.     (if (= (logand f-vis 1) 1)
  643.       (set_tile "edge_1" (setq edge1 "0"))
  644.       (set_tile "edge_1" (setq edge1 "1"))
  645.     )
  646.     (if (= (logand f-vis 2) 2)
  647.       (set_tile "edge_2" (setq edge2 "0"))
  648.       (set_tile "edge_2" (setq edge2 "1"))
  649.     )
  650.     (if (= (logand f-vis 4) 4)
  651.       (set_tile "edge_3" (setq edge3 "0"))
  652.       (set_tile "edge_3" (setq edge3 "1"))
  653.     )
  654.     (if (= (logand f-vis 8) 8)
  655.       (set_tile "edge_4" (setq edge4 "0"))
  656.       (set_tile "edge_4" (setq edge4 "1"))
  657.     )
  658.   )
  659.   ;;
  660.   ;; XYZ Point values for polyline vertex 
  661.   ;;
  662.   (defun set_tile_vpt (ptype)
  663.     (if (= ptype 0)
  664.       (setq vpt (trans (cdr (assoc 10 vlist)) 0 1))
  665.       (setq vpt (trans (cdr (assoc 10 vlist)) ename 1))
  666.     )
  667.     (set_tile "xtext" (rtos (setq x1 (car vpt))))
  668.     (set_tile "ytext" (rtos (setq y1 (cadr vpt))))
  669.     (set_tile "ztext" (rtos (setq z1 (caddr vpt))))
  670.   )
  671.   ;;
  672.   ;; Set tiles for Spline properties. If the spline is rational then we
  673.   ;; need to display the weight values of the control points, so set
  674.   ;; flag to 1.
  675.   ;; 1 = rational spline
  676.   ;; 0 = non-rational spline
  677.   ;;
  678.   (defun set_tile_spline_props ()
  679.     (setq rational_spl_flag 0)      ;; initialize rational spline flag
  680.     (set_tile "Degree" (itoa (cdr (assoc 71 elist))))
  681.     (setq bit70 (cdr (assoc 70 elist)))
  682.     (if (= (logand bit70 1) 1)
  683.         (set_tile "SpProp4" "Cerrado")
  684.         (set_tile "SpProp4" "      ")
  685.     )
  686.     (if (= (logand bit70 2) 2)
  687.         (set_tile "SpProp3" "Peri≤dico")
  688.         (set_tile "SpProp3" "No peri≤dico")
  689.     )
  690.     (if (= (logand bit70 4) 4)
  691.       (progn
  692.         (set_tile "SpProp2" "Racional")
  693.         (setq rational_spl_flag 1)      ;; this is a rational spline
  694.       )
  695.         (set_tile "SpProp2" "No racional")
  696.     )
  697.     (if (= (logand bit70 8) 8)
  698.         (set_tile "SpProp1" "Plano")
  699.         (set_tile "SpProp1" "No plano")
  700.     )
  701.     (if (= (logand bit70 16) 16)
  702.         (set_tile "SpProp5" "Lineal")
  703.         (set_tile "SpProp5" "      ")
  704.     )
  705.   )
  706.   ;;
  707.   ;; XYZ Point values for spline points  
  708.   ;; Need to account for WCS/UCS
  709.   ;;
  710.   (defun set_tile_cntl_pt ()
  711.     (setq cntl-pt (cdr (assoc 10  elist)))
  712.     (set_tile "xtext" (rtos (setq x1 (car cntl-pt))))
  713.     (set_tile "ytext" (rtos (setq y1 (cadr cntl-pt))))
  714.     (set_tile "ztext" (rtos (setq z1 (caddr cntl-pt))))
  715.     (if (= rational_spl_flag 1)      ;; if rational spline
  716.       (progn                         ;; show weight
  717.         (setq weight (cdr (assoc 41 elist)))
  718.         (set_tile "weight" (rtos weight))
  719.       )                              ;; else
  720.         (mode_tile "weight_text" 1)  ;; disable weight field
  721.     )
  722.   )
  723.   ;;
  724.   ;; XYZ Point values for spline points
  725.   ;; Need to account for WCS/UCS
  726.   ;;
  727.   (defun set_tile_data_pt ()
  728.     (if (not (assoc 11 elist))
  729.       (mode_tile "data_pts" 1)
  730.       (progn
  731.          (setq data-pt (cdr (assoc 11  elist)))
  732.          (set_tile "dxtext" (ai_rtos (setq x1 (car data-pt))))
  733.          (set_tile "dytext" (ai_rtos (setq y1 (cadr data-pt))))
  734.          (set_tile "dztext" (ai_rtos (setq z1 (caddr data-pt))))
  735.       )
  736.     )
  737.   )
  738.   ;;
  739.   ;; Fit curve, fit spline, or smooth spline surface setting
  740.   ;;
  741.   (defun set_tile_fitsmooth ()
  742.     (cond
  743.       ((= (logand bit70 4) 4)
  744.        (cond 
  745.          ((= bit75 0)
  746.            (set_tile "none" "1")
  747.            (setq spltype 0)
  748.          )
  749.          ((= bit75 5)
  750.            (set_tile "quad" "1")
  751.            (setq spltype 5)
  752.          )
  753.          ((= bit75 6)
  754.            (set_tile "cubic" "1")
  755.            (setq spltype 6)
  756.          )
  757.          ((= bit75 8)
  758.            (set_tile "bezier" "1")
  759.            (setq spltype 8)
  760.          )
  761.        )
  762.       )
  763.       ((= (logand bit70 2) 2)
  764.         (set_tile "fit" "1")
  765.         (setq spltype 1)
  766.       )
  767.       (T (set_tile "none" "1"))
  768.     )
  769.   )
  770.   ;;
  771.   ;; Closed or Open mesh and polyline setting
  772.   ;;
  773.   (defun set_tile_closed ()
  774.       (if (= pltype "Malla 3D")
  775.         (progn
  776.           (if (= (logand bit70 32) 32)
  777.             (set_tile "closedn" (setq closedn "1"))
  778.             (set_tile "closedn" (setq closedn "0"))
  779.           )
  780.           (if (= (logand bit70 1) 1)
  781.             (set_tile "closedm" (setq closed "1"))
  782.             (set_tile "closedm" (setq closed "0"))
  783.           )
  784.           (setq old-closedm closedm old-closedn closedn)
  785.         )
  786.       )
  787.       (if (or (= pltype "Polilφnea 2D")
  788.               (= pltype "Polilφnea 3D")
  789.           )
  790.         (progn
  791.           (if (= (logand bit70 1) 1)
  792.             (set_tile "closed" (setq closed "1"))
  793.             (set_tile "closed" (setq closed "0"))
  794.           )
  795.           (setq old-closed closed)
  796.         )
  797.       )
  798.   )
  799.   ;; Set common action tiles
  800.   ;;
  801.   ;; Defines action to be taken when pressing various widgets.  It is called 
  802.   ;; for every object dialogue.  Not all widgets exist for each object dialogue,
  803.   ;; but defining an action for a non-existent widget does no harm.
  804.   (defun set_action_tiles ()
  805.     (action_tile "cancel"       "(dismiss_dialog 0)")
  806.     (action_tile "accept"       "(dismiss_dialog 1)")
  807.     (action_tile "help"         "(help \"\" help_entry)")
  808.     (action_tile "b_color"      "(getcolor)")
  809.     (action_tile "show_image"   "(getcolor)")
  810.     (action_tile "b_name"       "(setq elayer (getlayer))")
  811.     (action_tile "b_line"       "(setq eltype (getltype))")
  812.     (action_tile "eb_thickness" "(getthickness $value)")
  813.     (action_tile "eb_ltscale"   "(getltscale $value)")
  814.  
  815.     (action_tile "pick_1"       "(dismiss_dialog 3)")
  816.     (action_tile "pick_2"       "(dismiss_dialog 4)")
  817.     (action_tile "pick_3"       "(dismiss_dialog 5)")
  818.     (action_tile "pick_4"       "(dismiss_dialog 6)")
  819.     (action_tile "x1_pt"        "(ver_x1 $value)")
  820.     (action_tile "y1_pt"        "(ver_y1 $value)")
  821.     (action_tile "z1_pt"        "(ver_z1 $value)")
  822.     (action_tile "x2_pt"        "(ver_x2 $value)")
  823.     (action_tile "y2_pt"        "(ver_y2 $value)")
  824.     (action_tile "z2_pt"        "(ver_z2 $value)")
  825.     (action_tile "x3_pt"        "(ver_x3 $value)")
  826.     (action_tile "y3_pt"        "(ver_y3 $value)")
  827.     (action_tile "z3_pt"        "(ver_z3 $value)")
  828.     (action_tile "x4_pt"        "(ver_x4 $value)")
  829.     (action_tile "y4_pt"        "(ver_y4 $value)")
  830.     (action_tile "z4_pt"        "(ver_4 $value)")
  831.  
  832.     ;; Action tiles for Xline & Ray
  833.     (action_tile "xline_x1" "(ver_xline_x1 $value)")
  834.     (action_tile "xline_y1" "(ver_xline_y1 $value)")
  835.     (action_tile "xline_z1" "(ver_xline_z1 $value)")
  836.     (action_tile "xline_x2" "(ver_xline_x2 $value)")
  837.     (action_tile "xline_y2" "(ver_xline_y2 $value)")
  838.     (action_tile "xline_z2" "(ver_xline_z2 $value)")
  839.  
  840.     (action_tile "edge_1"       "(setq edge1 $value)")
  841.     (action_tile "edge_2"       "(setq edge2 $value)")
  842.     (action_tile "edge_3"       "(setq edge3 $value)")
  843.     (action_tile "edge_4"       "(setq edge4 $value)")
  844.  
  845.     (action_tile "radius"       "(ver_rad $value)")
  846.     (action_tile "st_ang"       "(ver_ang1 $value)")
  847.     (action_tile "end_ang"      "(ver_ang2 $value)")
  848.     (action_tile "end_eang"     "(ver_eang $value)")
  849.     (action_tile "minrad"       "(ver_minrad $value)")
  850.     (action_tile "majrad"       "(ver_majrad $value)")
  851.  
  852.     (action_tile "xscale"       "(ver_xscl $value)")
  853.     (action_tile "yscale"       "(ver_yscl $value)")
  854.     (action_tile "zscale"       "(ver_zscl $value)")
  855.     (action_tile "rot"          "(ver_rot $value)")
  856.     (action_tile "columns"      "(ver_col $value)")
  857.     (action_tile "rows"         "(ver_row $value)")
  858.     (action_tile "col_sp"       "(ver_colsp $value)")
  859.     (action_tile "row_sp"       "(ver_rowsp $value)")
  860.  
  861.     (action_tile "hght"         "(ver_hght $value)")
  862.     (action_tile "wid"          "(ver_wid $value)")
  863.     (action_tile "obl"          "(ver_obl $value)")
  864.     (action_tile "style"        "(style_act $value)")
  865.     
  866.     (action_tile "t_string"     "(ddgettext)")
  867.     (action_tile "tag"          "(ver_tag $value)")
  868.     (action_tile "prompt"       "(setq atprompt $value)")
  869.     (action_tile "bkwd"         "(setq bkwd (atoi $value))")
  870.     (action_tile "upsd"         "(setq upsd (atoi $value))")
  871.     (action_tile "inv"          "(setq inv (atoi $value))")
  872.     (action_tile "con"          "(setq con (atoi $value))")
  873.     (action_tile "ver"          "(setq vfy (atoi $value))")
  874.     (action_tile "pre"          "(setq pre (atoi $value))")
  875.     (action_tile "popup_just"   "(jlist_act $value)")
  876.  
  877.     (action_tile "closed"       "(setq closed $value)")
  878.     (action_tile "ltgen"        "(setq ltgen $value)")
  879.     (action_tile "closedm"      "(setq closedm $value)")
  880.     (action_tile "closedn"      "(setq closedn $value)")
  881.     (action_tile "next_v"       "(next_vertex)")
  882.  
  883.     (action_tile "next_cntlpt"  "(next_cntl_pt)")
  884.     (action_tile "next_datapt"  "(next_data_pt)")
  885.  
  886.     (action_tile "none"         "(if (radio_gaga \"none\")(set_uv 0))")
  887.     (action_tile "fit"          "(if (radio_gaga \"fit\")(set_uv 1))")
  888.     (action_tile "quad"         "(if (radio_gaga \"quad\")(set_uv 5))")
  889.     (action_tile "cubic"        "(if (radio_gaga \"cubic\")(set_uv 6))")
  890.     (action_tile "bezier"       "(if (radio_gaga \"bezier\")(set_uv 8))")
  891.  
  892.     (action_tile "u"            "(ver_u $value)")
  893.     (action_tile "v"            "(ver_v $value)")
  894.   )
  895.   
  896.   (defun ddgettext()
  897.     (setq text (get_tile "t_string"))
  898.   )
  899.   ;; As OW doesn't support disabling of individual radio buttons within 
  900.   ;; clusters, a check must be performed as to the legitimacy of the 
  901.   ;; button pushed and reset if necessary.
  902.   (defun radio_gaga (pushed)
  903.     (cond 
  904.       ((and (= pltype "Polilφnea 3D")
  905.             (or (= pushed "fit")
  906.                 (= pushed "bezier")
  907.             )
  908.        )
  909.         (set_tile "none" "1")
  910.         nil
  911.       )
  912.       ((and (= pltype "Malla 3D")
  913.             (= "fit" pushed)
  914.        )
  915.         (set_tile "none" "1")
  916.         nil
  917.       )           
  918.       ((= pltype "Malla policara")
  919.         (set_tile "none" "1")
  920.         nil
  921.       )
  922.       ((and (= pltype "Polilφnea 2D")
  923.             (= "bezier" pushed)
  924.        )
  925.         (set_tile "none" "1")
  926.         nil
  927.       )  
  928.       (T)
  929.     )
  930.   )
  931.   ;;
  932.   (defun set_uv (type)
  933.     (setq spltype type)
  934.     (if (= pltype "Malla 3D")
  935.       (if (= spltype 0)
  936.         (progn
  937.           (set_tile "u" (itoa (setq u 0)))
  938.           (set_tile "v" (itoa (setq v 0)))
  939.         )
  940.         (progn
  941.           (if (= u 0)
  942.             (set_tile "u" (itoa (setq u (getvar "surfu"))))
  943.           )
  944.           (if (= v 0)
  945.             (set_tile "v" (itoa (setq v (getvar "surfv"))))
  946.           )
  947.         )
  948.       )
  949.     )
  950.   )
  951.   
  952.  
  953.   ;;
  954.   ;; Verification functions
  955.   ;;
  956.   ;; Verify distance function.  This takes a new X, Y, or Z coordinate or 
  957.   ;; distance value, the tile name, and the previous value as arguments.
  958.   ;; If the distance is valid, it returns the distance and resets the tile.
  959.   ;; Otherwise, it returns the previous value, sets the error tile and keeps
  960.   ;; focus on the tile.  Shifting focus to the tile with invalid value can
  961.   ;; trigger a callback from another tile whose value is valid.  In order
  962.   ;; to keep the error message from being cleared by this secondary callback,
  963.   ;; the variable errchk is set and checked.  The last-tile variable is set
  964.   ;; and checked to ensure the error message is properly cleared when the
  965.   ;; user corrects the value and hits return.
  966.   ;;
  967.   (defun verify_d (tile value old-value / coord valid errmsg)
  968.     (setq valid nil errmsg "Valor de entrada no vßlido.")
  969.     (if (setq coord (distof value))
  970.       (progn
  971.         (cond
  972.           ((or (= tile "radius")
  973.                (= tile "hght")
  974.                (= tile "wid")
  975.                (= tile "majrad")
  976.                (= tile "minrad")
  977.            )
  978.            (if (> coord 0)
  979.              (setq valid T)
  980.              (setq errmsg "El valor debe ser positivo y distinto de cero.")
  981.            )
  982.           )
  983.           ((or (= tile "xscale")
  984.                (= tile "yscale")
  985.                (= tile "zscale")
  986.                (= tile "eb_ltscale")
  987.            )
  988.            (if (/= coord 0)
  989.              (setq valid T)
  990.              (setq errmsg "El valor debe ser distinto de cero.")
  991.            )
  992.           )
  993.           (T (setq valid T))
  994.         )
  995.       )
  996.       (setq valid nil)
  997.     )
  998.     (if valid
  999.       (progn 
  1000.         (if (or (= errchk 0) (= tile last-tile))
  1001.           (set_tile "error" "")
  1002.         )
  1003.         (set_tile tile (ai_rtos coord))
  1004.         (setq errchk 0)
  1005.         (setq last-tile tile)
  1006.         coord
  1007.       )
  1008.       (progn
  1009.         (mode_tile tile 2)
  1010.         (set_tile "error" errmsg)
  1011.         (setq errchk 1)
  1012.         (setq last-tile tile)
  1013.         old-value
  1014.       )
  1015.     )
  1016.   )
  1017.   ;; Function for Xline coord edit box checking.
  1018.   (defun verify_xline (tile value old-value / coord valid errmsg)
  1019.     (setq valid nil errmsg "Valor de entrada no vßlido.")
  1020.     (if (setq coord (distof value))
  1021.       (setq valid T)
  1022.       (setq valid nil)
  1023.     )
  1024.     (if (and coord
  1025.           (and (= (atof (get_tile "xline_x1")) (atof (get_tile "xline_x2")) )
  1026.                (= (atof (get_tile "xline_y1")) (atof (get_tile "xline_y2")) )
  1027.                (= (atof (get_tile "xline_z1")) (atof (get_tile "xline_z2")) )         
  1028.           )
  1029.         )
  1030.        (progn 
  1031.          (setq errmsg 
  1032.                   "El punto raφz y el segundo punto no pueden ser iguales.") 
  1033.          (setq valid nil)
  1034.        )
  1035.     )
  1036.     (if valid
  1037.       (progn 
  1038.         (if (or (= errchk 0) (= tile last-tile))
  1039.           (set_tile "error" "")
  1040.         )
  1041.         (set_tile tile (ai_rtos coord))
  1042.         (setq errchk 0)
  1043.         (setq last-tile tile)
  1044.         coord
  1045.       )
  1046.       (progn
  1047.         (mode_tile tile 2)
  1048.         (set_tile "error" errmsg)
  1049.         (setq errchk 1)
  1050.         (setq last-tile tile)
  1051.         old-value
  1052.       )
  1053.     )
  1054.   )
  1055.  
  1056.   ;;
  1057.   ;; Verify angle function.  This takes an angle and a tile name as arguments.
  1058.   ;; If the angle is valid, it returns the angle and resets the tile.  
  1059.   ;; Otherwise, it sets the error tile and keeps focus on the tile.
  1060.   ;;
  1061.   (defun verify_a (tile value old-value / ang)
  1062.     (if (setq ang (angtof value))
  1063.       (progn 
  1064.         (if (or (= errchk 0) (= tile last-tile))
  1065.           (set_tile "error" "")
  1066.         )
  1067.         (set_tile tile (ai_angtos ang))
  1068.         (setq errchk 0)
  1069.         (setq last-tile tile)
  1070.         ang
  1071.       )
  1072.       (progn
  1073.         (mode_tile tile 2)
  1074.         (setq last-tile tile)
  1075.         (setq errchk 1)
  1076.         (set_tile "error" "Valor de entrada err≤neo.")
  1077.         old-value
  1078.       )
  1079.     )
  1080.   )
  1081.   ;;
  1082.   ;; Verify angle function.  This takes an angle and a tile name as arguments.
  1083.   ;; If the angle is valid, it returns the angle and resets the tile.
  1084.   ;; Otherwise, it sets the error tile and keeps focus on the tile.
  1085.   ;; This function is specifically for the end angle of the ellipse object. If
  1086.   ;; the end angle resolves to zero then we want to display it as 360.
  1087.   ;;
  1088.   (defun verify_ae (tile value old-value / ang tempend)
  1089.     (if (setq ang (angtof value))
  1090.       (progn
  1091.         (if (or (= errchk 0) (= tile last-tile))
  1092.           (set_tile "error" "")
  1093.         )
  1094.         (setq tempend (ai_angtos ang))
  1095.         (if (= tempend "0")
  1096.            (set_tile tile "360")
  1097.            (set_tile tile tempend)
  1098.         )
  1099.         (setq errchk 0)
  1100.         (setq last-tile tile)
  1101.         ang
  1102.       )
  1103.       (progn
  1104.         (mode_tile tile 2)
  1105.         (setq last-tile tile)
  1106.         (setq errchk 1)
  1107.         (set_tile "error" "Valor de entrada err≤neo.")
  1108.         old-value
  1109.       )
  1110.     )
  1111.   )
  1112.   ;;
  1113.   ;; Verify integer function.  This takes an integer and a tile name as 
  1114.   ;; arguments.  If the integer is valid, it returns the integer and resets the 
  1115.   ;; tile.  Otherwise, it sets the error tile and keeps focus on the tile.
  1116.   ;;
  1117.   (defun verify_i (tile value old-value / int valid errmsg)
  1118.     (setq valid nil)
  1119.     (setq errmsg "El valor debe ser un n·mero entero.")
  1120.     (setq int (atoi value))
  1121.     (if (setq intchk (distof value))
  1122.       (cond
  1123.         ((or (= tile "columns") (= tile "rows"))
  1124.          (if (and (= int intchk)
  1125.                   (>= int 0)
  1126.                   (<= int 32767)
  1127.              )
  1128.            (setq valid T)
  1129.            (setq errmsg "El valor debe ser un n·mero entero entre 0 y 32767.")
  1130.          )
  1131.         )
  1132.         ((and (or (= tile "u") (= tile "v")))
  1133.          (if (and (= int intchk)
  1134.                   (>= int 0)
  1135.                   (< int 201)
  1136.              )
  1137.            (setq valid T)
  1138.            (setq errmsg "El valor debe ser un n·mero entero entre 0 y 200.")
  1139.          )
  1140.         )
  1141.       )
  1142.     )
  1143.     (if valid
  1144.       (progn 
  1145.         (if (or (= errchk 0) (= tile last-tile))
  1146.             (set_tile "error" "")
  1147.         )
  1148.         (set_tile tile (itoa int))
  1149.         (setq errchk 0)
  1150.         (setq last-tile tile)
  1151.         int
  1152.       )
  1153.       (progn
  1154.         (mode_tile tile 2)
  1155.         (set_tile "error" errmsg)
  1156.         (setq errchk 1)
  1157.         (setq last-tile tile)
  1158.         old-value
  1159.       )
  1160.     )
  1161.   )
  1162.   ;;
  1163.   ;; Functions that verify tile values for integers
  1164.   ;;
  1165.   (defun ver_col (value)
  1166.     (setq columns (verify_i "columns" value columns))
  1167.   )
  1168.   (defun ver_row (value)
  1169.     (setq rows (verify_i "rows" value rows))
  1170.   )
  1171.   (defun ver_u (value)
  1172.     (setq u (verify_i "u" value u))
  1173.   )
  1174.   (defun ver_v (value)
  1175.     (setq v (verify_i "v" value v))
  1176.   )
  1177.   ;;
  1178.   ;; Functions that verify tile values for reals
  1179.   ;;
  1180.   (defun ver_x1 (value)
  1181.     (if (setq x1 (verify_d "x1_pt" value x1)) (calc))
  1182.   )
  1183.   (defun ver_y1 (value)
  1184.     (if (setq y1 (verify_d "y1_pt" value y1)) (calc))
  1185.   )
  1186.   (defun ver_z1 (value)
  1187.     (if (setq z1 (verify_d "z1_pt" value z1)) (calc))
  1188.   )
  1189.   (defun ver_x2 (value)
  1190.     (if (setq x2 (verify_d "x2_pt" value x2)) (calc))
  1191.   )
  1192.   (defun ver_y2 (value)
  1193.     (if (setq y2 (verify_d "y2_pt" value y2)) (calc))
  1194.   )
  1195.   (defun ver_z2 (value)
  1196.     (if (setq z2 (verify_d "z2_pt" value z2)) (calc))
  1197.   )
  1198.   (defun ver_x3 (value)
  1199.     (setq x3 (verify_d "x3_pt" value x3))
  1200.   )
  1201.   (defun ver_y3 (value)
  1202.     (setq y3 (verify_d "y3_pt" value y3))
  1203.   )
  1204.   (defun ver_z3 (value)
  1205.     (setq z3 (verify_d "z3_pt" value z3))
  1206.   )
  1207.   (defun ver_x4 (value)
  1208.     (setq x4 (verify_d "x4_pt" value x4))
  1209.   )
  1210.   (defun ver_y4 (value)
  1211.     (setq y4 (verify_d "y4_pt" value y4))
  1212.   )
  1213.   (defun ver_4 (value)
  1214.     (setq z4 (verify_d "z4_pt" value z4))
  1215.   )
  1216.   (defun ver_xscl (value)
  1217.     (setq xscale (verify_d "xscale" value xscale))
  1218.   )
  1219.   (defun ver_yscl (value)
  1220.     (setq yscale (verify_d "yscale" value yscale))
  1221.   )
  1222.   (defun ver_zscl (value)
  1223.     (setq zscale (verify_d "zscale" value zscale))
  1224.   )
  1225.   (defun ver_colsp (value)
  1226.     (setq col-sp (verify_d "col_sp" value col-sp))
  1227.   )
  1228.   (defun ver_rowsp (value)
  1229.     (setq row-sp (verify_d "row_sp" value row-sp))
  1230.   )
  1231.   (defun ver_rad (value)
  1232.     (if (setq radius (verify_d "radius" value radius))
  1233.       (calc)
  1234.     )
  1235.   )
  1236.   (defun ver_majrad (value)
  1237.     (if (setq majrad (verify_d "majrad" value majrad))
  1238.       (ell_calc_newval "majrad")
  1239.     )
  1240.   )
  1241.   (defun ver_minrad (value)
  1242.     (if (setq minrad (verify_d "minrad" value minrad))
  1243.       (ell_calc_newval "minrad")
  1244.     )
  1245.   )
  1246.   (defun ver_hght (value)
  1247.     (setq hght (verify_d "hght" value hght))
  1248.   )
  1249.   (defun ver_wid (value)
  1250.     (setq wid (verify_d "wid" value wid))
  1251.   )
  1252.   (defun ver_xline_x1 (value / temp)
  1253.     (setq temp xline_x1)
  1254.     (setq xline_x1 (verify_xline "xline_x1" value xline_x1))
  1255.     (if (/= temp xline_x1)
  1256.       (progn (modify_xline 0) (set_tile_dirv) ) 
  1257.     )
  1258.   )
  1259.   (defun ver_xline_y1 (value / temp)
  1260.     (setq temp xline_y1)
  1261.     (setq xline_y1 (verify_xline "xline_y1" value xline_y1))
  1262.     (if (/= temp xline_y1)
  1263.       (progn (modify_xline 0) (set_tile_dirv) ) 
  1264.     )
  1265.   )
  1266.   (defun ver_xline_z1 (value / temp)
  1267.     (setq temp xline_z1)
  1268.     (setq xline_z1 (verify_xline "xline_z1" value xline_z1))
  1269.     (if (/= temp xline_z1)
  1270.       (progn (modify_xline 0) (set_tile_dirv) ) 
  1271.     )
  1272.   )
  1273.   (defun ver_xline_x2 (value / temp)
  1274.     (setq temp xline_x2)
  1275.     (setq xline_x2 (verify_xline "xline_x2" value xline_x2)) 
  1276.     (if (/= temp xline_x2)
  1277.       (progn (modify_xline 0) (set_tile_dirv)) 
  1278.     )
  1279.   )
  1280.   (defun ver_xline_y2 (value / temp)
  1281.     (setq temp xline_y2)
  1282.     (setq xline_y2 (verify_xline "xline_y2" value xline_y2)) 
  1283.     (if (/= temp xline_y2)        
  1284.       (progn (modify_xline 0) (set_tile_dirv) )
  1285.     )
  1286.   )
  1287.   (defun ver_xline_z2 (value / temp)
  1288.     (setq temp xline_z2)
  1289.     (setq xline_z2 (verify_xline "xline_z2" value xline_z2))
  1290.     (if (/= temp xline_z2)
  1291.       (progn (modify_xline 0) (set_tile_dirv) ) 
  1292.     )
  1293.   )
  1294.   ;;
  1295.   ;; Functions that verify tile values for angles
  1296.   ;;
  1297.   (defun ver_ang1 (value)
  1298.     (if (setq st_ang (verify_a "st_ang" value st_ang))
  1299.       (calc)
  1300.     )
  1301.   )
  1302.   (defun ver_ang2 (value)
  1303.     (if (setq end_ang (verify_a "end_ang" value end_ang))
  1304.       (calc)
  1305.     )
  1306.   )
  1307.   ;;
  1308.   ;; Verify tile value for ellipse end angle. Handled slightly
  1309.   ;; differently than the other angles.
  1310.   ;;
  1311.   (defun ver_eang (value)
  1312.     (setq end_eang (verify_ae "end_eang" value end_eang))
  1313.   )
  1314.   (defun ver_rot (value)
  1315.     (setq rot (verify_a "rot" value rot))
  1316.   )
  1317.   (defun ver_obl (value)
  1318.     (setq obl (verify_a "obl" value obl))
  1319.   )
  1320.   ;;
  1321.   ;; Function that verifies attribute tag field for null string,
  1322.   ;; or a string that contains one or more spaces.  Tile value
  1323.   ;; is also converted to upper-case as well.
  1324.   ;;
  1325.   ;;
  1326.   (defun ver_tag (value / tval)
  1327.      (set_tile "error" "")
  1328.      (cond
  1329.         (  (or (eq "" (setq tval (strcase (ai_strtrim value))))
  1330.                (wcmatch tval "* *"))
  1331.            (set_tile "error" "Identificador de atributo no vßlido.")
  1332.            (mode_tile "tag" 2))
  1333.         (t (set_tile "error" "")
  1334.            (set_tile "tag" tval)
  1335.            (setq attag tval)))
  1336.   )
  1337.   ;;
  1338.   ;; Calculation functions
  1339.   ;;
  1340.   (defun calc ()
  1341.     (if (= etype "LINE") (line_calc))
  1342.     (if (= etype "ARC") (arc_calc))
  1343.     (if (= etype "CIRCLE") (cir_calc))
  1344.   )
  1345.   ;;
  1346.   ;; Calculation functions for lines, arcs, and circles
  1347.   ;;
  1348.   (defun line_calc ()
  1349.     (setq stpt  (list x1 y1 z1))
  1350.     (setq endpt (list x2 y2 z2))
  1351.     (set_tile "delta_x" (rtos (- x2 x1)))
  1352.     (set_tile "delta_y" (rtos (- y2 y1)))
  1353.     (set_tile "delta_z" (rtos (- z2 z1)))
  1354.     (set_tile "l_length" (rtos (distance stpt endpt)))
  1355.     (set_tile "l_angle" (angtos (angle stpt endpt)))
  1356.   )
  1357.  
  1358.   (defun cir_calc ()
  1359.         (setq radtest radius)
  1360.         (set_tile "Dia" (rtos (* 2 radius)))
  1361.         (set_tile "Circum" (rtos (* 2 pi radius)))
  1362.         (set_tile "Area" (rtos (* pi (* radius radius))))
  1363.   )
  1364.  
  1365.   (defun arc_calc ()
  1366.     (setq totang (- end_ang st_ang))
  1367.     (while (< totang 0)
  1368.       (setq totang (+ totang (* 2 pi)))
  1369.     )
  1370.     (while (> totang (* 2 pi))
  1371.       (setq totang (- totang (* 2 pi)))
  1372.     )
  1373.     (set_tile "tot_angle" (angtos totang))
  1374.     (setq arclen (* (* 2 pi radius) (/ totang (* 2 pi))))
  1375.     (set_tile "arclen" (rtos arclen))
  1376.   )
  1377.   ;;
  1378.   ;; Calculate the major radius, minor radius, major axis direction.
  1379.   ;; Get radius ratio. Convert Start, end parameters to start and end
  1380.   ;; angles. Save Major Radius value in "old_majrad" in case the user
  1381.   ;; chooses to input a new Major Radius value later. It's needed to
  1382.   ;; calculate a new Major Axis Vector value.
  1383.   ;;
  1384.   (defun ell_calc ()
  1385.         ;; Get major radius from the major axis vector.
  1386.         (setq majaxis (cdr (assoc 11 elist)))
  1387.         (setq xx (car majaxis))
  1388.         (setq yy (cadr majaxis))
  1389.         (setq zz (caddr majaxis))
  1390.         (setq majrad (sqrt (+ (* xx xx) (* yy yy) (* zz zz) )))
  1391.         (set_tile "majrad" (ai_rtos majrad))
  1392.         (setq old_majrad majrad)
  1393.         ;; Get radius ratio
  1394.         (setq rrat (cdr (assoc 40 elist)))
  1395.         (set_tile "rratio" (rtos rrat))
  1396.         ;; Calculate minor radius
  1397.         (setq minrad (* majrad rrat))
  1398.         (set_tile "minrad" (ai_rtos minrad))
  1399.         ;; display major axis vector
  1400.         (set_tile "Majraddirx" (rtos xx))
  1401.         (set_tile "Majraddiry" (rtos yy))
  1402.         (set_tile "Majraddirz" (rtos zz))
  1403.  
  1404.         ;; Convert start parm to start angle
  1405.         (setq stparm (cdr (assoc 41 elist)))
  1406.         (setq vecx (cos stparm))
  1407.         (setq vecy (sin stparm))
  1408.         (setq st_ang (atan (* rrat vecy) vecx))
  1409.         (setq tempst_ang (ai_angtos st_ang))
  1410.         (set_tile "st_ang" tempst_ang)
  1411.         ;; Convert end parm to end angle. If end angle evaluates to 0
  1412.         ;; degrees then display it as 360 degrees.
  1413.         (setq endparm (cdr (assoc 42 elist)))
  1414.         (setq evecx (cos endparm))
  1415.         (setq evecy (sin endparm))
  1416.         (setq end_eang (atan (* rrat evecy) evecx))
  1417.         (setq tempend_eang (ai_angtos end_eang))
  1418.         (if (= tempend_eang "0")
  1419.             (set_tile "end_eang" "360")
  1420.             (set_tile "end_eang" tempend_eang)
  1421.         )
  1422.         ;; Get area of the ellipse.
  1423.         (ell_calc_area)
  1424.   )
  1425.   ;; Calculate area of ellipse. If it is an arc then
  1426.   ;; grey out area display.
  1427.   ;; 
  1428.   (defun ell_calc_area ()
  1429.      (if (and (= tempst_ang "0") (= tempend_eang "0"))
  1430.          (set_tile "Area" (rtos (* pi majrad minrad)))
  1431.          (mode_tile "Area_text" 1)
  1432.      )
  1433.   )
  1434.   ;;
  1435.   ;; Calculate new values for ELLIPSE
  1436.   ;; Minor Radius, Area
  1437.   ;;
  1438.   (defun ell_calc_newval (ell_tile)
  1439.     (if (= ell_tile "majrad")
  1440.       (progn
  1441.          (setq rrat (/ minrad majrad))
  1442.          (set_tile "rratio" (rtos rrat))
  1443.          (ell_calc_area)
  1444.       )
  1445.     )
  1446.     (if (= ell_tile "minrad")
  1447.       (progn
  1448.          (setq rrat (/ minrad majrad))
  1449.          (set_tile "rratio" (rtos rrat))
  1450.          (ell_calc_area)
  1451.       )
  1452.     )
  1453.   )
  1454.   (defun set_dimen_props (/ loop a stl txstyname)
  1455.  
  1456.     (setq stname (cdr (assoc 3 elist)))   ; get style name
  1457.  
  1458.     ; Get all style names and list them in alphabetical order
  1459.     (setq stl (cdr (assoc 2 (tblnext "DIMSTYLE" T))))
  1460.     (while (not (null stl))
  1461.        (setq stlist (append stlist (list stl)))
  1462.        (setq stl (cdr (assoc 2 (tblnext "DIMSTYLE"))))
  1463.     )
  1464.     (setq stlist (acad_strlsort stlist))
  1465.     (setq len (length stlist))
  1466.     (setq loop 0)
  1467.     (setq dimsty stname)
  1468.     ; Show the styles in combo box
  1469.     (start_list "mod_style" 2)
  1470.     (while (< loop len)
  1471.       (add_list (nth loop stlist))
  1472.       (setq loop (1+ loop))
  1473.     )
  1474.  
  1475.     (end_list)
  1476.  
  1477.     ; Hilight the style name of the selected entity
  1478.     (while (and (< 0 loop) (/= stname (nth loop stlist)))
  1479.       (setq loop (1- loop))
  1480.     )
  1481.     (set_tile "mod_style" (itoa loop))
  1482.  
  1483.     ; The following is the list dimvars. It must be sorted in the same 
  1484.     ; order as the resfub returned from DDIM (ADS module).
  1485.  
  1486.     (setq dimtbl (list "DIMSTYLE"  "Style name"  "Standard flag values"
  1487.         "dimpost"   "dimapost"    "dimblk"    "dimblk1"    "dimblk2"
  1488.         "dimscale"  "dimasz"      "dimexo"    "dimdli"     "dimexe"
  1489.         "dimrnd"    "dimdle"      "dimtp"     "dimtm"      "dimtxt"
  1490.         "dimcen"    "dimtsz"      "dimaltf"   "dimlfac"    "dimtvp"
  1491.         "dimtfac"   "dimgap"      "dimtol"    "dimlim"     "dimtih"
  1492.         "dimtoh"    "dimse1"      "dimse2"    "dimtad"     "dimzin"
  1493.         "dimalt"    "dimaltd"     "dimtofl"   "dimsah"     "dimtix"
  1494.         "dimsoxd"   "dimclrd"     "dimclre"   "dimclrt"    "dimunit"
  1495.         "dimdec"    "dimtdec"     "dimaltu"   "dimalttd"   
  1496.         "dimaunit"  "dimjust"     "dimsd1"    "dimsd2"     "dimtolj"
  1497.         "dimtzin"   "dimaltz"     "dimalttz"  "dimfit"     "dimupt"
  1498.         "dimtxsty"
  1499.     )) 
  1500.  
  1501.     (setq sv_dvlist (ddimen_getostate dimsty)
  1502.           txstyname (assoc 340 sv_dvlist) 
  1503.           sv_dvlist (subst (cons 340 (tblobjname "STYLE" (cdr txstyname)))
  1504.                             txstyname sv_dvlist) 
  1505.           dimlist sv_dvlist
  1506.     )
  1507.     (action_tile "mod_style" "(setq dimsty (ddimen_style))")
  1508.     (action_tile "mod_text"  "(done_dialog 4)")
  1509.     (action_tile "mod_geom" "(setq dimlist (ddimen_dlg dimtype 11 dimsty dimlist))")
  1510.     (action_tile "mod_format" "(setq dimlist (ddimen_dlg dimtype 12 dimsty dimlist))")
  1511.     (action_tile "mod_annot" "(setq dimlist (ddimen_dlg dimtype 13 dimsty dimlist))")
  1512.     (action_tile "accept" "(done_dialog 1)")
  1513.   )
  1514.   ;;
  1515.   ;; Get dimvars 
  1516.   ;;
  1517.   (defun ddimen_getvars (/ elm dvlist dv i)
  1518.     (setq i 3 
  1519.           dvlist (list (cons 0 "") (cons 2 (getvar "dimstyle")) (cons 70 ""))
  1520.     )
  1521.     (while (setq dv (nth i dimtbl))
  1522.       (progn
  1523.         (setq elm (getvar dv))
  1524.         (setq dvlist (append dvlist (list (cons dv elm)))
  1525.               i (1+ i)
  1526.         )
  1527.       )
  1528.     )
  1529.     dvlist
  1530.   )
  1531.  
  1532.   ;;
  1533.   ;; Get the original states of dimvars.
  1534.   ;; 
  1535.   (defun ddimen_getostate (dimsty / dvlist elm i dvvars)
  1536.     (setq dvlist (tblsearch "dimstyle" dimsty) ; Get list for that style
  1537.           dvvars (ddimen_getvars)              ; Get dimvars for that entity
  1538.           i 1
  1539.     )
  1540.  
  1541.     ; Create a list that contains values of the selected entity.
  1542.  
  1543.     (while (setq elm (nth i dvlist))
  1544.       (if (/= i 2)
  1545.         (setq dvlist (subst (cons (car elm) (cdr (nth i dvvars))) elm dvlist))
  1546.       )
  1547.       (setq i (1+ i))
  1548.     )
  1549.     dvlist
  1550.   )
  1551.   
  1552.   ;;
  1553.   ;; Restores dimvars of the selected enity.
  1554.   ;;
  1555.   (defun ddimen_dimsty_restore(/ dimtbl dimsvcurset en)
  1556.     (setq dimtbl (list "DIMSTYLE"  "Style name"  "Standard flag values"
  1557.         "dimpost"   "dimapost"    "dimblk"    "dimblk1"    "dimblk2"
  1558.         "dimscale"  "dimasz"      "dimexo"    "dimdli"     "dimexe"
  1559.         "dimrnd"    "dimdle"      "dimtp"     "dimtm"      "dimtxt"
  1560.         "dimcen"    "dimtsz"      "dimaltf"   "dimlfac"    "dimtvp"
  1561.         "dimtfac"   "dimgap"      "dimtol"    "dimlim"     "dimtih"
  1562.         "dimtoh"    "dimse1"      "dimse2"    "dimtad"     "dimzin"
  1563.         "dimalt"    "dimaltd"     "dimtofl"   "dimsah"     "dimtix"
  1564.         "dimsoxd"   "dimclrd"     "dimclre"   "dimclrt"    "dimunit"
  1565.         "dimdec"    "dimtdec"     "dimaltu"   "dimalttd"   
  1566.         "dimaunit"  "dimjust"     "dimsd1"    "dimsd2"     "dimtolj"
  1567.         "dimtzin"   "dimaltz"     "dimalttz"  "dimfit"     "dimupt"
  1568.         "dimtxsty"
  1569.     )) 
  1570.     (setq dimsvcurset (ddimen_getvars))  ; Save current variable settings
  1571.     (if (= (cdr (assoc 0 elist)) "DIMENSION")
  1572.       (progn
  1573.         (setq en (cdr (assoc -1 elist)))
  1574.         (command "_.dimstyle" "" "" en)
  1575.       )
  1576.     )
  1577.     dimsvcurset
  1578.   )
  1579.   ;;
  1580.   ;; Modify Leader
  1581.   ;;
  1582.   (defun ddleader (/ dtypebit blkname bename sublist a  stname n dimtbl
  1583.                    dimsty dimlist dimtext svtext dimovr sv_dvlist stlist 
  1584.                    dimtype dimsvcurset r12)
  1585.     (setq dimtype "DDLEADER" 
  1586.           dimsvcurset (ddimen_dimsty_restore)
  1587.     )
  1588.     (setq r12 (ddimen_apnd_stname))
  1589.     (if (not (new_dialog "ddleader" dcl_id)) (exit))
  1590.     ;; Set initial tile values
  1591.     (set_tile_props)
  1592.     (set_dimen_props)
  1593.     (set_tile_handle)
  1594.     ;; Define action for tiles
  1595.     (set_action_tiles)
  1596.     (mode_tile "mod_text" 1)
  1597.  
  1598.     (action_tile "mod_style" "(setq dimsty (ddimen_style))")
  1599.     (action_tile "accept" "(setq leadtype (get_tile \"s-s\"))(setq arrow (get_tile \"arrow\"))(done_dialog 1)")
  1600.     ;; Get ARROW and TYPE.
  1601.     (if (= 1 (logand (cdr (assoc '71 elist)))) (set_tile "arrow" "1"))
  1602.     (if (= 1 (logand (cdr (assoc '72 elist)))) 
  1603.       (set_tile "s-s" "spline")
  1604.       (set_tile "s-s" "straight")
  1605.     )
  1606.     ;; Start the dialogue.
  1607.     (setq dialog-state (start_dialog))
  1608.     (if (= dialog-state 0)
  1609.       (progn 
  1610.         (reset)
  1611.       )
  1612.     )
  1613.     (if (= dialog-state 1)
  1614.       (progn
  1615.         (if (not (null dimlist))   ; attempted to change dimvars
  1616.             (ddimen_complist sv_dvlist dimlist dimtbl r12)
  1617.         )
  1618.         ;; update the style
  1619.         (if (/= dimsty stname)
  1620.           (setq elist (subst (cons 3 dimsty) (assoc 3 elist) elist))
  1621.         )
  1622.         ;; update for ARROW.
  1623.         (if (= "1" arrow)
  1624.           (setq elist (subst (cons 71 (logior 1 (cdr (assoc 71 elist)))) (assoc 71 elist) elist))
  1625.           (setq elist (subst (cons 71 (logand (~ 1) (cdr (assoc 71 elist)))) (assoc 71 elist) elist))
  1626.         )                                                                
  1627.         ;; update the TYPE.
  1628.         (if (= "spline" leadtype)
  1629.           (setq elist (subst (cons 72 (logior 1 (cdr (assoc 72 elist)))) (assoc 72 elist) elist))
  1630.           (setq elist (subst (cons 72 (logand (~ 1) (cdr (assoc 72 elist)))) (assoc 72 elist) elist))
  1631.         )     
  1632.         (modify_prop_geom)
  1633.         (entmod elist)
  1634.       )
  1635.     )
  1636.     (ddimen_setvars dimsvcurset)      ; Prepare to exit
  1637.   )
  1638.  
  1639.   ;;
  1640.   ;; Modify POINT
  1641.   ;;
  1642.   (defun modify_point ()
  1643.     (modify_properties)
  1644.     (setq pt1 (list x1 y1 z1))
  1645.     (tempmod pt1 10 0)
  1646.     (entmod elist)
  1647.   )
  1648.  
  1649.   (defun ddpoint ()
  1650.     (if (not (new_dialog "ddpoint" dcl_id)) (exit))
  1651.     ;; Set initial tile values
  1652.     (set_tile_props)
  1653.     (set_tile_handle)
  1654.     (set_tile_pt1 0)
  1655.     ;; Define action for tiles
  1656.     (set_action_tiles)
  1657.     (setq dialog-state (start_dialog))
  1658.     (if (= dialog-state 0)
  1659.       (reset)
  1660.     )
  1661.     (if (= dialog-state 3)
  1662.       (progn
  1663.         (modify_point)
  1664.         (setq pt1 (getpoint (list x1 y1 z1)  "\nPunto: "))
  1665.         (ver_pt1 0)
  1666.         (ddpoint)
  1667.       )
  1668.     )
  1669.     (if (= dialog-state 1)
  1670.       (modify_point)
  1671.     )
  1672.   )
  1673.   ;;
  1674.   ;; Modify LINE 
  1675.   ;;
  1676.   (defun modify_line ()
  1677.     (modify_properties)
  1678.     (setq pt1 (list x1 y1 z1))
  1679.     (setq pt2 (list x2 y2 z2))
  1680.     (tempmod pt1 10 0)
  1681.     (tempmod pt2 11 0)
  1682.     (entmod elist)
  1683.   )
  1684.   (defun ddline ()
  1685.     (if (not (new_dialog "ddline" dcl_id)) (exit))
  1686.     ;; Set initial tile values
  1687.     (set_tile_props)
  1688.     (set_tile_handle)
  1689.     (set_tile_pt1 0)
  1690.     (set_tile_pt2 0)
  1691.     (line_calc)
  1692.     ;; Define action for tiles
  1693.     (set_action_tiles)
  1694.     (setq dialog-state (start_dialog))
  1695.     (if (= dialog-state 0)
  1696.       (reset)
  1697.     )
  1698.     (if (= dialog-state 3)
  1699.       (progn
  1700.         (modify_line)
  1701.         (setq pt1 (getpoint (list x1 y1 z1)  "\nDesde el punto: "))
  1702.         (ver_pt1 0)
  1703.         (ddline)
  1704.       )
  1705.     )
  1706.     (if (= dialog-state 4)
  1707.       (progn
  1708.         (modify_line)
  1709.         (setq pt2 (getpoint (list x2 y2 z2) "\nAl punto: "))
  1710.         (ver_pt2 0)
  1711.         (ddline)
  1712.       )
  1713.     )
  1714.     (if (= dialog-state 1)
  1715.       (modify_line)
  1716.     )
  1717.   )
  1718.   ;;
  1719.   ;; Modify MLine
  1720.   ;;
  1721.   (defun modify_mline ()
  1722.     (modify_properties)
  1723.     (entmod elist)
  1724.   )
  1725.   (defun ddmline ()
  1726.     (if (not (new_dialog "ddmline" dcl_id)) (exit))
  1727.     ;; Set initial tile values
  1728.     (set_tile_props)
  1729.     (set_tile_handle)
  1730.     ;; Set mline style text field.
  1731.     (set_tile "ml_style" (cdr (assoc '2 elist)))
  1732.  
  1733.     ;; Define action for tiles
  1734.     (set_action_tiles)
  1735.     (action_tile "ml_edit" "(done_dialog 3)")
  1736.     (setq dialog-state (start_dialog))
  1737.     ;; Dialog cancelled, reset to original values.
  1738.     (if (= dialog-state 0)
  1739.       (reset)
  1740.     )
  1741.     ;; Dialog OKed, update the mline.
  1742.     (if (= dialog-state 1)
  1743.       (modify_mline)
  1744.     )
  1745.     ;; Edit Mline, call MLEDIT.
  1746.     (if (= dialog-state 3)
  1747.       (progn
  1748.         (modify_mline)
  1749.         (command "_mledit")
  1750.         (ddmline)
  1751.       )
  1752.     )
  1753.   )
  1754.   ;;
  1755.   ;; Modify Xline 
  1756.   ;;
  1757.   (defun modify_xline (flag)
  1758.     (modify_prop_geom)
  1759.     (setq xline_pt1 (list xline_x1 xline_y1 xline_z1))
  1760.     (setq xline_pt2 (list xline_x2 xline_y2 xline_z2))
  1761.     ;; Update the Root point.
  1762.     (setq elist (subst (cons 10 (trans xline_pt1 1 0))
  1763.                        (assoc 10 elist)
  1764.                        elist
  1765.                 )
  1766.     )
  1767.     ;; 
  1768.     ;; Calculate new Direction Vector WCS
  1769.     ;; x / (sqrt ( (x**2) + (y**2) + (z**2)    ))
  1770.  
  1771.     (setq temp_dir (trans xline_pt2 1 0))
  1772.     (setq temp_dir_x (car temp_dir))
  1773.     (setq temp_dir_y (cadr temp_dir))
  1774.     (setq temp_dir_z (caddr temp_dir))
  1775.  
  1776.     (setq temp_xline_pt1 (trans xline_pt1 1 0))
  1777.     (setq temp_xline_x1 (car temp_xline_pt1))
  1778.     (setq temp_xline_y1 (cadr temp_xline_pt1))
  1779.     (setq temp_xline_z1 (caddr temp_xline_pt1))
  1780.  
  1781.     (setq denom (sqrt (+ (expt (- temp_dir_x temp_xline_x1) 2)
  1782.                          (expt (- temp_dir_y temp_xline_y1) 2)
  1783.                          (expt (- temp_dir_z temp_xline_z1) 2)
  1784.     )))
  1785.     (setq temp_dir_x (/ (- temp_dir_x temp_xline_x1) denom))
  1786.     (setq temp_dir_y (/ (- temp_dir_y temp_xline_y1) denom))
  1787.     (setq temp_dir_z (/ (- temp_dir_z temp_xline_z1) denom))
  1788.     (setq elist (subst (cons 11 (list temp_dir_x temp_dir_y temp_dir_z))
  1789.                        (assoc 11 elist)
  1790.                        elist
  1791.                 )
  1792.     )        
  1793.     (if (= 1 flag)
  1794.       (entmod elist)
  1795.     )
  1796.   )
  1797.  
  1798.   (defun ddxline ()
  1799.     (if (= etype "XLINE")
  1800.       (if (not (new_dialog "ddxline" dcl_id)) (exit))
  1801.       (if (not (new_dialog "ddray" dcl_id)) (exit))
  1802.     )
  1803.     ;; Set initial tile values
  1804.     (set_tile_props)
  1805.     (set_tile_handle)
  1806.     (set_tile_xline_pt1)
  1807.     ;; Convert to UCS and post Direction vector.
  1808.     (set_tile_dirv)
  1809.     ;; Calculate second point by adding Root Point + Direction Vector.
  1810.     (set_tile_xline_pt2)
  1811.     ;; Define action for tiles
  1812.     (set_action_tiles)
  1813.     (setq dialog-state (start_dialog))
  1814.     (if (= dialog-state 0)
  1815.       (reset)
  1816.     )
  1817.     (if (= dialog-state 3)
  1818.       (progn
  1819.         (modify_xline 1)
  1820.         (while (equal xline_pt2
  1821.           (setq xline_pt1 (getpoint xline_pt2 "\nPunto raφz: ")) 0.000001)
  1822.           (princ "El punto raφz no puede ser igual al segundo punto.")
  1823.         )
  1824.         (ver_xline_pt1)
  1825.         (ver_xline_pt2)
  1826. (princ)
  1827.         (ddxline)
  1828.       )
  1829.     )
  1830.     (if (= dialog-state 4)
  1831.       (progn
  1832.         (modify_xline 1)
  1833.         (while (equal xline_pt1
  1834.           (setq xline_pt2 (getpoint xline_pt1 "\nSegundo punto: ")) 0.000001)
  1835.           (princ "El segundo punto no puede ser igual al punto raφz.")
  1836.         )
  1837.         (ver_xline_pt2)
  1838. (princ)
  1839.         (ddxline)
  1840.       )
  1841.     )
  1842.     (if (= dialog-state 1)
  1843.       (modify_xline 1)
  1844.     )
  1845.   )
  1846.   ;; 
  1847.   ;; Modify ELLIPSE
  1848.   ;;
  1849.   (defun modify_ellipse ()
  1850.     (modify_prop_geom)
  1851.     ;; Update Ellipse Center Point value.
  1852.     (setq pt1 (list x1 y1 z1))
  1853.     (tempmod pt1 10 1)
  1854.     ;; Update Start Parameter value.
  1855.     (setq y_val (sin st_ang))
  1856.     (setq x_val (* rrat (cos st_ang)))
  1857.     (setq stparm (atan y_val x_val))
  1858.     (setq elist (subst (cons 41 stparm) (assoc 41 elist) elist ))
  1859.     ;; Update End Parameter value. Normalize it, if it's less than
  1860.     ;; the start parameter.
  1861.     (setq y_eval (sin end_eang))
  1862.     (setq x_eval (* rrat (cos end_eang)))
  1863.     (setq endparm (atan y_eval x_eval))
  1864.     (setq diffparm (- endparm stparm))
  1865.     ;; Epsilon of 1.0e-6 radians for checking a zero length arc.
  1866.     ;; Since zero length arcs are not allowed - construct the full
  1867.     ;; ellipse in this case.
  1868.     (if (<= (* diffparm diffparm) 1.0e-12)
  1869.         (setq endparm (+ stparm (* 2 pi)))
  1870.     )
  1871.     (if (<= endparm stparm)
  1872.         (setq endparm (+ endparm (* 2 pi)))
  1873.     )
  1874.     (setq elist (subst (cons 42 endparm) (assoc 42 elist) elist ))
  1875.     ;; Calculate the Major Axis Vector by first calculating
  1876.     ;; a unit vector using the old Major Radius value. Then
  1877.     ;; Multiplying that by the (possibly) new Major Radius
  1878.     ;; value to get the new Major Axis Vector value.
  1879.     (setq unitxx (/ xx old_majrad))
  1880.     (setq unityy (/ yy old_majrad))
  1881.     (setq unitzz (/ zz old_majrad))
  1882.     (setq newvecxx (* unitxx majrad))
  1883.     (setq newvecyy (* unityy majrad))
  1884.     (setq newveczz (* unitzz majrad))
  1885.     (setq newmajaxis (list newvecxx newvecyy newveczz))
  1886.     ;; Update Major Axis Vector value
  1887.     (setq elist (subst (cons 11 newmajaxis) (assoc 11 elist) elist ))
  1888.     ;; Update Radius Ratio value
  1889.     (setq elist (subst (cons 40 rrat) (assoc 40 elist) elist ))
  1890.     (entmod elist)
  1891.   )
  1892.  
  1893.   (defun ddellipse ()
  1894.     (if (not (new_dialog "ddellipse" dcl_id)) (exit))
  1895.     ;; Set initial tile values
  1896.     (set_tile_props)
  1897.     (set_tile_handle)
  1898.     (set_tile_pt1 1)
  1899.     (ell_calc)
  1900.     ;; Define action for tiles
  1901.     (set_action_tiles)
  1902.     (setq dialog-state (start_dialog))
  1903.     (if (= dialog-state 0)
  1904.       (reset)
  1905.     )
  1906.     (if (= dialog-state 1)
  1907.       (modify_ellipse)
  1908.     )
  1909.     (if (= dialog-state 3)
  1910.       (progn
  1911.         (modify_ellipse)
  1912.         (setq pt1 (getpoint (list x1 y1 z1)  "\nCentro: "))
  1913.         (ver_pt1 1)
  1914.         (ddellipse)
  1915.       )
  1916.     )
  1917.   )
  1918.   ;;
  1919.   ;; Modify REGION
  1920.   ;;
  1921.   (defun modify_region ()
  1922.     (modify_prop_geom)
  1923.     (entmod elist)
  1924.   )
  1925.  
  1926.   (defun ddregion ()
  1927.     (if (not (new_dialog "ddregion" dcl_id)) (exit))
  1928.     ;; Set initial tile values
  1929.     (set_tile_props)
  1930.     (set_tile_handle)
  1931.     ;; Define action for tiles
  1932.     (set_action_tiles)
  1933.     (setq dialog-state (start_dialog))
  1934.     (if (= dialog-state 0)
  1935.       (reset)
  1936.     )
  1937.     (if (= dialog-state 1)
  1938.       (modify_region)
  1939.     )
  1940.   )
  1941.   ;;
  1942.   ;; Modify 3DSOLID
  1943.   ;;
  1944.   (defun modify_3dsolid ()
  1945.     (modify_prop_geom)
  1946.     (entmod elist)
  1947.   )
  1948.  
  1949.   (defun dd3dsolid ()
  1950.     (if (not (new_dialog "dd3dsolid" dcl_id)) (exit))
  1951.     ;; Set initial tile values
  1952.     (set_tile_props)
  1953.     (set_tile_handle)
  1954.     ;; Define action for tiles
  1955.     (set_action_tiles)
  1956.     (setq dialog-state (start_dialog))
  1957.     (if (= dialog-state 0)
  1958.       (reset)
  1959.     )
  1960.     (if (= dialog-state 1)
  1961.       (modify_3dsolid)
  1962.     )
  1963.   )
  1964.   ;;
  1965.   ;; Modify BODY
  1966.   ;;
  1967.   (defun modify_body ()
  1968.     (modify_prop_geom)
  1969.     (entmod elist)
  1970.   )
  1971.  
  1972.   (defun ddbody ()
  1973.     (if (not (new_dialog "ddbody" dcl_id)) (exit))
  1974.     ;; Set initial tile values
  1975.     (set_tile_props)
  1976.     (set_tile_handle)
  1977.     ;; Define action for tiles
  1978.     (set_action_tiles)
  1979.     (setq dialog-state (start_dialog))
  1980.     (if (= dialog-state 0)
  1981.       (reset)
  1982.     )
  1983.     (if (= dialog-state 1)
  1984.       (modify_body)
  1985.     )
  1986.   )
  1987.   ;;
  1988.   ;; Modify CIRCLE
  1989.   ;;
  1990.   (defun modify_circle ()
  1991.     (modify_properties)
  1992.     (setq pt1 (list x1 y1 z1))
  1993.     (tempmod pt1 10 1)
  1994.     (tempmod radius 40 nil)
  1995.     (entmod elist)
  1996.   )
  1997.  
  1998.   (defun ddcircle ()
  1999.     (if (not (new_dialog "ddcircle" dcl_id)) (exit))
  2000.     ;; Set initial tile values
  2001.     (set_tile_props)
  2002.     (set_tile_handle)
  2003.     (set_tile_pt1 1)
  2004.     (set_tile_rad)
  2005.     (cir_calc)
  2006.     ;; Define action for tiles
  2007.     (set_action_tiles)
  2008.     (set_tile_pt1 1)
  2009.     (setq dialog-state (start_dialog))
  2010.     (if (= dialog-state 0)
  2011.       (reset)
  2012.     )
  2013.     (if (= dialog-state 1)
  2014.       (modify_circle)
  2015.     )
  2016.     (if (= dialog-state 3)
  2017.       (progn
  2018.         (modify_circle)
  2019.         (setq pt1 (getpoint (list x1 y1 z1)  "\nCentro: "))
  2020.         (ver_pt1 1)
  2021.         (ddcircle)
  2022.       )
  2023.     )
  2024.   )
  2025.   ;;
  2026.   ;; Modify ARC
  2027.   ;;
  2028.   (defun modify_arc ()
  2029.     (modify_properties)
  2030.     (setq pt1 (list x1 y1 z1))
  2031.     (tempmod pt1 10 1)
  2032.     (tempmod radius 40 nil)
  2033.     (tempmod st_ang 50 nil)
  2034.     (tempmod end_ang 51 nil)
  2035.     (entmod elist)
  2036.   )
  2037.   (defun ddarc ()
  2038.     (if (not (new_dialog "ddarc" dcl_id)) (exit))
  2039.     ;; Set initial tile values
  2040.     (set_tile_props)
  2041.     (set_tile_handle)
  2042.     (set_tile_pt1 1)
  2043.     (set_tile_rad)
  2044.     (set_tile_stang)
  2045.     (set_tile_endang)
  2046.     (arc_calc)
  2047.     ;; Define action for tiles
  2048.     (set_action_tiles)
  2049.     (setq dialog-state (start_dialog))
  2050.     (if (= dialog-state 0)
  2051.       (reset)
  2052.     )
  2053.     (if (= dialog-state 1)
  2054.       (modify_arc)
  2055.     )
  2056.     (if (= dialog-state 3)
  2057.       (progn
  2058.         (modify_arc)
  2059.         (setq pt1 (getpoint (list x1 y1 z1) "\nCentro: "))
  2060.         (ver_pt1 1)
  2061.         (ddarc)
  2062.       )
  2063.     )
  2064.   )
  2065.   ;;
  2066.   ;; Modify SOLID or TRACE
  2067.   ;; Note the Z value of the object is determined by the Z value of the fourth
  2068.   ;; point - code 13.  Changing the point values of a solid or trace from a UCS
  2069.   ;; that is nonplanar to the UCS the object was created may confuse the user.
  2070.   (defun modify_solid ()
  2071.     (modify_properties)
  2072.     (setq pt1 (list x1 y1 z1))
  2073.     (setq pt2 (list x2 y2 z2))
  2074.     (setq pt3 (list x3 y3 z3))
  2075.     (setq pt4 (list x4 y4 z4))
  2076.     (tempmod pt1 10 1)
  2077.     (tempmod pt2 11 1)
  2078.     (tempmod pt3 12 1)
  2079.     (tempmod pt4 13 1)
  2080.     (entmod elist)
  2081.   )
  2082.  
  2083.   (defun ddsolid ()
  2084.     (if (= etype "SOLID")
  2085.         (if (not (new_dialog "ddsolid" dcl_id)) (exit))
  2086.         (if (not (new_dialog "ddtrace" dcl_id)) (exit))
  2087.     )
  2088.     ;; Set initial tile values
  2089.     (set_tile_props)
  2090.     (set_tile_handle)
  2091.     (set_tile_pt1 1)
  2092.     (set_tile_pt2 1)
  2093.     (set_tile_pt3 1)
  2094.     (set_tile_pt4 1)
  2095.     ;; Define action for tiles
  2096.     (set_action_tiles)
  2097.     (setq dialog-state (start_dialog))
  2098.     (if (= dialog-state 0)
  2099.       (reset)
  2100.     )
  2101.     (if (= dialog-state 1)
  2102.       (modify_solid)
  2103.     )
  2104.     (if (= dialog-state 3)
  2105.       (progn
  2106.         (modify_solid)
  2107.         (setq pt1 (getpoint (list x1 y1 z1) "\nPrimer punto: "))
  2108.         (ver_pt1 1)
  2109.         (ddsolid)
  2110.       )
  2111.     )
  2112.     (if (= dialog-state 4)
  2113.       (progn
  2114.         (modify_solid)
  2115.         (entmod elist)
  2116.         (setq pt2 (getpoint (list x2 y2 z2) "\nSegundo punto: "))
  2117.         (ver_pt2 1)
  2118.         (ddsolid)
  2119.       )
  2120.     )
  2121.     (if (= dialog-state 5)
  2122.       (progn
  2123.         (modify_solid)
  2124.         (setq pt3 (getpoint (list x3 y3 z3) "\nTercer punto: "))
  2125.         (ver_pt3 1)
  2126.         (ddsolid)
  2127.       )
  2128.     )
  2129.     (if (= dialog-state 6)
  2130.       (progn
  2131.         (modify_solid)
  2132.         (setq pt4 (getpoint (list x4 y4 z4) "\nCuarto punto: "))
  2133.         (ver_pt4 1)
  2134.         (ddsolid)
  2135.       )
  2136.     )
  2137.   )
  2138.   ;;
  2139.   ;; Modify 3DFACE
  2140.   ;;
  2141.   ;; Check visibility of edges
  2142.   ;;
  2143.   (defun edgetest (/ bit1 bit2 bit3 bit4)
  2144.     (if (= edge1 "1") (setq bit1 0) (setq bit1 1))
  2145.     (if (= edge2 "1") (setq bit2 0) (setq bit2 2))
  2146.     (if (= edge3 "1") (setq bit3 0) (setq bit3 4))
  2147.     (if (= edge4 "1") (setq bit4 0) (setq bit4 8))
  2148.     (+ bit1 bit2 bit3 bit4)
  2149.   )
  2150.  
  2151.   (defun modify_3dface ()
  2152.     (modify_properties)
  2153.     (setq pt1 (list x1 y1 z1))
  2154.     (setq pt2 (list x2 y2 z2))
  2155.     (setq pt3 (list x3 y3 z3))
  2156.     (setq pt4 (list x4 y4 z4))
  2157.     (tempmod pt1 10 0)
  2158.     (tempmod pt2 11 0)
  2159.     (tempmod pt3 12 0)
  2160.     (tempmod pt4 13 0)
  2161.     (tempmod (edgetest) 70 nil)
  2162.     (entmod elist)
  2163.   )
  2164.  
  2165.   (defun dd3dface ()
  2166.     (if (not (new_dialog "dd3dface" dcl_id)) (exit))
  2167.     (set_tile_props)
  2168.     (set_tile_handle)
  2169.     (set_tile_pt1 0)
  2170.     (set_tile_pt2 0)
  2171.     (set_tile_pt3 0)
  2172.     (set_tile_pt4 0)
  2173.     (set_tile_edges)
  2174.     ;; Define action for tiles
  2175.     (set_action_tiles)
  2176.     (setq dialog-state (start_dialog))
  2177.     (if (= dialog-state 0)
  2178.       (reset)
  2179.     )
  2180.     (if (= dialog-state 1)
  2181.       (modify_3dface)
  2182.     )
  2183.     (if (= dialog-state 3)
  2184.       (progn
  2185.         (modify_3dface)
  2186.         (setq pt1 (getpoint (list x1 y1 z1) "\nPrimer pto.: "))
  2187.         (ver_pt1 0)
  2188.         (dd3dface)
  2189.       )
  2190.     )
  2191.     (if (= dialog-state 4)
  2192.       (progn
  2193.         (modify_3dface)
  2194.         (setq pt2 (getpoint (list x2 y2 z2) "\nSegundo punto: "))
  2195.         (ver_pt2 0)
  2196.         (dd3dface)
  2197.       )
  2198.     )
  2199.     (if (= dialog-state 5)
  2200.       (progn
  2201.         (modify_3dface)
  2202.         (setq pt3 (getpoint (list x3 y3 z3) "\nTercer punto: "))
  2203.         (ver_pt3 0)
  2204.         (dd3dface)
  2205.       )
  2206.     )
  2207.     (if (= dialog-state 6)
  2208.       (progn
  2209.         (modify_3dface)
  2210.         (setq pt4 (getpoint (list x4 y4 z4) "\nCuarto punto: "))
  2211.         (ver_pt4 0)
  2212.         (dd3dface)
  2213.       )
  2214.     )
  2215.   )
  2216.   ;;
  2217.   ;; Modify BLOCK
  2218.   ;;
  2219.   (defun modify_block ()
  2220.     (modify_properties)
  2221.     (setq pt1 (list x1 y1 z1))
  2222.     (tempmod xscale 41 nil)
  2223.     (tempmod yscale 42 nil)
  2224.     (tempmod zscale 43 nil)
  2225.     (tempmod col-sp 44 nil)
  2226.     (tempmod row-sp 45 nil)
  2227.     (tempmod rot 50 nil)
  2228.     (tempmod columns 70 nil)
  2229.     (tempmod rows 71 nil)
  2230.     (entmod elist)
  2231.     (move_pt1 1)   
  2232.     (setq elist (entget ename))
  2233.   )
  2234.  
  2235.   (defun ddblock (/ temp)
  2236.     (setq blkname (cdr (assoc 2 elist)))
  2237.     (setq blklist (tblsearch "block" blkname))
  2238.     (setq blktype (cdr (assoc 70 blklist)))
  2239.     (if (= (logand blktype 4) 4)
  2240.       (progn
  2241.         (setq xrefpath (cdr (assoc 1 blklist)))
  2242.         (setq help_entry "modify_External_Reference_dialog")
  2243.         (if (not (new_dialog "ddxref" dcl_id)) (exit))
  2244.         (set_tile "path" xrefpath)
  2245.       )
  2246.       (progn
  2247.         (if (and (setq temp (assoc -3 (entget ename '("ACAD"))))
  2248.                  (= (cdr (assoc 1000 (cdadr temp))) "HATCH")
  2249.                  (assoc 1005 (cdadr temp))
  2250.             )
  2251.           (progn
  2252.             (if (not (new_dialog "ddhatch" dcl_id)) (exit))
  2253.             (action_tile "b_hatch" "(done_dialog 4)")
  2254.             (set_tile "Bl_name" (strcat blkname " - Sombreado asociativo"))
  2255.             (setq help_entry "modify_associative_hatch_dialog")
  2256.           )
  2257.           (progn
  2258.             (if (not (new_dialog "ddblock" dcl_id)) (exit))
  2259.             (if ( = "*" (substr blkname 1 1))
  2260.               (set_tile "Bl_name" (strcat blkname " - Bloque sin nombre"))
  2261.               (set_tile "Bl_name" blkname)
  2262.             )
  2263.             (setq help_entry  "modify_Block_Insertion_dialog")
  2264.           )
  2265.         )
  2266.       )
  2267.     )
  2268.     (set_tile_props)
  2269.     (set_tile_handle)
  2270.     (set_tile_pt1 1)  
  2271.     (set_tile_rot)
  2272. ;;    (set_tile "Bl_name" blkname)
  2273.      (set_tile_scale)
  2274.     (set_tile_rc)
  2275.     (if (= (logand blktype 1) 1)
  2276.       (progn
  2277.         (mode_tile "xscale" 1)
  2278.         (mode_tile "yscale" 1)
  2279.         (mode_tile "zscale" 1)
  2280.         (mode_tile "rot" 1)
  2281.         (mode_tile "columns" 1)
  2282.         (mode_tile "rows" 1)
  2283.         (mode_tile "col_sp" 1)
  2284.         (mode_tile "row_sp" 1)
  2285.       )
  2286.     )
  2287.     ;; Define action for tiles
  2288.     (set_action_tiles)
  2289.     (setq dialog-state (start_dialog))
  2290.     (cond
  2291.        (  (eq dialog-state 0)
  2292.           (setq pt1 (trans (cdr (assoc 10 old-elist)) ename 1))
  2293.           (move_pt1 1)   
  2294.           (reset))
  2295.        (  (eq dialog-state 1)
  2296.           (modify_block))
  2297.        (  (eq dialog-state 3)
  2298.           (modify_block)
  2299.           (setq pt1 (getpoint (list x1 y1 z1)  "\nPunto de inserci≤n: "))
  2300.           (move_pt1 1)  
  2301.           (ddblock))
  2302.        (  (eq dialog-state 4)
  2303.           (modify_block)
  2304.           ;; Get current handle.
  2305.           (setq hand (cdr (assoc 5 elist)))
  2306.           (command "_hatchedit" ename)
  2307.           ;; If OK in hatchedit, a *new* entity is created and the old one
  2308.           ;; is deleted.  So if the old one exists, it must have been a 
  2309.           ;; so rest the entity.
  2310.           (if (entget (handent hand)) (reset)) 
  2311.        )
  2312.     )
  2313.   )
  2314.   ;;
  2315.   ;; Modify SHAPE
  2316.   ;;
  2317.   (defun modify_shape ()
  2318.     (modify_properties)
  2319.     (setq pt1 (list x1 y1 z1))
  2320.     (tempmod pt1 10 1)
  2321.     (tempmod hght 40 nil)
  2322.     (tempmod wid 41 nil)
  2323.     (tempmod rot 50 nil)
  2324.     (tempmod obl 51 nil)
  2325.     (entmod elist)
  2326.   )
  2327.  
  2328.   (defun ddshape ()
  2329.     (if (not (new_dialog "ddshape" dcl_id)) (exit))
  2330.     (set_tile_props)
  2331.     (set_tile_handle)
  2332.     (set_tile_pt1 1)
  2333.     (set_tile_rot)
  2334.     (set_tile_hght)
  2335.     (set_tile_wid)
  2336.     (set_tile_obl)
  2337.     (set_tile "sh_name" (cdr (assoc 2 elist)))
  2338.     ;; Define action for tiles
  2339.     (set_action_tiles)
  2340.     (setq dialog-state (start_dialog))
  2341.     (if (= dialog-state 0)
  2342.       (reset)
  2343.     )
  2344.     (if (= dialog-state 1)
  2345.       (modify_shape)
  2346.     ) 
  2347.     (if (= dialog-state 3)
  2348.       (progn
  2349.         (modify_shape)
  2350.         (setq pt1 (getpoint (list x1 y1 z1)  "\nPunto de inserci≤n: "))
  2351.         (ver_pt1 1)
  2352.         (ddshape)
  2353.       )
  2354.     )
  2355.   )
  2356.   ;;
  2357.   ;; Modify TEXT or ATTDEF
  2358.   ;;
  2359.   ;; Set bit code for upside-down and backwards setting
  2360.   ;;
  2361.   (defun code_71 ()
  2362.     (cond ((and (= bkwd "0") (= upsd "0")) 0)
  2363.           ((and (= bkwd "1") (= upsd "0")) 2)
  2364.           ((and (= bkwd "0") (= upsd "1")) 4)
  2365.           ((and (= bkwd "1") (= upsd "1")) 6)
  2366.     )
  2367.   )
  2368.   ;;
  2369.   ;; Style action.  Reset widget values to style defaults
  2370.   ;;
  2371.   (defun style_act (index / style-list)
  2372.     (setq style-idx (atoi index))
  2373.     (setq tstyle (nth style-idx slist))
  2374.     (setq style-idx (itoa style-idx))
  2375.     (set_tile "style" style-idx)
  2376.     (setq style-list (tblsearch "style" tstyle))
  2377.     (setq shght (cdr (assoc 40 style-list)))
  2378.     (if (/= shght 0)
  2379.       (progn
  2380.         (setq hght shght)
  2381.         (set_tile "hght" (ai_rtos hght))
  2382.       )
  2383.     )
  2384.     (setq wid (cdr (assoc 41 style-list)))
  2385.     (set_tile "wid" (ai_rtos wid))
  2386.     (setq obl (cdr (assoc 50 style-list)))
  2387.     (set_tile "obl" (ai_angtos obl))
  2388.     (setq bk-up (cdr (assoc 71 style-list)))
  2389.     (if (= (logand bk-up 2) 2)
  2390.       (set_tile "bkwd" (itoa (setq bkwd 1)))
  2391.       (set_tile "bkwd" (itoa (setq bkwd 0)))
  2392.     )
  2393.     (if (= (logand bk-up 4) 4)
  2394.       (set_tile "upsd" (itoa (setq upsd 1)))
  2395.       (set_tile "upsd" (itoa (setq upsd 0)))
  2396.     )
  2397.   )
  2398.   ;;
  2399.   ;; Justification action.  Set vertical and horizontal alignment variables, 
  2400.   ;; grey out rotation and height if alignment = "aligned", grey out rotation 
  2401.   ;; if alignment = "fit".
  2402.   ;;
  2403.   (defun jlist_act (index / templist)
  2404.     (setq just-idx (atoi index))
  2405.     (cond 
  2406.       ((= just-idx 0) (setq va 0 ha 0))
  2407.       ((= just-idx 1) (setq va 0 ha 1))
  2408.       ((= just-idx 2) (setq va 0 ha 2))
  2409.       ((= just-idx 3) (setq va 0 ha 3))
  2410.       ((= just-idx 4) (setq va 0 ha 4))
  2411.       ((= just-idx 5) (setq va 0 ha 5))
  2412.       ((= just-idx 6) (setq va 3 ha 0))
  2413.       ((= just-idx 7) (setq va 3 ha 1))
  2414.       ((= just-idx 8) (setq va 3 ha 2))
  2415.       ((= just-idx 9) (setq va 2 ha 0))
  2416.       ((= just-idx 10) (setq va 2 ha 1))
  2417.       ((= just-idx 11) (setq va 2 ha 2))
  2418.       ((= just-idx 12) (setq va 1 ha 0))
  2419.       ((= just-idx 13) (setq va 1 ha 1))
  2420.       ((= just-idx 14) (setq va 1 ha 2))
  2421.     )
  2422.     (if (or (= ha 3) (= ha 5))  ; If Aligned or Fit text
  2423.       (mode_tile "rot" 1)
  2424.       (mode_tile "rot" 0)
  2425.     )
  2426.     (if (= ha 3)                ; If Aligned text
  2427.       (mode_tile "hght" 1)
  2428.       (mode_tile "hght" 0)
  2429.     )
  2430.     (if (= ha 5)                ; If Fit text
  2431.       (mode_tile "wid" 1)
  2432.       (mode_tile "wid" 0)
  2433.     )
  2434.     ;; Reset rotation and height if changing from aligned.
  2435.     (if (and (= ha-prev 3)  (/= ha 3))
  2436.       (progn 
  2437.         (set_tile "rot"  (ai_angtos (setq rot 0.0)))
  2438.         (set_tile "hght" (ai_rtos (setq hght 1.0)))
  2439.       )
  2440.     )
  2441.  
  2442.     ;; Reset rotation and width if changing from fit.
  2443.     (if (and (= ha-prev 5) (/= ha 5))
  2444.       (progn 
  2445.         (set_tile "rot" (ai_angtos (setq rot 0.0)))
  2446.         (set_tile "wid" (ai_rtos (setq wid 1.0)))
  2447.       )
  2448.     )
  2449.    
  2450.     (setq ha-prev ha)           ; update ha-prev for next time
  2451.     (setq just-idx (itoa just-idx))
  2452.   )
  2453.   ;;
  2454.   ;; Set intitial alignment setting based on vertical and horizontal alignment 
  2455.   ;; bit codes.
  2456.   ;;
  2457.   (defun set_just_idx ()
  2458.     (cond 
  2459.       ((= ha 0)             ; Horiz alignment = Left
  2460.         (cond 
  2461.           ((= va 0) (setq just-idx "0"))
  2462.           ((= va 1) (setq just-idx "12"))
  2463.           ((= va 2) (setq just-idx "9"))
  2464.           ((= va 3) (setq just-idx "6"))
  2465.         )
  2466.       )
  2467.       ((= ha 1)             ; Horiz alignment = Center
  2468.         (cond 
  2469.           ((= va 0) (setq just-idx "1"))
  2470.           ((= va 1) (setq just-idx "13"))
  2471.           ((= va 2) (setq just-idx "10"))
  2472.           ((= va 3) (setq just-idx "7"))
  2473.         )
  2474.       )
  2475.       ((= ha 2)             ; Horiz alignment = Right
  2476.         (cond 
  2477.           ((= va 0) (setq just-idx "2"))
  2478.           ((= va 1) (setq just-idx "14"))
  2479.           ((= va 2) (setq just-idx "11"))
  2480.           ((= va 3) (setq just-idx "8"))
  2481.         )
  2482.       )
  2483.       ((= ha 3) (setq just-idx "3"))   ; Aligned
  2484.       ((= ha 4) (setq just-idx "4"))   ; Middle
  2485.       ((= ha 5) (setq just-idx "5"))   ; Fit
  2486.       (T (setq just-idx "0"))
  2487.     )
  2488.     just-idx
  2489.   )
  2490.  
  2491.   (defun modify_text ()
  2492.     (setq pt1 (list x1 y1 z1))
  2493.     (setq showpt pt1)
  2494.     (if (or (and (= ha 0) (= va 0))
  2495.             (= ha 3)
  2496.             (= ha 5)
  2497.         )
  2498.       (progn
  2499.         (setq bit-10 (trans showpt 1 ename))
  2500.         (setq alipt (trans alipt 1 ename))
  2501.         (setq bit-11 (list
  2502.                        (car alipt)
  2503.                        (cadr alipt)
  2504.                        (caddr showpt)
  2505.                      )
  2506.         )      
  2507.       )
  2508.       (progn
  2509.         (setq bit-11 (trans showpt 1 ename))
  2510.         (setq bit-10 pt1)
  2511.       )
  2512.     )
  2513.     (modify_properties)
  2514.     (tempmod tstyle 7 nil)
  2515.     (tempmod bit-10 10 nil)
  2516.     (tempmod bit-11 11 nil)
  2517.     (tempmod text 1 nil)
  2518.     (tempmod hght 40 nil)
  2519.     (tempmod wid 41 nil)
  2520.     (tempmod rot 50 nil)
  2521.     (tempmod obl 51 nil)
  2522.     (setq bk-up (+ (* bkwd 2) (* upsd 4)))
  2523.     (tempmod bk-up 71 nil)
  2524.     (tempmod ha 72 nil)
  2525.     ;; Attdefs use 74, text 73
  2526.     (if (= etype "ATTDEF")
  2527.       (progn
  2528.         (tempmod attag 2 nil)
  2529.         (tempmod atprompt 3 nil)
  2530.         (setq icvp (+ inv (* 2 con) (* 4 vfy) (* 8 pre)))
  2531.         (tempmod icvp 70 nil)
  2532.         (tempmod va 74 nil)
  2533.       )
  2534.       (tempmod va 73 nil)
  2535.     )
  2536.     (entmod elist)
  2537.   )
  2538.  
  2539.   (defun ddtext (/ 2ndpt slist i)
  2540.     (if (= etype "TEXT")
  2541.       (if (not (new_dialog "ddtext" dcl_id)) (exit))
  2542.       (if (not (new_dialog "ddattdef" dcl_id)) (exit))
  2543.     )
  2544.     (set_tile_props)
  2545.     (set_tile_handle)
  2546.     (set_tile_text)
  2547.     (set_tile_tag)
  2548.     (set_tile_prompt)
  2549.     (set_tile_hght)
  2550.     (set_tile_wid)
  2551.     (set_tile_rot)
  2552.     (set_tile_obl)
  2553.     (set_tile_bk-up)
  2554.     (set_tile_icvp)
  2555.     (set_tile_style)
  2556.     (set_tile_just)
  2557.     (setq pt1 (trans (cdr (assoc 10 elist)) ename 1))
  2558.     (if (not (assoc 11 elist))
  2559.       (progn (setq pt2 pt1) 
  2560.         (setq elist (cons (cons '11 (cdr (assoc 10 elist))) elist ))
  2561.       )
  2562. ;;(trans '(0.0 0.0 0.0) ename 1))
  2563.       (setq pt2 (trans (cdr (assoc 11 elist)) ename 1))
  2564.     )
  2565.     (if (or (and (= ha 0) (= va 0))
  2566.                  (= ha 3)
  2567.                  (= ha 5)
  2568.         )
  2569.       (setq showpt pt1 alipt pt2)
  2570.       (setq showpt pt2 alipt '(0.0 0.0 0.0))
  2571.     )
  2572.  
  2573.     (set_tile "x1_pt" (ai_rtos (setq x1 (car showpt))))
  2574.     (set_tile "y1_pt" (ai_rtos (setq y1 (cadr showpt))))
  2575.     (set_tile "z1_pt" (ai_rtos (setq z1 (caddr showpt))))
  2576.  
  2577.     ;; Define action for tiles
  2578.     (set_action_tiles)
  2579.     ;; Set focus initially to the text edit box.
  2580.     (if (not i) (progn (mode_tile "t_string" 2)(setq i 1)))
  2581.     (setq dialog-state (start_dialog))
  2582.     (if (= dialog-state 0)
  2583.       (reset)
  2584.     )
  2585.     (if (= dialog-state 1)
  2586.       (modify_text)
  2587.     )
  2588.     (if (= dialog-state 3)
  2589.       (progn
  2590.         (modify_text)
  2591.         (if (or (= ha 3) (= ha 5))
  2592.           (progn
  2593.             (setq showpt (getpoint (list x1 y1 z1) "\nPrimer punto: "))
  2594.             (if (not showpt)
  2595.               (setq showpt (list x1 y1 z1))
  2596.             )
  2597.             (setq 2ndpt (getpoint showpt "\nSegundo punto: "))
  2598.             (if 2ndpt
  2599.               (progn
  2600.                 (setq alipt 2ndpt)
  2601.                 (tempmod showpt 10 1)
  2602.                 (tempmod alipt 11 1)
  2603.                 (entmod elist)
  2604.               )
  2605.             )
  2606.             (setq elist (entget ename))
  2607.           )
  2608.           (progn
  2609.             (setq showpt (getpoint (list x1 y1 z1) "\nPunto de inserci≤n: "))
  2610.             (if showpt
  2611.               (progn
  2612.                 (if (and (= ha 0) (= va 0))
  2613.                   (tempmod showpt 10 1)
  2614.                   (tempmod showpt 11 1)
  2615.                 )
  2616.                 (entmod elist)
  2617.               )
  2618.               (setq showpt (list x1 y1 z1))
  2619.             )
  2620.           )
  2621.         )
  2622.         (ddtext)
  2623.       )
  2624.     )
  2625.   )
  2626.   
  2627.   ;;
  2628.   ;; Modify MTEXT 
  2629.   ;;
  2630.   (defun modify_mtext ()
  2631.     (modify_properties)
  2632.     (setq pt1 (list x1 y1 z1))
  2633.     (tempmod pt1 10 0)
  2634.     (entmod elist)
  2635.   )
  2636.  
  2637.   (defun ddmtext ()
  2638.     (if (not (new_dialog "ddmtext" dcl_id)) (exit))
  2639.     ;; Set initial tile values
  2640.     (set_tile_props)
  2641.     (set_tile_handle)
  2642.     (set_tile_pt1 0)
  2643.  
  2644.     ;; Define action for tiles
  2645.     (set_action_tiles)
  2646.     (action_tile "MTextEdit" "(done_dialog 4)")
  2647.     (action_tile "MTextProp" "(done_dialog 5)")
  2648.  
  2649.     (set_tile "MTextContents" (cdr (assoc '1 elist)))
  2650.  
  2651.     (setq dialog-state (start_dialog))
  2652.     (if (= dialog-state 0)
  2653.       (reset)
  2654.     )
  2655.     (if (= dialog-state 3)
  2656.       (progn
  2657.         (modify_mtext)
  2658.         (setq pt1 (getpoint (list x1 y1 z1)  "\nNuevo punto de inserci≤n: "))
  2659.         (ver_pt1 0)
  2660.         (ddmtext)
  2661.       )
  2662.     )
  2663.     (if (= dialog-state 4)
  2664.       (progn
  2665.         (modify_mtext)
  2666.         (command "_ddedit" ename "")
  2667.     (setq elist (entget ename))
  2668.         (ddmtext)
  2669.       )
  2670.     )
  2671.     (if (= dialog-state 5)
  2672.       (progn
  2673.         (modify_mtext)
  2674.         (command "_mtprop" ename "")
  2675.     (setq elist (entget ename))
  2676.         (ddmtext)
  2677.       )
  2678.     )
  2679.     (if (= dialog-state 1)
  2680.       (modify_mtext)
  2681.     )
  2682.   )
  2683.   ;;  
  2684.   ;; Modify VIEWPORT
  2685.   ;;
  2686.  
  2687.   (defun ddvport ()
  2688.     (if (not (new_dialog "ddvport" dcl_id)) (exit))
  2689.     (set_tile_props)
  2690.     (set_tile_handle)
  2691.     (setq vpt (cdr (assoc 10 elist)))
  2692.     (set_tile "xtext" (rtos (setq x1 (car vpt))))
  2693.     (set_tile "ytext" (ai_rtos (setq y1 (cadr vpt))))
  2694.     (set_tile "ztext" (ai_rtos (setq z1 (caddr vpt))))
  2695.     (setq wid (cdr (assoc 40 elist)))
  2696.     (set_tile "wid" (ai_rtos wid))
  2697.     (setq hght (cdr (assoc 41 elist)))
  2698.     (set_tile "hght" (ai_rtos hght))
  2699.     (setq vpid (cdr (assoc 69 elist)))
  2700.     (set_tile "vpid" (itoa vpid))
  2701.     (setq on-off (cdr (assoc 68 elist)))
  2702.     (cond 
  2703.       ((= on-off 0) (set_tile "on-off" "DES"))
  2704.       ((> on-off 0) (set_tile "on-off" "ACT y Activo"))
  2705.       (T (set_tile "on-off" "ACT e Inactivo"))
  2706.     )
  2707.  
  2708.     ;; Define action for tiles
  2709.     (set_action_tiles)
  2710.  
  2711.     (setq dialog-state (start_dialog))
  2712.     (if (= dialog-state 0)
  2713.       (reset)
  2714.     )
  2715.     (if (= dialog-state 1)
  2716.       (progn
  2717.         (if (= ecolor   0) (setq ecolor ;|MSG0|;"BYBLOCK"))
  2718.         (if (= ecolor 256) (setq ecolor ;|MSG0|;"BYLAYER"))
  2719.         (command "_.chprop" ename ""
  2720.                  "_la" elayer
  2721.                  "_c" ecolor ""
  2722.         )
  2723.       )
  2724.     )
  2725.   )
  2726.   ;;
  2727.   ;; Modify POLYLINE
  2728.   ;;
  2729.   (defun modify_polyline ()
  2730.     (modify_properties)
  2731.     (if (= ltgen "1")
  2732.       (if (/= (logand bit70 128) 128)
  2733.         (setq bit70 (+ bit70 128))
  2734.       )
  2735.     )
  2736.     (if (= ltgen "0")
  2737.       (if (= (logand bit70 128) 128)
  2738.         (setq bit70 (- bit70 128))
  2739.       )
  2740.     )
  2741.     (setq elist (subst (cons 70 bit70) (assoc 70 elist) elist))
  2742.     (entmod elist)
  2743.     ;; Added to take care of updating Vertex information for color
  2744.     ;; and linetype.
  2745.     (setq save-ename ename save-elist elist)
  2746.     (setq ename (entnext save-ename))
  2747.     (setq elist (entget ename))
  2748.     (while (not (= (cdr (assoc 0 elist)) "SEQEND"))
  2749.       (emod ecolor 62)
  2750.       (emod eltype 6)
  2751.       (emod eltscale 48)
  2752.       (entmod elist)
  2753.       (setq ename (entnext ename)) 
  2754.       (setq elist (entget ename))
  2755.     )
  2756.     ;; Update the SEQEND
  2757.     (if (= (cdr (assoc 0 elist)) "SEQEND")
  2758.       (progn
  2759.         (emod ecolor 62)
  2760.         (emod eltype 6)
  2761.         (emod eltscale 48)
  2762.         (entmod elist)
  2763.       )
  2764.     )
  2765.     ;; Go back to header.
  2766.     (setq ename save-ename elist save-elist)
  2767.     (entupd ename)
  2768.   )
  2769.  
  2770.   ;; Increment vertex.  Set tile values to next vertex
  2771.   ;;
  2772.   (defun next_vertex ()
  2773.     (setq vname (entnext vname))
  2774.     (setq vlist (entget vname))
  2775.     (if (= (cdr (assoc 0 vlist)) "VERTEX")
  2776.       (progn
  2777.         (set_tile "ctr" (itoa (setq ctr (+ 1 ctr))))
  2778.         (set_tile_vpt pointype)
  2779.       )
  2780.       (progn
  2781.         (setq vname (entnext ename))
  2782.         (setq vlist (entget vname))
  2783.         (set_tile_vpt pointype)
  2784.         (set_tile "ctr" (itoa (setq ctr 1)))
  2785.       )
  2786.     )
  2787.   )
  2788.  
  2789.   (defun ddpline ()
  2790.     (if (not (new_dialog "ddpline" dcl_id)) (exit))
  2791.     (set_tile_props)
  2792.     (set_tile_handle)
  2793.     (setq bit70 (cdr (assoc 70 elist)))
  2794.     (setq bit75 (cdr (assoc 75 elist)))
  2795.     (cond 
  2796.       ((= (logand bit70 8) 8)   ; 3DPOLY
  2797.         (set_tile "ptype" (setq pltype "Polilφnea 3D"))
  2798.         (setq pointype 0)       ; WCS or ECS point values
  2799.         (mode_tile "fit" 1)
  2800.         (mode_tile "mesh" 1)
  2801.         (mode_tile "bezier" 1)
  2802.         (mode_tile "ltgen" 1)
  2803.         (set_tile "none" "1")
  2804.         (set_tile_closed)
  2805.         (set_tile_fitsmooth)
  2806.       )
  2807.       ((= (logand bit70 16) 16) ; 3DMESH
  2808.         (set_tile "ptype" (setq pltype "Malla 3D"))
  2809.         (setq pointype 0)
  2810.         (mode_tile "pline" 1)
  2811.         (mode_tile "fit" 1)
  2812.         (mode_tile "ltgen" 1)
  2813.         (setq m (1- (cdr (assoc 71 elist))))
  2814.         (setq n (1-(cdr (assoc 72 elist))))
  2815.         (setq u (1- (cdr (assoc 73 elist))))
  2816.         (if (< u 0) (setq u 0))
  2817.         (setq v (1- (cdr (assoc 74 elist))))
  2818.         (if (< v 0) (setq v 0))
  2819.         (set_tile "m" (itoa m))
  2820.         (set_tile "n" (itoa n))
  2821.         (set_tile "u" (itoa u))
  2822.         (set_tile "v" (itoa v))
  2823.         (set_tile_closed)
  2824.         (set_tile_fitsmooth)
  2825.       )
  2826.       ((= (logand bit70 64) 64) ; POLYFACE MESH
  2827.         (set_tile "ptype" (setq pltype "Malla policara"))
  2828.         (setq pointype 0)
  2829.         (mode_tile "f-s" 1)
  2830.         (mode_tile "mesh" 1)
  2831.         (mode_tile "pline" 1)
  2832.       )
  2833.       (T                        ; 2D POLYLINE
  2834.         (set_tile "ptype" (setq pltype "Polilφnea 2D"))
  2835.         (setq pointype 1)
  2836.         (mode_tile "bezier" 1)
  2837.         (mode_tile "mesh" 1)
  2838.         (if (= (logand bit70 128) 128)
  2839.           (set_tile "ltgen" (setq ltgen "1"))
  2840.         )
  2841.         (set_tile_closed)
  2842.         (set_tile_fitsmooth)
  2843.       )
  2844.     )
  2845.     (if (not next) (setq vname (entnext ename)))
  2846.     (setq next T)
  2847.     (set_tile "ctr" (itoa (setq ctr 1)))
  2848.     (setq vlist (entget vname))
  2849.     (set_tile_vpt pointype)
  2850.     ;; Define action for tiles
  2851.     (set_action_tiles)
  2852.     (setq dialog-state (start_dialog))
  2853.  
  2854.     (if (= dialog-state 0)
  2855.       (reset)
  2856.     )
  2857.     (if (= dialog-state 1)
  2858.       (progn
  2859.         (modify_polyline)
  2860.         (if (or (= pltype "Polilφnea 2D")
  2861.                 (= pltype "Polilφnea 3D")
  2862.             )
  2863.           (progn
  2864.             (command "_.pedit" ename)
  2865.             (if (= spltype 0) (command "_d"))
  2866.             (if (= spltype 1) (command "_f"))
  2867.             (if (or (= spltype 5)
  2868.                     (= spltype 6)
  2869.                 )
  2870.               (progn
  2871.                 (setvar "splinetype" spltype)
  2872.                 (command "_s")
  2873.               )
  2874.             )
  2875.             (if (= closed "0")
  2876.               (command "_o")
  2877.               (command "_c")
  2878.             )
  2879.             (command "")
  2880.           )
  2881.         )
  2882.         (if (= pltype "Malla 3D")
  2883.           (progn
  2884.             (command "_.pedit" ename)
  2885.             (if (= spltype 0) (command "_d"))
  2886.             (if (or (= spltype 5)
  2887.                     (= spltype 6)
  2888.                     (= spltype 8)
  2889.                 )
  2890.               (progn
  2891.                 (setvar "surftype" spltype)
  2892.                 (setvar "surfu" u)
  2893.                 (setvar "surfv" v)
  2894.                 (command "_s")
  2895.               )
  2896.             )
  2897.             (if (/= closedm old-closedm)
  2898.               (command "_m")
  2899.             )
  2900.             (if (/= closedn old-closedn)
  2901.               (command "_n")
  2902.             )
  2903.             (command "")
  2904.           )
  2905.         )
  2906.       )
  2907.     )
  2908.   )
  2909.   ;;
  2910.   ;; All the spline data is contained in a single elist. We must do some
  2911.   ;; tricky list processing to loop through the elist in order to display
  2912.   ;; all of the control points.
  2913.   ;;
  2914.   ;; The structure of the elist is different for rational and non-rational
  2915.   ;; splines. Therefore, we check the rational spline flag.
  2916.   ;;
  2917.   (defun next_cntl_pt ()
  2918.     (setq elem-no 0)               ;; elem-no = element counter
  2919.     (if (= first-10-time 1)        ;; If first time, find location of first
  2920.         (foreach list_item elist   ;; cntl point element in elist
  2921.            (progn
  2922.                (setq elem-no (+ 1 elem-no))
  2923.                (if (= (car list_item) 10)
  2924.                    (progn
  2925.                        (if (= first-10-time 1)
  2926.                            (progn
  2927.                               (setq first-10-rec (- elem-no 1))
  2928.                               (setq first-10-time 0)
  2929.                               (if (= rational_spl_flag 1) ;; if rational
  2930.                                   (setq cur-10-rec (+ elem-no 1))
  2931.                                   (setq cur-10-rec elem-no)
  2932.                               )
  2933.                            )   
  2934.                        )    
  2935.                    )    
  2936.                )    
  2937.            )    
  2938.         )
  2939.     )    
  2940.     ;; Now we know the location of the first "10" record; it's stored
  2941.     ;; in first-10-rec. The first 10 record was already displayed when
  2942.     ;; the dialog first came up so let's display the second one when 
  2943.     ;; the user presses the "next" button (the first time through).
  2944.     ;;
  2945.     (setq temprec (nth cur-10-rec elist))
  2946.     ;;   
  2947.     (if (= (car temprec) 10)   ;; if 10 record
  2948.       (progn
  2949.         (if (= rational_spl_flag 1)    ;; if rational spline
  2950.           (progn
  2951.             (setq tempweight (nth (+ cur-10-rec 1) elist))
  2952.             (setq cur-10-rec (+ 2 cur-10-rec))
  2953.           )
  2954.           (progn                       ;; else
  2955.             (setq cur-10-rec (+ 1 cur-10-rec))
  2956.           )
  2957.         )
  2958.       )                                ;; end if rational spline
  2959.       (progn                   ;; else reset counters
  2960.         (setq temprec (nth first-10-rec elist))  ;; get 1st 10 rec
  2961.         (setq tempweight (nth (+ first-10-rec 1) elist))
  2962.         (setq cntl-pt-indicator 0)
  2963.         (if (= rational_spl_flag 1)             ;; if rational
  2964.             (setq cur-10-rec (+ first-10-rec 2)) ;; point to 2nd 10 rec
  2965.             (setq cur-10-rec (+ first-10-rec 1)) ;; point to 2nd 10 rec
  2966.         )
  2967.       )  
  2968.     )                          ;; end if 10 record
  2969.       
  2970.     ;; Display cntl point, weight and ctr. Increment ctr.
  2971.     (setq cntl-pt (cdr temprec))
  2972.     (set_tile "xtext" (rtos (setq x1 (car cntl-pt))))
  2973.     (set_tile "ytext" (ai_rtos (setq y1 (cadr cntl-pt))))
  2974.     (set_tile "ztext" (ai_rtos (setq z1 (caddr cntl-pt))))
  2975.     (setq cntl-pt-indicator (+ 1 cntl-pt-indicator))
  2976.     (set_tile "cntl_ctr" (itoa cntl-pt-indicator))
  2977.     (if (= rational_spl_flag 1)                     ;; if rational
  2978.         (set_tile "weight" (ai_rtos (cdr tempweight))) ;; disp wght
  2979.         (mode_tile "weight_text" 1)                 ;; disable wght
  2980.     )
  2981.   )
  2982.   ;;
  2983.   ;; All the spline info is contained in a single elist. We must do some
  2984.   ;; tricky list processing to loop through the elist in order to display
  2985.   ;; all of the user data points.
  2986.   ;;
  2987.   (defun next_data_pt ()
  2988.     (setq elem-no 0)               ;; elem-no = element counter
  2989.     (if (= first-11-time 1)        ;; If first time, find location of first
  2990.         (foreach list_item elist   ;; data point element in elist
  2991.            (progn
  2992.                (setq elem-no (+ 1 elem-no))
  2993.                (if (= (car list_item) 11)
  2994.                    (progn
  2995.                        (if (= first-11-time 1)
  2996.                            (progn
  2997.                               (setq first-11-rec (- elem-no 1))
  2998.                               (setq cur-11-rec elem-no)
  2999.                               (setq first-11-time 0)
  3000.                            )
  3001.                        )
  3002.                    )
  3003.                )
  3004.            )
  3005.         )
  3006.     )
  3007.     (setq temprec (nth cur-11-rec elist))
  3008.     ;; If it's not a DXF "11" element then we've gone past the last
  3009.     ;; "11" element. Go back to first "11" element. Reset counters.
  3010.     (if (= (car temprec) 11)
  3011.         (setq data-pt (cdr temprec))
  3012.         (progn                           ;; else
  3013.            (setq data-pt (cdr (nth first-11-rec elist)))
  3014.            (setq cur-11-rec first-11-rec)
  3015.            (setq data-pt-indicator 0)
  3016.         )
  3017.     )
  3018.     ;; Display data point and ctr. Increment counters.
  3019.     (set_tile "dxtext" (rtos (setq x1 (car data-pt))))
  3020.     (set_tile "dytext" (rtos (setq y1 (cadr data-pt))))
  3021.     (set_tile "dztext" (rtos (setq z1 (caddr data-pt))))
  3022.     (setq data-pt-indicator (+ 1 data-pt-indicator))
  3023.     (set_tile "data_ctr" (itoa data-pt-indicator))
  3024.     (setq cur-11-rec (+ 1 cur-11-rec))
  3025.   )
  3026.   ;;
  3027.   ;; Modify SPLINE
  3028.   ;;
  3029.   (defun modify_spline ()
  3030.     (modify_prop_geom)
  3031.     (entmod elist)
  3032.   )
  3033.  
  3034.   (defun ddspline ()
  3035.     (if (not (new_dialog "ddspline" dcl_id)) (exit))
  3036.     (set_tile_props)
  3037.     (set_tile_handle)
  3038.     (set_tile_spline_props)
  3039.     ;; Display first control point
  3040.     (set_tile_cntl_pt)
  3041.     ;; Display first data point
  3042.     (set_tile_data_pt)
  3043.  
  3044.     ;; Initialize flags to indicate first time through the dialog.
  3045.     ;; For control points and user data points the "next" buttons
  3046.     ;; in the dialog call the appropriate functions.
  3047.     (setq first-10-time 1)
  3048.     (setq first-11-time 1)
  3049.     ;; initialize control point number counter
  3050.     (setq cntl-pt-indicator 1)
  3051.     (setq data-pt-indicator 1)
  3052.     (set_tile "cntl_ctr" (itoa cntl-pt-indicator))
  3053.     (set_tile "data_ctr" (itoa data-pt-indicator))
  3054.     (set_action_tiles)
  3055.     (setq dialog-state (start_dialog))
  3056.  
  3057.     (if (= dialog-state 0)
  3058.       (reset)
  3059.     )
  3060.     (if (= dialog-state 1)
  3061.       (modify_spline)
  3062.     )
  3063.   )
  3064.   ;;
  3065.   ;; Modify DIMENSION
  3066.   ;;
  3067.   (defun ddimen (/ dtypebit blkname bename sublist a stname n dimtbl
  3068.                    dimsty dimlist dimtext svtext dimovr sv_dvlist stlist 
  3069.                    dimtype dimsvcurset r12)
  3070.    (setq dimtype "DDIMEN"
  3071.           dimsvcurset (ddimen_dimsty_restore)
  3072.     )
  3073.     (setq r12 (ddimen_apnd_stname))
  3074.     (if (not (new_dialog "ddimen" dcl_id)) (exit))
  3075.     (set_tile_props)
  3076.     (set_dimen_props)
  3077.     (set_tile_handle)
  3078.     ;; Define action for tiles
  3079.     (set_action_tiles)
  3080.  
  3081.     (setq dialog-state (start_dialog))
  3082.  
  3083.     (if (= dialog-state 0)
  3084.       (reset)
  3085.     )
  3086.     (if (= dialog-state 1)
  3087.       (progn
  3088.         (if (not (null dimlist))   ; attempted to change dimvars
  3089.             (ddimen_complist sv_dvlist dimlist dimtbl r12)
  3090.         )
  3091.         (if (/= dimsty stname)
  3092.           (setq elist (subst (cons 3 dimsty) (assoc 3 elist) elist))
  3093.         )
  3094.         (modify_properties)
  3095.         (entmod elist)
  3096.       )
  3097.     )
  3098.     (if (= dialog-state 4)
  3099.       (progn
  3100.         (if (not (null dimlist))   ; attempted to change dimvars
  3101.             (ddimen_complist sv_dvlist dimlist dimtbl r12)
  3102.         )
  3103.         (if (/= dimsty stname)
  3104.           (setq elist (subst (cons 3 dimsty) (assoc 3 elist) elist))
  3105.         )
  3106.         (modify_properties)
  3107.         (entmod elist)
  3108.         (command "_ddedit" ename "")
  3109.     (setq elist (entget ename))
  3110.         (ddimen)
  3111.       )
  3112.     )
  3113.     (ddimen_setvars dimsvcurset)      ; Prepare to exit
  3114.   )
  3115.  
  3116.   ;;
  3117.   ;; Modify TOLERANCE
  3118.   ;;
  3119.   (defun ddtolerance (/ a stname n dimtbl
  3120.                    dimsty dimlist dimovr sv_dvlist stlist dimtype 
  3121.                    dimsvcurset r12)
  3122.     (setq dimtype "DDTOLERANCE"
  3123.           dimsvcurset (ddimen_dimsty_restore)
  3124.     )
  3125.     (setq r12 (ddimen_apnd_stname))
  3126.     (if (not (new_dialog "ddtolerance" dcl_id)) (exit))
  3127.     (set_tile_props)
  3128.     (set_dimen_props)
  3129.     (set_tile_handle)
  3130.     (set_action_tiles)
  3131.     (setq dialog-state (start_dialog))
  3132.     (if (= dialog-state 0)
  3133.       (progn 
  3134.         (reset)
  3135.       )
  3136.     )
  3137.     (if (= dialog-state 1)
  3138.       (progn
  3139.         (if (not (null dimlist))   ; attempted to change dimvars
  3140.             (ddimen_complist sv_dvlist dimlist dimtbl r12)
  3141.         )
  3142.         (if (/= dimsty stname)
  3143.           (setq elist (subst (cons 3 dimsty) (assoc 3 elist) elist))
  3144.         )
  3145. ;        (if (null dimtext)
  3146. ;            (setq dimtext "")
  3147. ;        )
  3148. ;        (if (/= dimtext svtext)
  3149. ;            (setq elist (subst (cons 1 dimtext) (assoc 1 elist) elist))
  3150. ;        )
  3151.     (modify_prop_geom)
  3152.     (entmod elist)
  3153.       )
  3154.     )
  3155.     (if (= dialog-state 4)
  3156.       (progn
  3157.         (if (not (null dimlist))   ; attempted to change dimvars
  3158.             (ddimen_complist sv_dvlist dimlist dimtbl r12)
  3159.         )
  3160.         (if (/= dimsty stname)
  3161.           (setq elist (subst (cons 3 dimsty) (assoc 3 elist) elist))
  3162.         )
  3163.         (modify_properties)
  3164.         (entmod elist)
  3165.         (command "_ddedit" ename "")
  3166.     (setq elist (entget ename))
  3167.         (ddtolerance)
  3168.       )
  3169.     )
  3170.     (ddimen_setvars dimsvcurset)      ; Prepare to exit
  3171. )
  3172.  
  3173.   ;;
  3174.   ;; ddimen_dlg - jump to ADS ddim module
  3175.   ;;
  3176.  
  3177.   (defun ddimen_dlg (dimtype tile dimsty dvlist / dimlist)
  3178.  
  3179.     ; Jump to DDIM with overrides if any.
  3180.  
  3181.     (cond ((= tile 11) (setq dimlist (c:ddim "DDMODIFY" dimtype tile dimsty dvlist))) ; Geometry 
  3182.           ((= tile 12) (setq dimlist (c:ddim "DDMODIFY" dimtype tile dimsty dvlist))) ; Format
  3183.           ((= tile 13) (setq dimlist (c:ddim "DDMODIFY" dimtype tile dimsty dvlist))) ; Annotation
  3184.     )
  3185.   )
  3186.  
  3187.   ;;
  3188.   ;; Dimension variables updated are stored as overrides.
  3189.   ;;
  3190.  
  3191.   (defun ddimen_complist (dimolist dimnlist dimtbl r12 / i odvar ndvar 
  3192.                           dv dime)
  3193.  
  3194.     ; Here we skip the following first three items:
  3195.     ;   (0 . "DIMSTYLE") (2 . sylename) (70 . 0)
  3196.     ;
  3197.     ; The list comparison immediately begins with dimvar.
  3198.     ;
  3199.     ;  dimolist - original states of dimvars
  3200.     ;  dimnlist - new dimvar list which is of the resbuf's 
  3201.     ;  dime - entity name for the dimension
  3202.     ;  odvar - value of dimvar for the dimolist 
  3203.     ;  ndvar - value of dimvar for the dimnlist
  3204.     ;  r12 - flag for r12 dwg which used *UNNAMED style
  3205.  
  3206.     ;; Compare the changes against the style "standard" if
  3207.     ;; the (r12's) entity had to use r13 default style. So, 
  3208.     ;; substitute dimolist with the ones of the r13 "standard".
  3209.  
  3210.     (if (not (null r12))
  3211.       (setq dimolist (tblsearch "dimstyle" dimsty))
  3212.     )
  3213.     (setq i 3
  3214.           dime (cdr (assoc -1 elist))
  3215.     )
  3216.     (while (setq odvar (cdr (nth i dimolist)))
  3217.       (progn
  3218.         (setq ndvar (cdr (nth i dimnlist)))
  3219.         (setq dv (nth i dimtbl))
  3220.         (if (eq dv "dimtxsty")
  3221.             (setq odvar (cdr (assoc 2 (entget odvar)))
  3222.                   ndvar (cdr (assoc 2 (entget ndvar))) 
  3223.             )
  3224.         )
  3225.         (if (/= ndvar odvar)
  3226.           (progn
  3227.             (setq dv (strcat "_" dv))
  3228.             (command "_.dimoverride" dv ndvar "" dime "")
  3229.           )
  3230.         )
  3231.         (setq i (1+ i))
  3232.       ) 
  3233.     )
  3234.   )
  3235.  
  3236.   ;;
  3237.   ;; Get style name currently selected style name.
  3238.   ;;
  3239.  
  3240.   (defun ddimen_style (/ dimsty)
  3241.     (setq dimsty (nth (atoi (get_tile "mod_style")) stlist))
  3242.   )
  3243.  
  3244.   ;;
  3245.   ;; Set dimvars 
  3246.   ;;
  3247.   (defun ddimen_setvars (dimsvcurset / dv i)
  3248.     (setq dv (cdr (nth 1 dimsvcurset)))
  3249.     (command "_.dimstyle" "" dv)
  3250.     (setq i 3)
  3251.     (while (setq dv (nth i dimsvcurset))
  3252.       (progn
  3253.         (setvar (car dv) (cdr dv))
  3254.         (setq i (1+ i))
  3255.       )
  3256.     )
  3257.   )
  3258.  
  3259.   ;
  3260.   ; Append dimstyle name if R12 dwg had no dimstyle name field.
  3261.   ;
  3262.   (defun ddimen_apnd_stname()
  3263.     ; R12 dimension used *UNNAMED dimstyle doen't contain 
  3264.     ; (3 . "DIMSTYLENAME") element in 'elist'. With this if 
  3265.     ; R12 dwg was imported to R13 and ran DDMODIFY, the DDMODIFY
  3266.     ; crashes. This a bug in ACAD as of 10/21/94. 
  3267.     ; To prevent us from crashes, this function is provided. 
  3268.     ; Once the bug was fixed in ACAD, this function will not be 
  3269.     ; needed but it does nothing anyway.
  3270.     (if (null (assoc 3 elist)) 
  3271.       (progn
  3272.         (setq elist (append elist (list (cons 3 "STANDARD"))))
  3273.         (entmod elist)
  3274.         T
  3275.       )
  3276.     )
  3277.   )
  3278.   ;;
  3279.   ;;  End-of-dimension
  3280.   ;; ==================
  3281.  
  3282.   ;;
  3283.   ;; Sub-dialogues for properties.  Common to all object dialogues
  3284.   ;;
  3285.   ;; This function pops a dialogue box consisting of a list box,image tile, and
  3286.   ;; edit box to allow the user to select or type a color number.  It returns 
  3287.   ;; the color number selected.
  3288.   (defun getcolor (/ old-idx colorno cname lay_clr)
  3289.     (if (= (get_tile "error") "")
  3290.       (progn
  3291.         ;; Get the color associated with this object's layer, for use
  3292.         ;; in the color swatch if the user selects color BYLAYER.
  3293.         (setq lay_clr (cdr (assoc 62 (tblsearch "layer" elayer))))
  3294.         (if (numberp (setq temp_color (acad_colordlg ecolor T lay_clr)))
  3295.           (progn
  3296.             (setq ecolor temp_color)
  3297.             (setcolor)
  3298.           )
  3299.           (setq testcolor temp_color)
  3300.         )
  3301.       )
  3302.     )
  3303.     ecolor
  3304.   )
  3305.   ;;
  3306.   ;; Function to set the color tiles. 
  3307.   (defun setcolor()
  3308.     (cond 
  3309.       ((= 0 ecolor)
  3310.         (set_tile "t_color" "PORBLOQUE")
  3311.         (col_tile "show_image" 7 nil)    ; show BYBLOCK as white
  3312.       )
  3313.       ((= 1 ecolor)
  3314.         (set_tile "t_color" "1 rojo")
  3315.         (col_tile "show_image" 1 nil)
  3316.       )
  3317.       ((= 2 ecolor)
  3318.         (set_tile "t_color" "2 amarillo")
  3319.         (col_tile "show_image" 2 nil)
  3320.       )
  3321.       ((= 3 ecolor)
  3322.         (set_tile "t_color" "3 verde")
  3323.         (col_tile "show_image" 3 nil)
  3324.       )
  3325.       ((= 4 ecolor)
  3326.         (set_tile "t_color" "4 ciano")
  3327.         (col_tile "show_image" 4 nil)
  3328.       )
  3329.       ((= 5 ecolor)
  3330.         (set_tile "t_color" "5 azul")
  3331.         (col_tile "show_image" 5 nil)
  3332.       )
  3333.       ((= 6 ecolor)
  3334.         (set_tile "t_color" "6 magenta")
  3335.         (col_tile "show_image" 6 nil)
  3336.       )
  3337.       ((= 7 ecolor)
  3338.         (set_tile "t_color" "7 blanco")
  3339.         (col_tile "show_image" 7 nil)
  3340.       )
  3341.       ((= 256 ecolor) 
  3342.         (set_tile "t_color" "PORCAPA")
  3343.         (col_tile "show_image" (bylayer_col) nil)
  3344.       )
  3345.       (T
  3346.         (set_tile "t_color" (itoa ecolor))
  3347.         (col_tile "show_image" ecolor nil)
  3348.       )
  3349.     )
  3350.   )
  3351.   ;;
  3352.   ;; This function pops a dialogue box consisting of a list box, image tile, and 
  3353.   ;; edit box to allow the user to select or  type a linetype.  It returns the 
  3354.   ;; linetype selected.
  3355.   ;;
  3356.   (defun getltype (/ old-idx ltname)
  3357.     (if (not lt-idx)
  3358.       (progn
  3359.         (make_lt_lists)             ; linetype lists - ltnmlst, mdashlist
  3360.         (cond
  3361.           ((= eltype ;|MSG0|;"BYLAYER")
  3362.              (setq lt-idx (getindex "PORCAPA" ltnmlst)))
  3363.           ((= eltype ;|MSG0|;"BYBLOCK")
  3364.              (setq lt-idx (getindex "PORBLOQUE" ltnmlst)))
  3365.           (T (setq lt-idx (getindex eltype ltnmlst)))
  3366.         )
  3367.       )
  3368.     )
  3369.   
  3370.     (if (= (get_tile "error") "")
  3371.      (progn
  3372.       (if (not (new_dialog "setltype" dcl_id)) (exit))
  3373.       (start_list "list_lt")
  3374.       (mapcar 'add_list ltnmlst)  ; initialize list box
  3375.       (end_list)
  3376.       (setq old-idx lt-idx)
  3377.       (ltlist_act (itoa lt-idx))
  3378.  
  3379.       (action_tile "list_lt" "(ltlist_act $value)")
  3380.       (action_tile "edit_lt" "(ltedit_act $value)")
  3381.       (action_tile "accept" "(test_ok)")
  3382.       (action_tile "cancel" "(reset_lt)")
  3383.  
  3384.       (if (= (start_dialog) 1) ; User pressed OK
  3385.         (cond 
  3386.           ((= lt-idx 0)
  3387.             (set_tile "t_ltype" (bylayer_lt))
  3388.             ;|MSG0|;"BYLAYER"
  3389.           )
  3390.           ((= lt-idx 1)
  3391.             (set_tile "t_ltype" "PORBLOQUE")
  3392.             ;|MSG0|;"BYBLOCK"
  3393.           )
  3394.           (T  (set_tile "t_ltype" ltname) ltname)
  3395.         )
  3396.         eltype
  3397.       )
  3398.      )
  3399.      eltype
  3400.     )
  3401.   )
  3402.   ;;
  3403.   ;; Edit box entries end up here
  3404.   (defun ltedit_act (ltvalue)
  3405.     (setq ltvalue (xstrcase ltvalue))
  3406.     (if (or (= ltvalue ;|MSG0|;"BYLAYER")
  3407.             (= ltvalue "PORCAPA"))
  3408.       (setq ltvalue "PORCAPA")
  3409.     )
  3410.     (if (or (= ltvalue ;|MSG0|;"BYBLOCK")
  3411.             (= ltvalue "PORBLOQUE"))
  3412.       (setq ltvalue "PORBLOQUE")
  3413.     )
  3414.     (if (setq lt-idx (getindex ltvalue ltnmlst))
  3415.       (progn
  3416.         (set_tile "error" "")
  3417.         (ltlist_act (itoa lt-idx))
  3418.         (mode_tile "list_lt" 2)
  3419.       )
  3420.       (progn
  3421.         (set_tile "error" "Tipo de lφnea no vßlido.")
  3422.         (setq lt-idx old-idx)
  3423.         (mode_tile "edit_lt" 2)
  3424.       )
  3425.     )
  3426.   )
  3427.   ;;
  3428.   ;; List selections end up here.  Update the list box, edit box, and color 
  3429.   ;; tile.
  3430.   ;;
  3431.   (defun ltlist_act (index / dashdata)
  3432.     (set_tile "error" "")
  3433.     (setq lt-idx (atoi index))
  3434.     (setq ltname (nth lt-idx ltnmlst))
  3435.     (setq dashdata (nth lt-idx mdashlist))
  3436.     (col_tile "show_image" 0 dashdata)
  3437.     (set_tile "list_lt" (itoa lt-idx))
  3438.     (set_tile "edit_lt" ltname)
  3439.   )
  3440.   ;;
  3441.   ;; Reset to original linetype when cancel it selected
  3442.   ;;
  3443.   (defun reset_lt ()
  3444.     (setq lt-idx old-idx)
  3445.     (done_dialog 0)
  3446.   )
  3447.   ;;
  3448.   ;; This function pops a dialogue box consisting of a list box,image tile, and 
  3449.   ;; edit box to allow the user to select or type a layer name.  It returns the 
  3450.   ;; layer name selected.  It also has a button to find the status (On, Off, 
  3451.   ;; Frozen, etc.) of any layer selected.
  3452.   ;;
  3453.   (defun getlayer (/ old-idx layname on off frozth linetype)
  3454.     ;; Create layer list the first time the layer
  3455.     ;; dialogue is called.
  3456.     (if (not lay-idx) 
  3457.       (progn 
  3458.         (make_lay_lists)
  3459.         (setq lay-idx (getindex elayer laynmlst))
  3460.       )
  3461.     )
  3462.  
  3463.     (if (= (get_tile "error") "")
  3464.      (progn
  3465.       (if (not (new_dialog "setlayer" dcl_id)) (exit))
  3466.       (set_tile "cur_layer" (getvar "clayer"))
  3467.       (start_list "list_lay")
  3468.       (mapcar 'add_list longlist)  ; initialize list box
  3469.       (end_list)
  3470.       (setq old-idx lay-idx)
  3471.       (laylist_act (itoa lay-idx))
  3472.       (action_tile "list_lay" "(laylist_act $value)")
  3473.       (action_tile "edit_lay" "(layedit_act $value)")
  3474.       (action_tile "accept" "(test_ok)")
  3475.       (action_tile "cancel" "(reset_lay)")
  3476.       (if (= (start_dialog) 1) ; User pressed OK
  3477.         (progn
  3478.           (set_tile "t_layer" layname)
  3479.           (setq elayer layname)
  3480.           ;; If layer equals bylayer reset color tile
  3481.           (if (= ecolor 256)
  3482.             (col_tile "show_image" (bylayer_col) nil)
  3483.           )
  3484.           layname
  3485.         )
  3486.         elayer
  3487.       )
  3488.      )
  3489.      elayer
  3490.     )
  3491.   )
  3492.   ;;
  3493.   ;; Edit box selections end up here.  Convert layer entry to upper case.  If 
  3494.   ;; layer name is valid, clear error string, call (laylist_act) function,
  3495.   ;; and change focus to list box.  Else print error message.
  3496.   ;;
  3497.   (defun layedit_act (layvalue)
  3498.     (setq layvalue (xstrcase layvalue))
  3499.     (if (setq lay-idx (getindex layvalue laynmlst))
  3500.       (progn
  3501.         (set_tile "error" "")
  3502.         (laylist_act (itoa lay-idx))
  3503.       )
  3504.       (progn
  3505.         (set_tile "error" "Nombre de capa no vßlido.")
  3506.         (mode_tile "edit_lay" 2)
  3507.         (setq lay-idx old-idx)
  3508.       )
  3509.     )
  3510.   )
  3511.   ;;
  3512.   ;; List entry selections end up here.
  3513.   ;;
  3514.   (defun laylist_act (index / layinfo color dashdata)
  3515.     ;; Update the list box, edit box, and color tile.
  3516.     (set_tile "error" "")
  3517.     (setq lay-idx (atoi index))
  3518.     (setq layname (nth lay-idx laynmlst))
  3519.     (setq layinfo (tblsearch "layer" layname))
  3520.     (setq color (cdr (assoc 62 layinfo)))
  3521.     (setq color (abs color))
  3522.     (setq colname (colorname color))
  3523.     (set_tile "list_lay" (itoa lay-idx))
  3524.     (set_tile "edit_lay" layname)
  3525.     (mode_tile "list_lay" 2)
  3526.   )
  3527.   ;;
  3528.   ;; Reset to original layer when cancel is selected.
  3529.   ;;
  3530.   (defun reset_lay ()
  3531.     (setq lay-idx old-idx)
  3532.     (done_dialog 0)
  3533.   )
  3534.   ;;
  3535.   ;; Checks validity of thickness from edit box.
  3536.   (defun getthickness (value)
  3537.     (setq ethickness (verify_d "eb_thickness" value ethickness))
  3538.   )
  3539.   ;;
  3540.   ;; Copy of (getthickness) for ltscale.  If more, make this function
  3541.   ;; generic.
  3542.   (defun getltscale (value)
  3543.     (setq eltscale (verify_d "eb_ltscale" value eltscale))
  3544.   )
  3545.   ;;
  3546.   ;; This function makes a list called laynmlst which consists of all the layer
  3547.   ;; names in the drawing.  It also creates a list called longlist which 
  3548.   ;; consists of strings which contain the layer name, color, linetype, etc.  
  3549.   ;; Longlist is later mapped into the layer listbox.  Both are ordered the 
  3550.   ;; same.
  3551.   ;;
  3552.   (defun make_lay_lists (/ layname onoff frozth color linetype vpf vpn ss 
  3553.                            cvpname xdlist vpldata sortlist name templist
  3554.                            bit-70 layer_number
  3555.                         )
  3556.     (if (= (setq tilemode (getvar "tilemode")) 0)
  3557.       (progn
  3558.         (setq ss (ssget "_x" (list (cons 0 "VIEWPORT")
  3559.                                   (cons 69 (getvar "CVPORT"))
  3560.                             )
  3561.                  )
  3562.         )
  3563.         (setq cvpname (ssname ss 0))
  3564.         (setq xdlist (assoc -3 (entget cvpname '("acad"))))
  3565.         (setq vpldata (cdadr xdlist))
  3566.       )
  3567.     )
  3568.     (setq sortlist nil)
  3569.     (setq templist (tblnext "LAYER" T))
  3570.     (setq layer_number 1)
  3571.     (while templist
  3572.       (setq name (cdr (assoc 2 templist)))
  3573.       (setq sortlist (cons name sortlist))
  3574.       (setq templist (tblnext "LAYER"))
  3575.       ;; Not dead message...
  3576.       (if (= (/ layer_number 50.0) (fix (/ layer_number 50.0)))
  3577.         (set_tile "error" (strcat "Reuniendo..." (itoa layer_number)))
  3578.       )
  3579.       (setq layer_number (1+ layer_number))
  3580.     )
  3581.     (set_tile "error" "")
  3582.     (if (>= (getvar "maxsort") (length sortlist))
  3583.       (progn
  3584.         (if (> layer_number 50) 
  3585.           (set_tile "error" "Ordenando...")
  3586.         )
  3587.         (setq sortlist (acad_strlsort sortlist))
  3588.       )  
  3589.       (setq sortlist (reverse sortlist))
  3590.     )
  3591.     (set_tile "error" "")
  3592.     (setq laynmlst sortlist)
  3593.     (setq longlist nil)
  3594.     (setq layname (car sortlist))
  3595.     (setq layer_number 1)
  3596.     (while layname
  3597.       (if (= (/ layer_number 50.0) (fix (/ layer_number 50.0)))
  3598.         (set_tile "error" (strcat "Analizando..." (itoa layer_number)))
  3599.       )
  3600.       (setq layer_number (1+ layer_number))
  3601.       (setq laylist (tblsearch "LAYER" layname))
  3602.       (setq color (cdr (assoc 62 laylist)))
  3603.       (if (minusp color)
  3604.         (setq onoff ".")
  3605.         (setq onoff "A")
  3606.       )
  3607.       (setq color (abs color))
  3608.       (setq colname (colorname color))
  3609.       (setq bit-70 (cdr (assoc 70 laylist)))
  3610.       (if (= (logand bit-70 1) 1)
  3611.         (setq frozth "I")
  3612.         (setq frozth ".")
  3613.       )
  3614.       (if (= (logand bit-70 2) 2)
  3615.         (setq vpn "N")
  3616.         (setq vpn ".")
  3617.       )
  3618.       (if (= (logand bit-70 4) 4)
  3619.         (setq lock "B")
  3620.         (setq lock ".")
  3621.       )
  3622.       (setq linetype (cdr (assoc 6 laylist)))
  3623.       (setq layname (substr layname 1 31))
  3624.       (if (= tilemode 0)
  3625.         (progn
  3626.           (if (member (cons 1003 layname) vpldata)
  3627.             (setq vpf "A")
  3628.             (setq vpf ".")
  3629.           )
  3630.         )
  3631.         (setq vpf ".")
  3632.       )
  3633.       (setq ltabstr (strcat layname "\t"
  3634.                               onoff "\t"
  3635.                              frozth "\t"
  3636.                                lock "\t"
  3637.                                 vpf "\t"
  3638.                                 vpn "\t"
  3639.                             colname "\t"
  3640.                            linetype
  3641.                     )
  3642.       )
  3643.       (setq longlist (append longlist (list ltabstr)))
  3644.       (setq sortlist (cdr sortlist))
  3645.       (setq layname (car sortlist))
  3646.     )
  3647.     (set_tile "error" "")
  3648.   )
  3649.   ;;
  3650.   ;; This function makes 2 list - ltnmlst & mdashlist.
  3651.   ;; Ltnmlst is a list of linetype names read from the symbol table.  Mdashlist 
  3652.   ;; is list consisting of lists which define the linetype pattern - numbers 
  3653.   ;; that indicate dots, dashes, and spaces taken from group code 49.  The list 
  3654.   ;; corresponds to the order of names in ltnmlst.
  3655.   ;;
  3656.   (defun make_lt_lists (/ ltlist ltname)
  3657.     (setq mdashlist nil)
  3658.     (setq ltlist (tblnext "LTYPE" T))
  3659.     (setq ltname (cdr (assoc 2 ltlist)))
  3660.     (setq ltnmlst (list ltname))
  3661.     (while (setq ltlist (tblnext "LTYPE"))
  3662.       (setq ltname (cdr (assoc 2 ltlist)))
  3663.       (setq ltnmlst (append ltnmlst (list ltname)))
  3664.     )
  3665.     (setq ltnmlst (acad_strlsort ltnmlst))
  3666.     (foreach ltname ltnmlst
  3667.       (setq ltlist (tblsearch "LTYPE" ltname))
  3668.       (if (= ltname "CONTINUOUS")
  3669.         (setq mdashlist (append mdashlist (list "CONT")))
  3670.         (setq mdashlist 
  3671.             (append mdashlist (list (add_mdash ltlist)))
  3672.         )
  3673.       )
  3674.     )
  3675.     (setq ltnmlst (cons "PORBLOQUE" ltnmlst))
  3676.     (setq mdashlist  (cons nil mdashlist))
  3677.     (setq ltnmlst (cons "PORCAPA" ltnmlst))
  3678.     (setq mdashlist  (cons nil mdashlist))
  3679.   )
  3680.   ;;
  3681.   ;; Get all the group code 49 values for a linetype and put them in a list 
  3682.   ;; (pen-up, pen-down info).
  3683.   ;;
  3684.   (defun add_mdash (ltlist1 / dashlist assoclist dashsize)
  3685.     (setq dashlist nil)
  3686.     (while (setq assoclist (car ltlist1))
  3687.       (if (= (car assoclist) 49)
  3688.         (progn
  3689.           (setq dashsize (cdr assoclist))
  3690.           (setq dashlist (cons dashsize dashlist))
  3691.         )
  3692.       )
  3693.       (setq ltlist1 (cdr ltlist1))
  3694.     )
  3695.     (setq dashlist (reverse dashlist))
  3696.   )
  3697.   ;;
  3698.   ;; Color a tile, draw linetype, and draw a border around it
  3699.   ;;
  3700.   (defun col_tile (tile color patlist / x y)
  3701.     (setq x (dimx_tile tile))
  3702.     (setq y (dimy_tile tile))
  3703.     (start_image tile)
  3704.     (fill_image 0 0 x y color)
  3705.     (if (= color 7)
  3706.       (progn
  3707.         (if patlist (drawpattern x (/ y 2) patlist 0))
  3708.         (tile_rect 0 0 x y 0)
  3709.       )
  3710.       (progn
  3711.         (if patlist (drawpattern x (/ y 2) patlist 7))
  3712.         (tile_rect 0 0 x y 7)
  3713.       )
  3714.     )
  3715.     (end_image)
  3716.   )
  3717.   ;;
  3718.   ;; Draw a border around a tile
  3719.   ;;
  3720.   (defun tile_rect (x1 y1 x2 y2 color)
  3721.     (setq x2 (- x2 1))
  3722.     (setq y2 (- y2 1))
  3723.     (vector_image x1 y1 x2 y1 color)
  3724.     (vector_image x2 y1 x2 y2 color)
  3725.     (vector_image x2 y2 x1 y2 color)
  3726.     (vector_image x1 y2 x1 y1 color)
  3727.   )
  3728.   ;;
  3729.   ;; Draw the linetype pattern in a tile.  Boxlength is the length of the image 
  3730.   ;; tile, y2 is the midpoint of the height of the image tile, pattern is a 
  3731.   ;; list of numbers that define the linetype, and color is the color of the 
  3732.   ;; tile.
  3733.   ;;
  3734.   (defun drawpattern (boxlength y2 pattern color / x1 x2
  3735.                       patlist dash)
  3736.     (setq x1 0 x2 0)
  3737.     (setq patlist pattern)
  3738.     (setq fx 30)
  3739.     (if (= patlist "CONT")
  3740.       (progn (setq dash boxlength)
  3741.         (vi)
  3742.         (setq x1 boxlength)
  3743.       )
  3744.       (foreach dash patlist
  3745.         (if (> (abs dash) 2.5)
  3746.           (setq fx 2)
  3747.         )
  3748.       )
  3749.     )
  3750.     (while (< x1 boxlength)
  3751.       (if (setq dash (car patlist))
  3752.         (progn
  3753.           (setq dash (fix (* fx dash)))
  3754.           (cond 
  3755.             ((= dash 0) (setq dash 1) (vi))
  3756.             ((> dash 0) (vi))
  3757.             (T 
  3758.               (if (< (abs dash) 2)
  3759.                (setq dash 2)
  3760.               )
  3761.               (setq x2 (+ x2 (abs dash)))
  3762.             )
  3763.           )
  3764.           (setq patlist (cdr patlist))
  3765.           (setq x1 x2)
  3766.         )
  3767.         (setq patlist pattern)
  3768.       )
  3769.     )
  3770.   )
  3771.   ;;
  3772.   ;; Draw a dash or dot in image tile
  3773.   ;;
  3774.   (defun vi ()
  3775.     (setq x2 (+ x2 dash))
  3776.     (vector_image x1 y2 x2 y2 color)
  3777.   )
  3778.   ;;
  3779.   ;; If an item is a member of the list, then return its index number, else 
  3780.   ;; return nil.
  3781.   ;;
  3782.   (defun getindex (item itemlist / m n)
  3783.     (setq n (length itemlist))
  3784.     (if (> (setq m (length (member item itemlist))) 0)
  3785.       (- n m)
  3786.       nil
  3787.     )
  3788.   )
  3789.   ;;
  3790.   ;; This function is called if the linetype is set "BYLAYER". It finds the 
  3791.   ;; ltype of the layer so it can be displayed  beside the linetype button.
  3792.   ;;
  3793.   (defun bylayer_lt (/ layname layinfo ltype)
  3794.     (if lay-idx
  3795.       (progn
  3796.         (setq layname (nth lay-idx laynmlst))
  3797.         (setq layinfo (tblsearch "layer" layname))
  3798.         (setq ltype (cdr (assoc 6 layinfo)))
  3799.         "PORCAPA"
  3800.       )
  3801.       "PORCAPA"
  3802.     )
  3803.   )
  3804.   ;;
  3805.   ;; This function is called if the color is set "BYLAYER".  It finds the color 
  3806.   ;; of the layer so it can be displayed beside the color button.
  3807.   ;;
  3808.   (defun bylayer_col (/ layname layinfo color)
  3809.     (setq layinfo (tblsearch "layer" elayer))
  3810.     (setq color (abs (cdr (assoc 62 layinfo))))
  3811.   )
  3812.   ;;
  3813.   ;; Used to set the color name in layer subdialogue.
  3814.   ;;
  3815.   (defun colorname (colnum / cn)
  3816.     (setq cn (abs colnum))
  3817.     (cond ((= cn 1) "rojo")
  3818.           ((= cn 2) "amarillo")
  3819.           ((= cn 3) "verde")
  3820.           ((= cn 4) "ciano")
  3821.           ((= cn 5) "azul")
  3822.           ((= cn 6) "magenta")
  3823.           ((= cn 7) "blanco")
  3824.           (T (itoa cn))
  3825.     )
  3826.   )
  3827.   ;;
  3828.   ;; If their is no error message, then close the dialogue.
  3829.   ;;
  3830.   (defun dismiss_dialog (action)
  3831.     (if (= action 0)
  3832.       (done_dialog 0)
  3833.       (if (= (get_tile "error") "")
  3834.         (done_dialog action)
  3835.       )
  3836.     )
  3837.   )
  3838.  
  3839.   (defun test_ok ()
  3840.     (if (= (get_tile "error") "")
  3841.       (done_dialog 1)
  3842.     )
  3843.   )
  3844.  
  3845.   (defun cancel ()
  3846.     (done_dialog 0)
  3847.   )
  3848.  
  3849. ;;; =======================================================================
  3850. ;;; SETUP layer and linetype lists for application, and initialize all
  3851. ;;; program variables.
  3852.  
  3853.   (setq elist       (entget ename)
  3854.         old-elist   elist
  3855.         modlist     elist
  3856.         etype       (strcase (cdr (assoc 0 elist)))
  3857.         extru       (cdr (assoc 210 elist))
  3858.         ecolor      (cdr (assoc 62 elist))
  3859.         elayer      (cdr (assoc 8 elist))
  3860.         ethickness  (cdr (assoc 39 elist))
  3861.         eltscale    (cdr (assoc 48 elist))
  3862.         eltype      (cdr (assoc 6 elist))
  3863.   )
  3864.   (if (not ecolor) (setq ecolor 256))
  3865.   (if (not eltype) (setq eltype ;|MSG0|;"BYLAYER"))
  3866.   (if (not ethickness) (setq ethickness 0))
  3867.   (if (not eltscale) (setq eltscale 1))
  3868.  
  3869. ) ; end ddmodify_init
  3870.  
  3871. ;;; --------------------------------------------------------------------------
  3872. ;;; Function: DDMODIFY_SELECT
  3873. ;;;
  3874. ;;; Object aquisition function.
  3875. ;;;
  3876. ;;; (ddmodify_select)
  3877. ;;;
  3878. ;;; Obtains object to be modified, in one of three ways:
  3879. ;;;
  3880. ;;;   1 - Autoselected.
  3881. ;;;   2 - Prompted for.
  3882. ;;;   3 - Passed as an argument in a call to (ddmodify <ename> )
  3883. ;;;
  3884. ;;; The (ddmodify_select) function also sets the value of the
  3885. ;;; global symbol AI_SELTYPE to one of the above three values to
  3886. ;;; indicate the method thru which the object was aquired.
  3887. ;;;
  3888. ;;; This value can be useful to applications that want to RESTORE
  3889. ;;; an object that was autoselected to its previous selected state
  3890. ;;; when they terminate, although there doesn't appear to be any
  3891. ;;; way to do this right now.
  3892.  
  3893. (defun ddmodify_select ()
  3894.    (cond
  3895.       (  ename                             ; (ddmodify) was called
  3896.          (cond                             ; with an <ename> argument
  3897.             (  (entget ename)              ;   If object is non-deleted
  3898.                (setq ai_seltype 3)         ;   then return its ename.
  3899.                (ai_return ename))))
  3900.  
  3901.  
  3902.       (  (ai_aselect1 "\nDesigne objeto a modificar: ")) ; return autoselected
  3903.                                                       ; object (if only one
  3904.                                                       ; object is selected)
  3905.                                                       ; or prompt for object
  3906.       (t (princ "\nNada seleccionado.")
  3907.          (ai_return nil))
  3908.    )
  3909. )
  3910.  
  3911. ;;; ============= Command line interface function =======================
  3912.  
  3913. (defun C:DDMODIFY ()
  3914.    (ddmodify nil)
  3915.    (princ)
  3916. )
  3917.  
  3918. ;;; ================== (ddmodify) - Main program ========================
  3919. ;;;
  3920. ;;; (ddmodify <ename> )
  3921. ;;;
  3922. ;;; Main program function, callable as a subroutine.
  3923. ;;;
  3924. ;;; <ename> = object name of the object to modify.
  3925. ;;;
  3926. ;;; If <ename> is nil, then user is prompted to select
  3927. ;;; the object interactively.
  3928. ;;;
  3929. ;;; Before (ddmodify) can be called as a subroutine, it must
  3930. ;;; be loaded first.  It is up to the calling application to
  3931. ;;; first determine this, and load it if necessary.
  3932.  
  3933.  
  3934. (defun ddmodify (ename /
  3935.  
  3936.        2ndpt            eltype              old-elist        totang
  3937.        add_mdash        emod                old-fit          tstyle
  3938.        alipt            endpt               old-idx          u
  3939.        ang              end_ang             old-spltype      upsd
  3940.        arclen           ethickness          old-u            v
  3941.        arc_calc         etype               old-v            va
  3942.        assoclist        extru               olderr           value
  3943.        atprompt         f-vis               oldlist          verify_a
  3944.        attag            fchk                on               verify_d
  3945.        attprompt        fit                 on-off           verify_i
  3946.        bit              frozth              onoff            ver_4
  3947.        bit-10           getcolor            patlist          ver_ang1
  3948.        bit-11           getindex            pattern          ver_ang2
  3949.        bit-70           getlayer            pltype           ver_col
  3950.        bit1             getltype            polytype         ver_colsp
  3951.        bit2             getthickness        pre              ver_hght
  3952.        bit3             get_color           proplist         ver_obl
  3953.        bit4             globals             pt               ver_pt1
  3954.        bit70            ha                  pt1              ver_pt2
  3955.        bit75            hght                pt2              ver_pt3
  3956.        bk-up            icvp                pt3              ver_pt4
  3957.        bkwd             index               pt4              ver_rad
  3958.        boxlength        inv                 ptype            ver_rot
  3959.        bylayer_col      item                radius           ver_row
  3960.        bylayer_lt       item1               reset            ver_rowsp
  3961.        calc             item2               reset_lay        ver_u
  3962.        cancel           itemlist            reset_lt         ver_v
  3963.        cir_calc         jlist               rot              ver_wid
  3964.        closed           jlist_act           row-sp           ver_x1
  3965.        closedm          just-idx            rows             ver_x2
  3966.        closedn          lay-idx             s                ver_x3
  3967.        cmd              layedit_act         set_action_tiles ver_x4
  3968.        cn               layinfo             set_just_idx     ver_xscl
  3969.        cname            laylist             set_tile_bk-up   ver_y1
  3970.        code_71          laylist_act         set_tile_edges   ver_y2
  3971.        col-idx          layname             set_tile_endang  ver_y3
  3972.        col-sp           laynmlst            set_tile_hght    ver_y4
  3973.        colname          layvalue            set_tile_icvp    ver_yscl
  3974.        colnmlst         linetype            set_tile_just    ver_z1
  3975.        colnolst         line_calc           set_tile_obl     ver_z2
  3976.        colnum           list1               set_tile_prompt  ver_z3
  3977.        color            longlist            set_tile_props   ver_zscl
  3978.        colorname        lt-idx              set_tile_pt1     vi
  3979.        colorno          ltabstr             set_tile_pt2     vlist
  3980.        columns          ltedit_act          set_tile_pt3     vname
  3981.        col_tile         ltidx               set_tile_pt4     vpf
  3982.        con              ltlist              set_tile_rad     vpid
  3983.        coord            ltlist1             set_tile_rc      vpldata
  3984.        ctr              ltlist_act          set_tile_rot     vpn
  3985.        cvpname          ltname              set_tile_scale   vpt
  3986.        dash             ltnmlst             set_tile_stang   wid
  3987.        dashdata         ltvalue             set_tile_style   x
  3988.        dashlist         ltype               set_tile_tag     x1
  3989.        dashsize         m                   set_tile_text    x2
  3990.        dcl_id           make_lay_lists      set_tile_vpt     x3
  3991.        dd3dface         make_lt_lists       set_tile_wid     x4
  3992.        ddarc            mdashlist           shght            xdlist
  3993.        ddblock          modify_3dface       showpt           xscale
  3994.        ddcircle         modify_arc          size             y
  3995.        ddline           modify_block        slist            y1
  3996.        ddlist           modify_circle       sname            y2
  3997.        ddmodify_err     modify_line                          y3
  3998.        ddpline          modify_point        sortlist         y4
  3999.        ddpoint          modify_polyline     spltype          yscale
  4000.        ddshape          modify_properties   ss               z1
  4001.        ddsolid          modify_shape        stpt             z2
  4002.        ddtext           modify_solid        style-idx        z3
  4003.        ddvport          modify_text         style-list       z4
  4004.        dialog-state     modify_vport        style_act        zscale
  4005.        modlist          st_ang              setcolor         reset_flag
  4006.        drawpattern      n                   temp             reset_uv
  4007.        echo             name                templist         ver_tag
  4008.        ecolor           newpoint            tempmod          move_pt1
  4009.        edge1            next                temp_color       undo_init
  4010.        edge2            next_vertex         test_ok          help_entry
  4011.        edge3            obl                 text             which_tiles
  4012.        edge4            off                 th-value         eltscale
  4013.        edgetest         old-closed          tile             vfy
  4014.        elayer           old-closedm         tilemode         ddmline
  4015.        elist            old-closedn         tile_rect        modify_mline
  4016.        ddimen           errchk              dismiss_dialog     ddmtext
  4017.        cur-10-rec       cntl-pt-indicator   ddellipse         modify_mtext
  4018.        ddregion         dd3dsolid           ddspline         ddbody
  4019.        ell_calc         first-10-rec        first-10-time    modify_body
  4020.        modify_ellipse   modify_region       modify_3dsolid   modify_spline
  4021.        modify_prop_geom ver_majrad          rrat             tempst_ang
  4022.        majrad           old_majrad          minrad           tempend_eang
  4023.        xx               yy                  zz               ell_calc_area
  4024.        ell_tile         ver_eangle          first-11-time    ddgettext
  4025.        first-11-rec     data-pt-indicator   cur-11-rec       fx
  4026.        set_tile_cntl_pt set_tile_data_pt    set_tile_spline_props
  4027.        ddleader         rational_spl_flag
  4028.        ver_xline_pt1    ver_xline_pt2       set_tile_xline_pt1
  4029.        set_tile_dirv    pt1_eq_pt2          set_tile_xline_pt2
  4030.        ver_xline_x1     ver_xline_y1        ver_xline_z1
  4031.        ver_xline_x2     ver_xline_y2        ver_xline_z2
  4032.        modify_xline     ddxline             modify_ray       ddray
  4033.        xline_x1         xline_y1            xline_z1
  4034.        xline_x2         xline_y2            xline_z2
  4035.        xline_pt1        xline_pt2           denom            
  4036.        dir_pt           dir_ptx             dir_pty          dir_ptz
  4037.        temp_dir_x       temp_dir_y          temp_dir_z   
  4038.        verify_xline     temp_xline_pt1      temp_xline_x1
  4039.        temp_xline_y1    temp_xline_z1       ha-prev
  4040.        
  4041.   )
  4042.  
  4043.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  4044.         old_error  *error*            ; save current error function
  4045.         *error* ai_error              ; new error function
  4046.   )
  4047.  
  4048.   (setvar "cmdecho" (cond (  (or (not *debug*) (zerop *debug*)) 0)
  4049.                           (t 1)))
  4050.  
  4051.   (cond
  4052.      (  (not (ai_notrans)))                      ; Not transparent?
  4053.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  4054.      (  (not (setq dcl_id (ai_dcl "ddmodify")))) ; is .DLG file loaded?
  4055.      (  (not (setq ename (ddmodify_select))))    ; object to modify?
  4056.  
  4057.      (t (ai_undo_push)
  4058.         (ddmodify_init)                          ; everything okay, proceed.
  4059.         (cond
  4060.            ((= etype "LEADER")       
  4061.              (setq help_entry  "modify_Leader_dialog")
  4062.              (ddleader)
  4063.            )
  4064.            ((= etype "ARC")       
  4065.              (setq help_entry  "modify_Arc_dialog")
  4066.              (ddarc)
  4067.            )
  4068.            ((= etype "ATTDEF")    
  4069.              (setq help_entry  "modify_Attribute_Definition_dialog")
  4070.              (ddtext)
  4071.            )
  4072.            ((= etype "CIRCLE")    
  4073.              (setq help_entry  "modify_Circle_dialog")
  4074.              (ddcircle)
  4075.            )
  4076.            ((= etype "ELLIPSE")
  4077.              (setq help_entry  "modify_Ellipse_dialog")
  4078.              (ddellipse)
  4079.            )
  4080.            ((= etype "3DSOLID")
  4081.              (setq help_entry  "modify_Solid_dialog")
  4082.              (dd3dsolid)
  4083.            )
  4084.            ((= etype "BODY")
  4085.              (setq help_entry  "modify_Body_dialog")
  4086.              (ddbody)
  4087.            )
  4088.            ((= etype "REGION")
  4089.              (setq help_entry  "modify_Region_dialog")
  4090.              (ddregion)
  4091.            )
  4092.            ((= etype "SPLINE")
  4093.              (setq help_entry  "modify_Spline_dialog")
  4094.              (ddspline)
  4095.            )
  4096.            ((= etype "INSERT")    ; see ddblock for help_entry
  4097.              (ddblock)
  4098.            )
  4099.            ((= etype "LINE")      
  4100.              (setq help_entry  "modify_Line_dialog")
  4101.              (ddline)
  4102.            )
  4103.            ((= etype "MLINE") 
  4104.              (setq help_entry  "modify_multiLine_dialog")
  4105.              (ddmline)
  4106.            )
  4107.            ((= etype "RAY")      
  4108.              (setq help_entry  "modify_Ray_dialog")
  4109.              (ddxline)
  4110.            )
  4111.            ((= etype "XLINE")      
  4112.              (setq help_entry  "modify_Xline_dialog")
  4113.              (ddxline)
  4114.            )
  4115.            ((= etype "POINT")     
  4116.              (setq help_entry  "modify_Point_dialog")
  4117.              (ddpoint)
  4118.            )
  4119.            ((= etype "POLYLINE")  
  4120.              (setq help_entry  "modify_Polyline_dialog")
  4121.  
  4122.              ;; If a 2D pline, check to see if it is planar to the current
  4123.              ;; UCS, reject if not.   To see if the pline is parallel,
  4124.              ;; the 210 group (WCS) is added to the current UCS origin (WCS)
  4125.              ;; and then converted to the current UCS and checked to see if
  4126.              ;; it is equal to (0,0,1).
  4127.              (if (and (zerop (logand 120 (cdr (assoc 70 (entget ename)))))
  4128.                       (not (equal '(0.0 0.0 1.0) 
  4129.                                    (trans (mapcar '+ 
  4130.                                              (cdr (assoc 210 (entget ename)))
  4131.                                              (trans '(0.0 0.0 0.0) 1 0)
  4132.                                           ) 
  4133.                                      0 1
  4134.                                    )
  4135.                                    0.0000000001            ; fuzz
  4136.                            )
  4137.                       )
  4138.                  )
  4139.                (princ "\nLa polilφnea 2D no es paralela al SCP actual.")
  4140.                (ddpline)
  4141.              )
  4142.            )
  4143.  
  4144.            ((= etype "SHAPE")     
  4145.              (setq help_entry  "modify_Shape_dialog")
  4146.              (ddshape)
  4147.            )
  4148.            ((= etype "SOLID")     
  4149.              (setq help_entry  "modify_Solid_dialog")
  4150.              (ddsolid)
  4151.            )
  4152.            ((= etype "TEXT")
  4153.              (setq help_entry  "modify_Text_dialog")
  4154.              (ddtext)
  4155.            )
  4156.            ((= etype "MTEXT")
  4157.              (setq help_entry  "modify_MText_dialog")
  4158.              (ddmtext)
  4159.            )
  4160.            ((= etype "TRACE")     
  4161.              (setq help_entry  "modify_Trace_dialog")
  4162.              (ddsolid)
  4163.            )
  4164.            ((= etype "VIEWPORT")  
  4165.              (setq help_entry  "modify_Viewport_dialog")
  4166.              (ddvport)
  4167.            )
  4168.            ((= etype "3DFACE")    
  4169.              (setq help_entry  "modify_3D_Face_dialog")
  4170.              (dd3dface)
  4171.            )
  4172.            ((= etype "DIMENSION") 
  4173.              (setq help_entry  "modify_Dimension_dialog")
  4174.              (ddimen)
  4175.            )
  4176.            ((= etype "TOLERANCE") 
  4177.              (setq help_entry  "modify_Tolerance_dialog")
  4178.              (ddtolerance)
  4179.            )
  4180.            (t (princ (strcat "No hay cuadros de dißlogo para este tipo de objeto: "
  4181.                              etype "."
  4182.                      )
  4183.               )
  4184.            )
  4185.         )
  4186.         (ai_undo_pop)
  4187.      )
  4188.   )
  4189.   
  4190.   (setq *error* old_error) 
  4191.   (setvar "cmdecho" old_cmd)
  4192.   (if (not reset_flag)            ; if object was modified, then
  4193.       (ai_return ename)           ; return it's ename to caller
  4194.   )
  4195. )
  4196.  
  4197.  
  4198. (princ "  DDMODIFY cargado.  ")
  4199. (princ)
  4200.  
  4201.  
  4202.