home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 10.img / BONUS3.LIB / XPLODE.LSP < prev    next >
Encoding:
Text File  |  1993-01-23  |  20.2 KB  |  677 lines

  1. ;;;--------------------------------------------------------------------------;
  2. ;;; XPLODE.LSP
  3. ;;;   (C) ¬⌐┼v 1988-1992  Autodesk ñ╜Ñq
  4. ;;;
  5. ;;;   Ñ╗╡{ªíñwÑ╤ Autodesk ñ╜Ñq╡∙ÑU¬⌐┼v, ╢╚⌐≤ñU¡z▒í¬pñUÑi▒┬╗P▒zíu│\ÑiívíC
  6. ;;;   ╗╒ñUñú▒oÑHÑ⌠ª≤º╬ªí╡oªµ⌐╬ÑX¬⌐ª╣╡{ªí¬║íu¡∞⌐l╜Xív; ª²ñ╣│\▒zªb»S⌐w¡lÑ═
  7. ;;;   ¬║ñuº@ñW╡▓ªXª╣╡{ªí¬║íuÑ╪¬║╜Xív¿╧Ñ╬íCª│├÷│o├■¡lÑ═ñuº@¬║▒°Ñ≤ªpñU:
  8. ;;;
  9. ;;;   ( i)  │]¡pñW╗Pñuº@ñW¼╥»┬║Θ░w╣∩ Autodesk ñ╜Ñq¬║▓ú½~íC
  10. ;;;   (ii)  ╕ⁿª│íu¬⌐┼v  (C) 1988-1992  Autodesk ñ╜Ñqív¬║¬⌐┼v│qºiíC
  11. ;;;
  12. ;;;
  13. ;;;
  14. ;;;   AUTODESKñ╜Ñq┤ú¿╤ª╣╡{ªí╢╚¿╤º@íu├■ªⁿív¬║░╤ª╥, ª╙ÑBñú▒╞░úª│Ñ⌠ª≤┐∙╗~¬║
  15. ;;;   Ñi»αíCAUTODESKñ╜Ñq»Sª╣º_╗{Ñ⌠ª≤»S⌐wÑ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºt
  16. ;;;   ÑX¿π¬║½O├╥íCAUTODESKñ╜ÑqªP«╔ÑτñúÑX¿πª╣╡{ªí░⌡ªµ«╔ñ@⌐wñú╖|íuññ┬_ív⌐╬
  17. ;;;   íuº╣Ñ■╡L╗~ív¬║½O├╥íC
  18. ;;;
  19. ;;;
  20. ;;;   Jan S. Yoder & K.C. Jones   Version 1.0
  21. ;;;
  22. ;;;   Modified to allow explosion of blocks with equal absolute scaling
  23. ;;;   parameters but varying signs (i.e. 1,-1,1).  This allows mirrored blocks
  24. ;;;   to be exploded.
  25. ;;;
  26. ;;;   Jerry Ford   Version 2.0  8/20/91
  27. ;;; --------------------------------------------------------------------------;
  28. ;;; DESCRIPTION
  29. ;;;
  30. ;;;
  31. ;;;   This is a replacement for the EXPLODE command in AutoCAD.  It allows
  32. ;;;   you to control all of the properties of the component entities of a
  33. ;;;   block or set of blocks while exploding them.  There are several major
  34. ;;;   differences between XPlode and the EXPLODE command in AutoCAD.
  35. ;;;
  36. ;;;   First, you can select as many entities as you wish; all dimensions,
  37. ;;;   polyline and polymeshes, and block insertions will be extracted from
  38. ;;;   your selection set, and you will be asked to XPlode them either
  39. ;;;   globally or individually.  If you chose to explode them globally, you
  40. ;;;   will see the following prompt for all of the candidate entities:
  41. ;;;
  42. ;;;     All/Color/LAyer/LType/Inherit from parent block/<Explode>:
  43. ;;;
  44. ;;;   If, on the other hand, you elect to operate on each element of the
  45. ;;;   selection set individually, you will need to make a selection from this
  46. ;;;   prompt for each entity to be exploded.
  47. ;;;
  48. ;;;   Second, the EXPLODE command in AutoCAD does not allow you to specify
  49. ;;;   any of the properties for the resulting entities generated from the
  50. ;;;   EXPLODE command.  Nor does it allow you to let the component entities
  51. ;;;   inherit the attributes of the parent block.
  52. ;;;
  53. ;;;   Third, this routine allows blocks inserted with equal absolute scale
  54. ;;;   factors but differing signs to be exploded (i.e. -1,1,1).  This allows
  55. ;;;   mirrored blocks to be exploded.
  56. ;;;
  57. ;;;   ALL
  58. ;;;
  59. ;;;   This option allows you to specify a color, linetype, and layer for the
  60. ;;;   new entities.
  61. ;;;
  62. ;;;   COLOR
  63. ;;;
  64. ;;;   This option prompts you for a new color for the component entities.
  65. ;;;
  66. ;;;     New color for exploded entities.
  67. ;;;     Red/Yellow/Green/Cyan/Blue/Magenta/White/BYLayer/BYBlock/<cecolor>:
  68. ;;;
  69. ;;;   You may enter any color number from 1 through 255, or one of the
  70. ;;;   standard color names listed.  "Cecolor" is the current entity color
  71. ;;;   from the CECOLOR system variable.
  72. ;;;
  73. ;;;   LAYER
  74. ;;;
  75. ;;;   This option prompts you to enter the name of the layer on which you
  76. ;;;   want the component entities to be placed.
  77. ;;;
  78. ;;;     XPlode onto what layer?  <clayer>:
  79. ;;;
  80. ;;;   The layer name entered is verified and if it does not exist you are
  81. ;;;   reprompted for a layer name.  Pressing RETURN causes the current
  82. ;;;   layer to be used.
  83. ;;;
  84. ;;;   LTYPE
  85. ;;;
  86. ;;;   This option lists all of the loaded linetypes in the current drawing,
  87. ;;;   and prompts you to choose one of them.  You must type the entire
  88. ;;;   linetype name (sorry), or you may press RETURN to use the current one.
  89. ;;;
  90. ;;;     Choose from the following list of linetypes.
  91. ;;;     CONTinuous/...others.../<CONTINUOUS>:
  92. ;;;
  93. ;;;   INHERIT
  94. ;;;
  95. ;;;   Inherit from parent block means that the attributes of the block
  96. ;;;   being XPloded will be the attributes of component entities.  No other
  97. ;;;   choices are required.
  98. ;;;
  99. ;;;   EXPLODE
  100. ;;;
  101. ;;;   This option issues the current EXPLODE command for each of the entities
  102. ;;;   in the selection set.
  103. ;;;
  104. ;;; --------------------------------------------------------------------------;
  105.  
  106. ;;; ------------------------ INTERNAL ERROR HANDLER --------------------------;
  107.  
  108. (defun xp_err (s)                     ; If an error (such as CTRL-C) occurs
  109.   ;; while this command is active...
  110.   (if (/= s "Ñ\»α¿·«°")
  111.     (princ (strcat "\n┐∙╗~: " s))
  112.   )
  113.   (if xp_oce (setvar "cmdecho" xp_oce)) ; restore old cmdecho value
  114.   (setq *error* olderr)               ; restore old *error* handler
  115.   (princ)
  116. )
  117.  
  118. ;;; ---------------------------- COMMON FUNCTION -----------------------------;
  119.  
  120. (defun xp_val (n e f)
  121.   (if f ; if f then e is an entity list.
  122.     (cdr (assoc n e))
  123.     (cdr (assoc n (entget e)))
  124.   )
  125. )
  126.  
  127. ;;; ------------------------- GET ENTITY TO EXPLODE --------------------------;
  128. ;;; ---------------------------- MAIN PROGRAM --------------------------------;
  129.  
  130. (defun explode ( / oce ohl e0 en e1 s0)
  131.  
  132.   ;; Version number.  Reset this local if you make a change.
  133.   (setq xp_ver "2.00")
  134.  
  135.   (setq xp_oer *error*
  136.         *error* xp_err)
  137.   (setq xp_oce (getvar "cmdecho"))    ; save value of cmdecho
  138.   (setvar "cmdecho" 0)                ; turn cmdecho off
  139.  
  140.   (graphscr)
  141.   (princ (strcat "\nXPlode, ¬⌐Ñ╗ " xp_ver ", (c) 1991 Autodesk ñ╜ÑqíC"))
  142.  
  143.   (princ "\n┐∩╛▄╣w│╞íu¼╡╢} (XPlode)ív¬║╣╧ñ╕ íC")
  144.   (setq ss (ssget))
  145.  
  146.   (if ss
  147.     (progn
  148.       ;; Sort out any entities not explodeable...
  149.       (setq ss (xp_sxe)) ; DLine_Sort_Xplodable_Entities
  150.  
  151.       ;; XPlode Individually or Globally?
  152.  
  153.       (if (> (sslength ss) 0)
  154.         (progn
  155.           (if (> (sslength ss) 1)
  156.             (progn
  157.               (initget "Individually Globally")
  158.               (setq ans (getkword "\n\n¼╡╢} (XPlode) í╨ I¡╙ºO/<G╛π┼Θ>: "))
  159.             )
  160.             (setq ans "Globally")
  161.           )
  162.  
  163.  
  164.           (cond
  165.             ((= ans "Individually")
  166.               (setq sslen (sslength ss)
  167.                     j    0
  168.               )
  169.               (while (< j sslen)
  170.                 (setq temp  (ssname ss j)
  171.                       prmpt T
  172.                 )
  173.  
  174.                 (redraw temp 3)
  175.                 (setq typ (xp_gxt))
  176.                 (xp_xpe temp typ)
  177.                 (redraw temp 4)
  178.                 (setq j (1+ j))
  179.               )
  180.             )
  181.             (T
  182.               (setq sslen (sslength ss)
  183.                     j     0
  184.                     ans   "Globally"
  185.                     prmpt T
  186.               )
  187.               (setq typ (xp_gxt))
  188.               (while (< j sslen)
  189.                 (setq temp (ssname ss j))
  190.                 (xp_xpe temp typ)
  191.                 (setq j (1+ j))
  192.               )
  193.             )
  194.           )
  195.         )
  196.       )
  197.     )
  198.   )
  199.  
  200.   (if xp_oce (setvar "cmdecho" xp_oce)) ; restore old cmdecho value
  201.   (setq *error* xp_err)               ; restore old *error* handler
  202.   (prin1)
  203. )
  204. ;;;
  205. ;;; Sort out all of the entities which can be exploded from the selection
  206. ;;; set.  Also ensure that block insertions have equal X, Y and Z scale factors.
  207. ;;;
  208. ;;; xp_sxe == DLine_Sort_Xplodable_Entities
  209. ;;;
  210. (defun xp_sxe (/ temp bad)
  211.  
  212.   (setq sslen (sslength ss)
  213.         j     0
  214.         ss1   (ssadd)
  215.   )
  216.   (while (< j sslen)
  217.     (setq temp (ssname ss j))
  218.     (setq j (1+ j))
  219.     (if (member (xp_val 0 temp nil) '("INSERT" "DIMENSION" "POLYLINE"))
  220.       (if (= (xp_val 0 temp nil) "INSERT")
  221.         (if (and (= (abs (xp_val 41 temp nil)) (abs (xp_val 42 temp nil)))
  222.                  (= (abs (xp_val 41 temp nil)) (abs (xp_val 43 temp nil)))
  223.             )
  224.           (ssadd temp ss1)
  225.         )
  226.         (ssadd temp ss1)
  227.       )
  228.     )
  229.   )
  230.   (setq sslen (sslength ss)
  231.         bad (sslength ss1)
  232.   )
  233.   (princ "\n")
  234.   (princ "ºΣ¿∞ ")
  235.   (princ sslen)
  236.   (princ " ▓╒╣╧ñ╕íC ")
  237.   (if (> (- sslen bad) 0)
  238.     (progn
  239.       (princ (- sslen bad))
  240.       (princ " ▓╒╡L«─íC ")
  241.     )
  242.   )
  243.   ss1
  244. )
  245. ;;;
  246. ;;; Set the type of explode to do.
  247. ;;;
  248. ;;; xp_gxt == XPlode_Get_Xplode_Type
  249. ;;;
  250. (defun xp_gxt (/ temp)
  251.  
  252.   (initget "All Color LAyer LType Inherit Explode")
  253.   (setq temp (getkword
  254.     "\n\nAÑ■│í/C├CªΓ/LA╣╧╝h/LT╜u½¼/I⌐╙┼ºñ≈¿t╣╧╕s/<E¼╡╢}>: "))
  255.  
  256.   (if (or (= temp "") (null temp))
  257.     (setq temp "Explode")
  258.   )
  259.   temp
  260. )
  261. ;;;
  262. ;;; Do the explosion of an entity.
  263. ;;;
  264. ;;; xp_xpe == XPlode_XPlode_Entity
  265. ;;;
  266. (defun xp_xpe (ent typ /  )
  267.   (cond
  268.     ((= typ "All")
  269.       (if prmpt
  270.         (progn
  271.           (setq color (xp_scn))
  272.           (setq ltype (xp_slt))
  273.           (setq layer (xp_sla))
  274.           (setq prmpt nil)
  275.         )
  276.       )
  277.  
  278.       (xp_xfa)
  279.       (if (or (= ans "Individually") (= j (1- sslen)))
  280.         (progn
  281.           (if (and (> sslen 1) (= ans "Globally"))
  282.             (princ "\níu¼╡╢}ívñº½ß¬║╣╧ñ╕")
  283.             (princ "\níu¼╡╢}ívñº½ß¬║╣╧ñ╕")
  284.           )
  285.           (princ (strcat "├CªΓ╜X = "
  286.                          (if (= (type color) 'INT) (itoa color) color) " ,"
  287.                          " ╜u½¼ = " ltype " , "
  288.                          "╕m⌐≤íu" layer "ív╣╧╝híC"))
  289.         )
  290.       )
  291.     )
  292.     ((= typ "Color")
  293.       (if prmpt
  294.         (progn
  295.           (setq color (xp_scn))
  296.           (setq ltype (getvar "celtype"))
  297.           (setq layer (getvar "clayer"))
  298.           (setq prmpt nil)
  299.         )
  300.       )
  301.  
  302.       (xp_xfa)
  303.       (if (or (= ans "Individually") (= j (1- sslen)))
  304.         (progn
  305.           (if (and (> sslen 1) (= ans "Globally"))
  306.             (princ "\níu¼╡╢}ív½ßñº╣╧ñ╕")
  307.             (princ "\níu¼╡╢}ív½ßñº╣╧ñ╕")
  308.           )
  309.           (princ (strcat "├CªΓ╜X = "
  310.                          (if (= (type color) 'INT) (itoa color) color) " íC"))
  311.         )
  312.       )
  313.     )
  314.     ((=
  315.     typ "LAyer")
  316.       (if prmpt
  317.         (progn
  318.           (setq color (getvar "cecolor"))
  319.           (setq ltype (getvar "celtype"))
  320.           (setq layer (xp_sla))
  321.           (setq prmpt nil)
  322.         )
  323.       )
  324.  
  325.       (xp_xfa)
  326.       (if (or (= ans "Individually") (= j (1- sslen)))
  327.         (progn
  328.           (if (and (> sslen 1) (= ans "Globally"))
  329.             (princ "\níu¼╡╢}ív½ßñº╣╧ñ╕")
  330.             (princ "\níu¼╡╢}ív½ßñº╣╧ñ╕")
  331.           )
  332.           (princ (strcat "╕m⌐≤íu" layer "ív╣╧╝híC"))
  333.         )
  334.       )
  335.     )
  336.     ((= typ "LType")
  337.       (if prmpt
  338.         (progn
  339.           (setq color (getvar "cecolor"))
  340.           (setq ltype (xp_slt))
  341.           (setq layer (getvar "clayer"))
  342.           (setq prmpt nil)
  343.         )
  344.       )
  345.  
  346.       (xp_xfa)
  347.       (if (or (= ans "Individually") (= j (1- sslen)))
  348.         (progn
  349.           (if (and (> sslen 1) (= ans "Globally"))
  350.             (princ "\níu¼╡╢}ív½ßñº╣╧ñ╕")
  351.             (princ "\níu¼╡╢}ív½ßñº╣╧ñ╕")
  352.           )
  353.           (princ (strcat "╜u½¼ = " ltype " íC"))
  354.         )
  355.       )
  356.     )
  357.     ((= typ "Inherit")
  358.       (xp_iap ent)
  359.     )
  360.     (T
  361.       (xp_mirrchk (xp_val -1 ent nil)) ; check entity and explode
  362.     )
  363.   )
  364. )
  365. ;;;
  366. ;;; Force the color, linetype and layer attributes after exploding.
  367. ;;;
  368. ;;; xp_xea == XPlode_Xplode_Force_All
  369. ;;;
  370. (defun xp_xfa ()
  371.  
  372.   (setq e0 (entlast))
  373.   (setq en (entnext e0))
  374.   (while (not (null en))              ; find the last entity
  375.     (setq e0 en)
  376.     (setq en (entnext e0))
  377.   )
  378.  
  379.   (xp_mirrchk (xp_val -1 ent nil))    ; check entity and explode
  380.  
  381.   (setq s0 (ssadd))
  382.  
  383.   (while (entnext e0)
  384.     (ssadd (setq e0 (entnext e0))
  385.            s0
  386.     )
  387.   )
  388.   (command "_.CHPROP" s0 ""             ; change entities to the proper layer
  389.            "_C"  color                 ; color, and linetype, regardless
  390.            "_LT" ltype                 ; of their extrusion direction
  391.            "_LA" layer
  392.            ""
  393.   )
  394. )
  395. ;;;
  396. ;;; Inherit attributes (if BYBLOCK) from parent.
  397. ;;;
  398. ;;; xp_iap == XPlode_Inherit_Attributes_from_Parent
  399. ;;;
  400. (defun xp_iap (t1 / t1cl t1lt t1ly s0ly s0lt s0cl t0e)
  401.   (setq yyy t1)
  402.   (setq t0 (entlast))
  403.   (setq tn (entnext t0))
  404.   (while (not (null tn))              ; find the last entity
  405.     (setq t0 tn)
  406.     (setq tn (entnext t0))
  407.   )
  408.  
  409.   (setq t1cl (xp_val 62 t1 nil))      ; record the attributes of the block
  410.   (setq t1lt (xp_val 6  t1 nil))
  411.   (setq t1ly (xp_val 8  t1 nil))
  412.   (xp_mirrchk (xp_val -1 t1 nil))     ; check entity and explode
  413.   (setq s0ly (ssadd))                 ; create nil selection sets for layer
  414.   (setq s0lt (ssadd))                 ; linetype and color changes
  415.   (setq s0cl (ssadd))
  416.   (setq t0 (entnext t0))
  417.   (while t0                           ; can exploded entities
  418.     (setq t0e (entget t0))            ; and build selection sets
  419.  
  420.     (if (=  (xp_val 62 t0e T) "BYBLOCK") (ssadd t0 s0cl))
  421.     (if (=  (xp_val 6  t0e T) "BYBLOCK") (ssadd t0 s0lt))
  422.     (if (=  (xp_val 8  t0e T) "0")       (ssadd t0 s0ly))
  423.     (setq t0 (entnext t0))
  424.   )
  425.   (if (> (sslength s0cl) 0)           ; is selection set non-nil...
  426.       (command "_.CHPROP" s0cl ""       ; Change exploded entities with color
  427.                "_CO" t1cl "")          ; BYBLOCK to color of old block
  428.   )
  429.   (if (> (sslength s0lt) 0)
  430.       (command "_.CHPROP" s0lt ""       ; Change exploded entities with linetype
  431.                "_LT" t1lt "")          ; BYBLOCK to linetype of old block
  432.   )
  433.   (if (> (sslength s0ly) 0)
  434.       (command "_.CHPROP" s0ly ""       ; Change exploded entities with linetype
  435.                "_LA" t1ly "")          ; BYBLOCK to linetype of old block
  436.   )
  437.   (if (or (= ans "Individually") (= j (1- sslen)))
  438.     (progn
  439.       (if (and (> sslen 1) (= ans "Globally"))
  440.         (princ "\n╣╧ñ╕")
  441.         (princ "\n╣╧ñ╕")
  442.       )
  443.       (princ "ñwíu¼╡╢}ívíC")
  444.     )
  445.   )
  446. )
  447.  
  448. ;;;
  449. ;;; Set the color for the exploded entities.
  450. ;;;
  451. ;;; xp_scn == XPlode_Set_Color_Number
  452. ;;;
  453. (defun xp_scn ()
  454.   (setq arg 257)
  455.   (while (> arg 256)
  456.     (initget 2 "Red Yellow Green Cyan Blue Magenta White BYLayer BYBlock")
  457.     (setq arg (getint (strcat
  458.       "\n\níu¼╡╢}ív½ß╖s╣╧ñ╕¬║íu├CªΓíví╨ "
  459.       "\nR¼⌡/Y╢└/G║±/Cñ⌠┬┼/B┬┼/"
  460.       "M╡╡¼⌡/WÑ╒/BYL¿╠╖╙╣╧╝h/BYB¿╠╖╙╣╧╕s/<"
  461.       (if (= (type (getvar "cecolor")) 'INT)
  462.         (itoa (getvar "cecolor"))
  463.         (getvar "cecolor")
  464.       )
  465.       ">: ")))
  466.     (cond
  467.       ((= arg "BYBlock") (setq arg 0))
  468.       ((= arg "Red")     (setq arg 1))
  469.       ((= arg "Yellow")  (setq arg 2))
  470.       ((= arg "Green")   (setq arg 3))
  471.       ((= arg "Cyan")    (setq arg 4))
  472.       ((= arg "Blue")    (setq arg 5))
  473.       ((= arg "Magenta") (setq arg 6))
  474.       ((= arg "White")   (setq arg 7))
  475.       ((= arg "BYLayer") (setq arg 256))
  476.       (T
  477.         (if (= (type arg) 'INT)
  478.           (if (> arg 255)
  479.             (progn
  480.               (princ "\níu├CªΓ╜Xív╢WÑX╜d│≥ 1 í╨ 255 íC")
  481.               (setq arg 257) ; kludge
  482.             )
  483.           )
  484.           (setq arg (if (= (type (setq arg (getvar "cecolor"))) 'INT)
  485.                       (getvar "cecolor")
  486.                       (cond
  487.                         ((= arg "BYBLOCK") (setq arg 0))
  488.                         ((= arg "BYLAYER") (setq arg 256))
  489.                       )
  490.                     )
  491.           )
  492.         )
  493.       )
  494.     )
  495.   )
  496.   (cond
  497.     ((= arg 0) (setq arg "BYBLOCK"))
  498.     ((= arg 256) (setq arg "BYLAYER"))
  499.   )
  500.   arg
  501. )
  502. ;;;
  503. ;;; Set the linetype from the loaded linetypes.
  504. ;;;
  505. ;;; xp_slt == XPlode_Set_Line_Type
  506. ;;;
  507. (defun xp_slt ()
  508.   (princ "\n\nÑ╤ÑHñUªCÑ▄¬║╜u½¼ññ¼D┐∩...")
  509.   (tblnext "ltype" T)
  510.   (setq xp_lta "CONTINUOUS,CONT BYLayer BYBlock"
  511.         xp_ltb "BYB¿╠╖╙╣╧╕s/BYL¿╠╖╙╣╧╝h/CONT│s─≥╜u")
  512.  
  513.   (while (setq xp_lt (cdr(assoc 2 (tblnext "ltype"))))
  514.     (setq xp_lta (strcat xp_lta " " xp_lt)
  515.           xp_ltb (strcat xp_ltb "/" xp_lt))
  516.   )
  517.   (initget xp_lta)
  518.   (princ (strcat
  519.     "\n┐ΘñJ╖s¬║íu╜u½¼ívªW║┘  \n" xp_ltb "/<"
  520.     (getvar "celtype") "> : "))
  521.   (setq xp_nln (getkword) )
  522.   (if (or (= xp_nln nil) (= xp_nln ""))
  523.     (setq xp_nln (getvar "celtype"))
  524.   )
  525.   xp_nln
  526. )
  527. ;;;
  528. ;;; Set a layer if it exists.
  529. ;;;
  530. ;;; xp_sla == XPlode_Set_LAyer
  531. ;;;
  532. (defun xp_sla (/ temp)
  533.   (while (null temp)
  534.     (initget 1)
  535.     (setq temp (getstring (strcat
  536.       "\n\níu¼╡╢}ív½ß╣w│╞⌐±╕m¬║íu╣╧╝hívªW║┘?  <" (getvar "clayer") ">: ")))
  537.     (if (or (= temp "") (null temp))
  538.       (setq temp (getvar "clayer"))
  539.       (if (not (tblsearch "layer" temp))
  540.         (progn
  541.           (princ "\n╡L«─¬║íu╝hªWívíC")
  542.           (setq temp nil)
  543.         )
  544.       )
  545.     )
  546.   )
  547.   temp
  548. )
  549.  
  550. ;;; ------------------ xp_mirrchk == mirror check ------------------------------;
  551. ;;;
  552. ;;;  Check entity type ...
  553. ;;;
  554. ;;;  If it's a block with equal absolute scale factors but differing signs
  555. ;;;  (i.e. -1,1,1), then:
  556. ;;;
  557. ;;;      1) copy the block off screen
  558. ;;;      2) modify the block with positive scale factors
  559. ;;;      3) explode the block
  560. ;;;      4) mirror or rotate the resulting entities
  561. ;;;      5) erase the original block
  562. ;;;      6) move the exploded entites into position
  563. ;;;
  564. ;;;  Else, just explode the block, polyline or dimension.
  565. ;;;
  566. (defun xp_mirrchk (e / elist etype laste icon xoffset ss
  567.      xscl yscl zscl xsclist)
  568.   (setq elist (entget e))
  569.   (setq etype (cdr (assoc 0 elist)))
  570.   (setq xscl (cdr (setq xsclist (assoc 41 elist))))
  571.   (setq yscl (cdr (setq ysclist (assoc 42 elist))))
  572.   (setq zscl (cdr (setq zsclist (assoc 43 elist))))
  573.   (if (and (equal etype "INSERT")
  574.              (not (and (= xscl yscl) (= xscl zscl)))
  575.       )
  576.       (progn
  577.         (command "_.UNDO" "_GROUP")
  578.         (setq icon (getvar "ucsicon"))
  579.         (setvar "ucsicon" 0)
  580.         (setq xoffset (list (* (getvar "viewsize") 3) 0))
  581.         (setq ss (ssadd))
  582.         (setq laste (entlast))
  583.         (command "_.UCS" "_V")
  584.         (command "_.COPY" e "" '(0 0) xoffset)
  585.         (setq elist (entget (entlast)))
  586.         (command "_.UCS" "_E" (entlast))
  587.         (setq elist (subst (cons 41 (abs xscl)) xsclist elist))
  588.         (setq elist (subst (cons 42 (abs yscl)) ysclist elist))
  589.         (setq elist (subst (cons 43 (abs zscl)) zsclist elist))
  590.         (entmod elist)
  591.         (command "_.EXPLODE" (entlast))
  592.         (while (setq next (entnext laste))
  593.              (ssadd next ss)
  594.              (setq laste next)
  595.         )
  596.         (cond ((and (minusp xscl)
  597.                             (not (minusp yscl))
  598.                             (not (minusp zscl))
  599.                        ) (-xyz)
  600.                       )
  601.                       ((and (not (minusp xscl))
  602.                             (not (minusp yscl))
  603.                             (minusp zscl)
  604.                        ) (xy-z)
  605.                       )
  606.                       ((and (minusp xscl)
  607.                             (not (minusp yscl))
  608.                             (minusp zscl)
  609.                        ) (-xy-z)
  610.                       )
  611.                       ((and (not (minusp xscl))
  612.                             (minusp yscl)
  613.                             (not (minusp zscl))
  614.                        ) (x-yz)
  615.                       )
  616.                       ((and (minusp xscl)
  617.                             (minusp yscl)
  618.                             (not (minusp zscl))
  619.                        ) (-x-yz)
  620.                       )
  621.                       ((and (not (minusp xscl))
  622.                             (minusp yscl)
  623.                             (minusp zscl)
  624.                        ) (x-y-z)
  625.                       )
  626.         )
  627.         (command "_.ERASE" e "")
  628.         (command "_.UCS" "_P")
  629.         (command "_.MOVE" ss "" xoffset '(0 0))
  630.         (command "_.UCS" "_P")
  631.         (setvar "ucsicon" icon)
  632.         (command "_.UNDO" "_END")
  633.       )
  634.       (command "_.EXPLODE" (xp_val -1 ent nil))
  635.   )
  636. )
  637. ;;;
  638. ;;;  Functions that reposition exploded modified block into place
  639. ;;;
  640. (defun -xyz ()
  641.   (command "_.MIRROR" ss "" '(0 0) '(0 1) "y")
  642. )
  643.  
  644. (defun xy-z ()
  645.   (command "_.UCS" "_Y" "90")
  646.   (command "_.MIRROR" ss "" '(0 0) '(0 1) "_Y")
  647.   (command "_.UCS" "_P")
  648. )
  649.  
  650. (defun -xy-z ()
  651.   (command "_.UCS" "_X" "90")
  652.   (command "_.ROTATE" ss "" '(0 0) "180")
  653.   (command "_.UCS" "_P")
  654. )
  655.  
  656. (defun x-yz ()
  657.   (command "_.MIRROR" ss "" '(0 0) '(1 0) "_Y")
  658. )
  659.  
  660. (defun -x-yz ()
  661.   (command "_.MIRROR" ss "" '(0 0) '(1 0) "_Y")
  662.   (command "_.MIRROR" ss "" '(0 0) '(0 1) "_Y")
  663. )
  664.  
  665. (defun x-y-z ()
  666.   (command "_.UCS" "_Y" "90")
  667.   (command "_.ROTATE" ss "" '(0 0) "180")
  668.   (command "_.UCS" "_P")
  669. )
  670.  
  671. ;;; --------------------------------------------------------------------------;
  672. (defun c:xp       () (explode))
  673. (defun c:xplode   () (explode))
  674. (princ
  675.   "\n\tíuC:XPlodeívñw╕ⁿñJ; ╜╨ÑH XP ⌐╬ XPLODE ▒╥░╩½ⁿÑOíC")
  676. (princ)
  677.