home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 10.img / BONUS3.LIB / XREFCLIP.LSP < prev   
Encoding:
Text File  |  1993-02-08  |  16.5 KB  |  573 lines

  1. ;;;   XrefClip.lsp
  2. ;;;   (C) ¬⌐┼v 1988-1992  Autodesk ñ╜Ñq
  3. ;;;
  4. ;;;   Ñ╗╡{ªíñwÑ╤ Autodesk ñ╜Ñq╡∙ÑU¬⌐┼v, ╢╚⌐≤ñU¡z▒í¬pñUÑi▒┬╗P▒zíu│\ÑiívíC
  5. ;;;   ╗╒ñUñú▒oÑHÑ⌠ª≤º╬ªí╡oªµ⌐╬ÑX¬⌐ª╣╡{ªí¬║íu¡∞⌐l╜Xív; ª²ñ╣│\▒zªb»S⌐w¡lÑ═
  6. ;;;   ¬║ñuº@ñW╡▓ªXª╣╡{ªí¬║íuÑ╪¬║╜Xív¿╧Ñ╬íCª│├÷│o├■¡lÑ═ñuº@¬║▒°Ñ≤ªpñU:
  7. ;;;
  8. ;;;   ( i)  │]¡pñW╗Pñuº@ñW¼╥»┬║Θ░w╣∩ Autodesk ñ╜Ñq¬║▓ú½~íC
  9. ;;;   (ii)  ╕ⁿª│íu¬⌐┼v  (C) 1988-1992  Autodesk ñ╜Ñqív¬║¬⌐┼v│qºiíC
  10. ;;;
  11. ;;;
  12. ;;;
  13. ;;;   AUTODESKñ╜Ñq┤ú¿╤ª╣╡{ªí╢╚¿╤º@íu├■ªⁿív¬║░╤ª╥, ª╙ÑBñú▒╞░úª│Ñ⌠ª≤┐∙╗~¬║
  14. ;;;   Ñi»αíCAUTODESKñ╜Ñq»Sª╣º_╗{Ñ⌠ª≤»S⌐wÑ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºt
  15. ;;;   ÑX¿π¬║½O├╥íCAUTODESKñ╜ÑqªP«╔ÑτñúÑX¿πª╣╡{ªí░⌡ªµ«╔ñ@⌐wñú╖|íuññ┬_ív⌐╬
  16. ;;;   íuº╣Ñ■╡L╗~ív¬║½O├╥íC
  17. ;;;
  18. ;;;
  19. ;;;   by Jan S. Yoder
  20. ;;;   02 July 1990
  21. ;;;
  22. ;;;----------------------------------------------------------------------------
  23. ;;; DESCRIPTION
  24. ;;;
  25. ;;;   This routine is intended to make the task of inserting, sizing, and
  26. ;;;   positioning of external references easier, by clearing the screen of
  27. ;;;   all graphics, creating a viewport exclusively for the XREF, creating
  28. ;;;   a layer on which to attach the XREF, and zooming to the extents of
  29. ;;;   the XREF in current UCS plan view.
  30. ;;;
  31. ;;;   The routine may be called with either XC or XREFCLIP.
  32. ;;;
  33. ;;;   If TILEMODE is set to 1 or ON, you are asked whether you want to reset
  34. ;;;   it, and if not, you are exited from the routine.  If you elect to change
  35. ;;;   it, or it is already 0 or OFF, then you are prompted:
  36. ;;;
  37. ;;;     XrefClip, Version 1.00, (c) 1990 by Autodesk, Inc.
  38. ;;;     Xref name:
  39. ;;;     XrefClip onto what layer?
  40. ;;;
  41. ;;;   The XREF name must be a valid drawing file name that can be found on
  42. ;;;   AutoCAD's search paths.  The layer name must not be the name of an
  43. ;;;   existing layer name;  if it is you are so informed and asked for a
  44. ;;;   new name.
  45. ;;;
  46. ;;;   At this point, all of the viewports are turned off, and all thawed
  47. ;;;   layers are frozen.  A new viewport is fit to the screen, and the
  48. ;;;   XREF is attached to the layer specified in that viewport.  The XREF
  49. ;;;   is zoomed to its extents so that you may select the area you want to
  50. ;;;   clip (inclusively.)
  51. ;;;
  52. ;;;   You are prompted for the two clip points;
  53. ;;;
  54. ;;;     First point of clip box:
  55. ;;;     Other point of clip box:
  56. ;;;
  57. ;;;   and the zoom ratio;
  58. ;;;
  59. ;;;     Enter the ratio of paper space units to model space units...
  60. ;;;     Number of paper space units.  <1.0>:
  61. ;;;     Number of model space units.  <1.0>: (8)
  62. ;;;
  63. ;;;   All of the viewports are restored to their former state, and a box
  64. ;;;   designating the clipped viewport can be dragged around and you are
  65. ;;;   prompted for a location for the clipped view.
  66. ;;;
  67. ;;;     Insertion point for XrefClip:
  68. ;;;
  69. ;;;   A new viewport containing the clipped view of the XREF will be inserted
  70. ;;;   at the location specified.
  71. ;;;
  72. ;;;
  73. ;;; REVISIONS
  74. ;;;
  75. ;;;   Version 1.10 -- 11 Mar 1991 - Fixed multiple XREF of a file.
  76. ;;;   Version 1.11 -- 27 Mar 1991 - Fixed ZOOM problem.
  77. ;;;
  78. ;;;
  79. ;;;
  80. ;;;
  81. ;;;----------------------------------------------------------------------------;
  82. ;;;
  83. ;;;
  84. (defun xcmain ( / xc_err s xc_oer xc_oce xc_oem xc_olu xc_ocv
  85.                   curlay xc_nam lay xc:sov xc_vpn xc:ltg xc:ltl)
  86.  
  87.   ;;
  88.   ;; Internal error handler defined locally
  89.   ;;
  90.  
  91.   (defun xc_err (s)                   ; If an error (such as CTRL-C) occurs
  92.                                       ; while this command is active...
  93.     (if (/= s "Function cancelled")
  94.       (if (= s "quit / exit abort")
  95.         (princ)
  96.         (princ (strcat "\n┐∙╗~: " s))
  97.       )
  98.     )
  99.     (if (= 8 (logand (getvar "undoctl")))(command "_.UNDO" "_EN"))
  100.     (if xc_oer                        ; If an old error routine exists
  101.       (setq *error* xc_oer)           ; then, reset it
  102.     )
  103.     (if xc_oce (setvar "cmdecho" xc_oce)) ; Reset command echoing on error
  104.     (if xc_oem (setvar "expert" xc_oem)) ; Reset expert mode on error
  105.     (princ)
  106.   )
  107.  
  108.   (if *error*                         ; If there is an error routine defined
  109.     (setq xc_oer   *error*            ; Store AutoLisp error routine
  110.           *error*  xc_err)            ; Temporarily replace it
  111.   )
  112.  
  113.   (setq xc_oce (getvar "cmdecho"))
  114.   (setq xc_oem (getvar "expert"))
  115.   (setvar "cmdecho" 0)                ; Turn off command echoing
  116.   (setvar "expert" 5)                 ; Turn expert mode way up.
  117.   (command "_.UNDO" "_GROUP")            ; Set start of Undo group
  118.   (if (xc_ctm)                        ; Is Tile-mode on? T or nil
  119.     (progn
  120.       (xc_sxc)                        ; Set up for Xref Clip
  121.       (xc_dxc)                        ; Do XREF clipping
  122.     )
  123.   )
  124.   (if (/= xc_ocv 1) (setvar "cvport" xc_ocv) (command "_.PSPACE"))
  125.   (command "_.LAYER" "_SET" curlay "")
  126.   (if xc_oer                          ; If an old error routine exists
  127.     (setq *error* xc_oer)             ; then, reset it
  128.   )
  129.   (command "_.UNDO" "_END")              ; Set Undo End
  130.  
  131.   (if xc_oem (setvar "expert" xc_oem)) ; Reset expert mode
  132.   (if xc_oce (setvar "cmdecho" xc_oce)) ; Reset command echoing
  133.   (princ)
  134. )
  135. ;;;
  136. ;;; Check Tile-mode.  Returns T if ON and nil if not on.
  137. ;;;
  138. ;;; xc_ctm == MView_Check_TileMode
  139. ;;;
  140. (defun xc_ctm (/ ans)
  141.   (if (= (getvar "TILEMODE") 1)
  142.     (progn
  143.       (initget "Yes No")
  144.       (setq ans (getkword (strcat
  145.         "\nÑ╝▒╥Ñ╬íu╣╧»╚¬┼╢íí■╝╥½¼¬┼╢íívÑ\»α; ╢╖▒╥Ñ╬ª╣Ñ\»αñ~Ñi¿╧Ñ╬Ñ╗▒`ªííC"
  146.         "\n▒╥Ñ╬íu╣╧»╚¬┼╢íí■╝╥½¼¬┼╢íív? <Y>: "))
  147.       )
  148.       (if (= ans "No")
  149.         nil
  150.         (progn
  151.           (setvar "TILEMODE" 0)
  152.           T
  153.         )
  154.       )
  155.     )
  156.     T
  157.   )
  158. )
  159. ;;;
  160. ;;; Get set up for reference file clipping; get the file name, the layer to
  161. ;;; put it on, and make the layers, and set up all of the layers correctly
  162. ;;; to minimize "viewports".
  163. ;;;
  164. ;;; xc_sxc == MView_Setup_for_Xref_Clip
  165. ;;;
  166. (defun xc_sxc (/ xc_ver xc_xdf xc_xlf xref xdpnd)
  167.  
  168.   (setq xc_ver "1.11")                ; Reset this local if you make a change.
  169.  
  170.   (setq xc_ocv (getvar "cvport"))
  171.   (if (/= xc_ocv 1)
  172.     (command "_.PSPACE")                ; Change to paperspace
  173.   )
  174.  
  175.   (princ (strcat
  176.     "\nXrefClip, ¬⌐Ñ╗ " xc_ver ", (c) 1990  Autodesk ñ╜ÑqíC "))
  177.  
  178.   (setq xref T)
  179.  
  180.  
  181.   ;; Save the current layer name.
  182.   (setq curlay (getvar "clayer"))
  183.  
  184.   ;; Get the name of the xref...
  185.   (setq xc_nam (xc_gxn))
  186.  
  187.   ;; Check whether the XREF has already been attached.  Or whether a block
  188.   ;; by that name exists in the current drawing.
  189.   ;;   xc_xrs == xref_status == 0 -- not in current drawing.
  190.   ;;                            1 -- Xref in current drawing.
  191.   ;;                            2 -- Block ref in current drawing.
  192.   ;; Also set xdpnd True if the layer on which the Xref or block insert
  193.   ;; has been placed is an exclusive layer, nil otherwise.
  194.   (setq xc_xrs (xc_gxs xc_nam))
  195.  
  196.   ;; Get a layer name for the Xref.  It must not already exist!
  197.   (setq lay (xc_gln))
  198.  
  199.   ;; Make a layer for the new viewport.
  200.   (command "_.VPLAYER" "_NEW" (strcat lay "-vp") "")
  201.   (command "_.VPLAYER" "_F" (strcat lay "-vp") "_ALL"
  202.            "_T" (strcat lay "-vp") "" "")
  203.   (command "_.LAYER" "_SET" (strcat lay "-vp") "")
  204.  
  205.   ;; Save the names of all the layers that are thawed globally.
  206.   (xc_sgt)
  207.  
  208.   ;; Freeze all of 'em except the current layer.
  209.   (command "_.LAYER" "_F" (strcat "~" lay "-vp") "")
  210.  
  211.   ;; Save the names of all the viewports that are ON.
  212.   (xc_sov)
  213.  
  214.   ;; Freeze all of 'em except the current layer.
  215.   (command "_.MVIEW" "_OFF" xc:sov "")
  216.  
  217.   ;; Create a new viewport on the viewport layer.  Fit it to the screen.
  218.   (command "_.MVIEW" "_F")
  219.  
  220.   ;; Make a new layer for the Xref.  Make it exclusive.
  221.   (command "_.VPLAYER" "_NEW" lay "")
  222.   (command "_.VPLAYER" "_F" lay "_ALL" "_T" lay "_S" "_L" "" "")
  223.  
  224.   ;; Save the entity name of the viewport.
  225.   (setq xc_vpn (entlast))
  226.  
  227.   (if (= (getvar "cvport") 1)
  228.     (command "_.MSPACE")                ; Change to modelspace
  229.   )
  230.  
  231.   ;; If xdpnd is true, thaw the layer on which the xref or insert has
  232.   ;; been placed previously.
  233.   (if xdpnd
  234.     (progn
  235.       (command "_.LAYER" "_T" xc_xrl "_T" (strcat xc_xri "*") "")
  236.       (command "_.VPLAYER" "_T" xc_xrl "_CUR" "")
  237.     )
  238.   )
  239.  
  240.   (command "_.LAYER" "_SET" lay "")
  241.  
  242.   (if (not xdpnd)
  243.     (progn
  244.       (command "_.VPLAYER" "_F" (strcat "~" lay) "" "")
  245.     )
  246.   )
  247.   ;; Do the Xref attach or block insertion.
  248.   (command "_.XREF" "" xc_nam "0,0" "" "" "")
  249.  
  250.   ;; Zoom extents in plan view
  251.   (command "_.ZOOM" "_E")
  252. )
  253. ;;;
  254. ;;;
  255. ;;;
  256. ;;;
  257. ;;; xc_dxc == MView_Do_Xref_Clip
  258. ;;;
  259. (defun xc_dxc (/ xc:cp1 xc:cp2 xc_vps xs ys nxs nys ip)
  260.   ;; Get the first point of the clip box.
  261.   (setq xc:cp1 (getpoint "\níu║I«╪ív▓─ñ@¿ñ┬I: "))
  262.  
  263.   ;; Get the other point of the clip box.
  264.   (setq xc:cp2 (getcorner xc:cp1 "\níu║I«╪ívÑtñ@¿ñ┬I: "))
  265.  
  266.   ;; Sort the two points into lower-left to upper-right order.
  267.   (if (> (car xc:cp1) (car xc:cp2))
  268.     (setq x (car xc:cp1)
  269.           xc:cp1 (list (car xc:cp2) (cadr xc:cp1) 0.0)
  270.           xc:cp2 (list x (cadr xc:cp2) 0.0)
  271.     )
  272.   )
  273.   (if (> (cadr xc:cp1) (cadr xc:cp2))
  274.     (setq x (cadr xc:cp1)
  275.           xc:cp1 (list (car xc:cp1) (cadr xc:cp2) 0.0)
  276.           xc:cp2 (list (car xc:cp2) x 0.0)
  277.     )
  278.   )
  279.  
  280.   (if (/= (getvar "cvport") 1)
  281.     (command "_.PSPACE")                ; Change to paperspace
  282.   )
  283.  
  284.   ;; Get the scale of the clip region.
  285.   (setq xc_vps (xc_ssi))
  286.  
  287.   ;; Set the X and Y scale factors based on the two points
  288.   ;; and the scale factor entered.
  289.   (setq xs (- (car  xc:cp2) (car  xc:cp1))
  290.         ys (- (cadr xc:cp2) (cadr xc:cp1))
  291.         nxs (/ xs xc_vps)
  292.         nys (/ ys xc_vps)
  293.   )
  294.   ;; Delete the last viewport.
  295.   (entdel xc_vpn)
  296.  
  297.   ;; Turn back ON all of the viewports.
  298.   (command "_.MVIEW" "_ON" xc:sov "")
  299.  
  300.   ;; Thaw the layers which we froze earlier.
  301.   (command "_.LAYER")
  302.  
  303.   (foreach n xc:ltg (command "_THAW" n))
  304.   (command "")
  305.   (command "_.LAYER" "_SET" curlay "")
  306.  
  307.   (if (tblsearch "block" "xc_box")
  308.     (progn
  309.       (princ "\níuXrefClipív┤íñ▐┬I: ")
  310.       (command "_.INSERT" "xc_box" "_xscale" nxs "_yscale" nys "_rotate" 0 pause)
  311.     )
  312.     (progn
  313.       (command "_.PLINE" "0,0" "_W" "0" "" "1,0" "1,1" "0,1" "_CL")
  314.       (command "_.CHPROP" (entlast) "" "_C" "bylayer" "_LT" "bylayer" "_LA" "0" "")
  315.       (command "_.BLOCK" "xc_box" "0,0" (entlast) "")
  316.       (princ "\níuXrefClipív┤íñ▐┬I: ")
  317.       (command "_.INSERT" "xc_box" "_xscale" nxs "_yscale" nys "_rotate" 0 pause)
  318.     )
  319.   )
  320.  
  321.   ;; Get the block insertion point and scale factors.
  322.   (setq ip (xc_val 10 (entlast) nil))
  323.  
  324.   ;; Delete the block.
  325.   (entdel(entlast))
  326.  
  327.   ;;(princ "\n¡╫º∩╖síu╡°╡íívíC")
  328.  
  329.   ;; Create the new viewport.
  330.   (command "_.LAYER" "_SET" (strcat lay "-vp") "")
  331.   (command "_.VPLAYER" "_F" lay "_C" "")
  332.   (command "_.MVIEW" ip (strcat "@" (rtos nxs) "," (rtos nys) "," "0.0"))
  333.  
  334.   (setq xc_vpn (entlast))
  335.   (setq temp (xc_val 69 xc_vpn nil))
  336.  
  337.   (if (= (getvar "cvport") 1)
  338.     (command "_.MSPACE")                ; Change to modelspace
  339.   )
  340.  
  341.   (command "_.VPLAYER" "_F" lay "_ALL" "_T" lay "_S" "_L" "" "")
  342.  
  343.   (if (> (xc_val 68 xc_vpn nil) 0)
  344.     (progn
  345.  
  346.       (setvar "cvport" temp)
  347.  
  348.       (command "_.PLAN" "")
  349.       (command "_.ZOOM" "_C" (xc_a2p xc:cp1 xc:cp2) ys)
  350.     )
  351.     (princ "\níu╡°╡íívñ╙ñpíC")
  352.   )
  353.  
  354. )
  355. ;;;
  356. ;;; Get the midpoint between two points.
  357. ;;;
  358. ;;; xc_a2p == XrefClip_Average_2_Points
  359. ;;;
  360. (defun xc_a2p (a b / c)
  361.   (setq c (list (/ (+ (car  a) (car  b)) 2.0)
  362.                 (/ (+ (cadr a) (cadr b)) 2.0)
  363.                 0.0
  364.           )
  365.   )
  366. )
  367. ;;;
  368. ;;; Get the value associated with key "n" in "e".
  369. ;;; If "f" is T the "e" is an entity list, else it is an entity name.
  370. ;;;
  371. ;;; xc_val == XrefClip_assoc_VALue
  372. ;;;
  373. (defun xc_val (n e f)
  374.   (if f ; if f then e is an entity list.
  375.     (cdr (assoc n e))
  376.     (cdr (assoc n (entget e)))
  377.   )
  378. )
  379.  
  380. ;;;
  381. ;;; Save the names of all the viewports that are ON,
  382. ;;; because we are going to temporarily turn them all OFF.
  383. ;;;
  384. ;;; xc_sov == XrefClip_Save_On_Viewports
  385. ;;;
  386. (defun xc_sov (/ ss sov sslen)
  387.   (setq xc:sov (ssadd)
  388.         j      0
  389.   )
  390.   (setq ss (ssget "x" '((0 . "viewport")))) ; Get all vports in database.
  391.   (setq sslen (sslength ss))
  392.   (while (< j sslen)
  393.     (setq sov (ssname ss j))
  394.     (if (and (> (xc_val 68 sov nil) 1) (/= (xc_val 69 sov nil) 1))
  395.       (ssadd sov xc:sov)
  396.     )
  397.     (setq j (1+ j))
  398.   )
  399.   xc:sov
  400. )
  401. ;;;
  402. ;;; Save the layer names of all the layers that are globally Thawed,
  403. ;;; because we are going to temporarily Freeze all of them.
  404. ;;;
  405. ;;; xc_sgt == XrefClip_Save_Globally_Thawed_layers
  406. ;;;
  407. (defun xc_sgt (/ lay)
  408.   (setq lay (tblnext "layer" T))      ; Get first layer in database.
  409.   (if (/= (logand (cdr(assoc 70 lay)) 1) 1)
  410.     (setq xc:ltg (list (cdr(assoc 2 lay))))
  411.   )
  412.   (while (setq lay (tblnext "layer"))
  413.     (if (/= (logand (cdr(assoc 70 lay)) 1) 1)
  414.       (setq xc:ltg (append xc:ltg (list (cdr(assoc 2 lay)))))
  415.     )
  416.   )
  417.   xc:ltg
  418. )
  419. ;;;
  420. ;;; Save the layer names of all the layers in the current viewport that
  421. ;;; are locally thawed, because we are going to temporarily freeze them.
  422. ;;;
  423. ;;; xc_slt == XrefClip_Save_Locally_Thawed_layers
  424. ;;;
  425. (defun xc_slt (/ lay)
  426.   (setq lay (tblnext "layer" T))      ; Get first layer in database.
  427.   (if (/= (logand (cdr(assoc 70 lay)) 2) 2)
  428.     (setq xc:ltl (list (cdr(assoc 2 lay))))
  429.   )
  430.   (while (setq lay (tblnext "layer"))
  431.     (if (/= (logand (cdr(assoc 70 lay)) 2) 2)
  432.       (setq xc:ltl (append xc:ltl (list (cdr(assoc 2 lay)))))
  433.     )
  434.   )
  435.   xc:ltl
  436. )
  437. ;;;
  438. ;;; Set a layer if it exists?  Create it otherwise?
  439. ;;;
  440. ;;; xc_gln == XrefClip_Get_Layer_Name
  441. ;;;
  442. (defun xc_gln (/ temp)
  443.   (while (null temp)
  444.     (setq temp (getstring
  445.       "\n\níuXrefClipív╕m⌐≤ª≤╝h? ")
  446.     )
  447.     (if (tblsearch "layer" temp)
  448.       (progn
  449.         (princ "\níu╣╧╝hívñwªsªbíC")
  450.         (setq temp nil)
  451.       )
  452.     )
  453.   )
  454.   temp
  455. )
  456. ;;;
  457. ;;; Get the xref file name and verify that it exists.
  458. ;;;
  459. ;;; xc_gxn == XrefClip_Get_Xref_Name
  460. ;;;
  461. (defun xc_gxn (/ temp xc_nam sl a b)
  462.   (while (null xc_nam)
  463.     (setq temp (getstring (strcat
  464.       "\níuÑ~│í░╤ª╥ívªW║┘: "))
  465.     )
  466.     (setq sl (strlen temp))
  467.  
  468.     (if (and (> sl 4) (= (substr temp (- sl 3)) ".dwg"))
  469.       (setq temp (substr temp 1 (- sl 4)))
  470.     )
  471.  
  472.     (if (setq xc_nam (findfile (strcat temp ".dwg")))
  473.       (princ)
  474.       (princ (strcat "\nºΣñú¿∞íu" temp "ívíC"))
  475.  
  476.     )
  477.  
  478.     ;; Remove pathname
  479.     (setq a 1)
  480.     (repeat (strlen temp)
  481.       (if (member (substr temp a 1) '("/" "\\" ":"))
  482.         (setq b a)
  483.       )
  484.       (setq a (1+ a))
  485.     )
  486.     (if b
  487.       (setq temp (substr temp (1+ b)))
  488.     )
  489.     (setq xc_snm (strcase temp))
  490.   )
  491.   xc_nam
  492. )
  493. ;;;
  494. ;;; Interactively set the scale of each viewport.
  495. ;;;
  496. ;;; xc_ssi == XrefClip_Setup_Scale_Interactively
  497. ;;;
  498. (defun xc_ssi (/ ans)
  499.   (princ "\n┐ΘñJíu╣╧»╚¬┼╢í│µª∞ív╣∩íu╝╥½¼¬┼╢í│µª∞ív¬║ñ±¿╥... ")
  500.   (initget 6)
  501.   (setq ans (getreal
  502.     "\níu╣╧»╚¬┼╢í│µª∞ív╝╞¡╚ <1.0>: ")
  503.   )
  504.   (if (= (type ans) 'REAL)
  505.     (setq xc_vps ans)
  506.     (setq xc_vps 1.0)
  507.   )
  508.   (initget 6)
  509.   (setq ans (getreal
  510.     "\níu╝╥½¼¬┼╢í│µª∞ív╝╞¡╚ <1.0>: ")
  511.   )
  512.   (if (= (type ans) 'REAL)
  513.     (setq xc_vps (/ xc_vps ans))
  514.     (setq xc_vps (/ xc_vps 1.0))
  515.   )
  516.   xc_vps
  517. )
  518. ;;;
  519. ;;; Check whether the XREF has already been attached.  Or whether a block
  520. ;;; by that name exists in the current drawing.
  521. ;;;   xc_xrs == xref_status == 0 -- not in current drawing.
  522. ;;;                            1 -- Xref in current drawing.
  523. ;;;                            2 -- Block ref in current drawing.
  524. ;;;
  525. ;;; xc_gxs == XrefClip_Get_Xref_Status
  526. (defun xc_gxs (nam / ss)
  527.   (cond
  528.     ((and nam (setq ent (tblsearch "block" xc_snm)))
  529.       (cond
  530.         ((= (cdr(assoc 70 ent)) 4)
  531.           (setq flag 1)
  532.         )
  533.         (T
  534.           (setq flag 2)
  535.         )
  536.       )
  537.       (if (= (getvar "cvport") 1)
  538.         (command "_.MSPACE")                ; Change to modelspace
  539.       )
  540.       (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 xc_snm))))
  541.       (if ss
  542.         (setq xc_xre (entget (ssname ss 0))
  543.               xc_xri (cdr(assoc 2 xc_xre))
  544.               xc_xrl (tblsearch "layer" (cdr(assoc 8 xc_xre)))
  545.         )
  546.       )
  547.       (if (/= (getvar "cvport") 1)
  548.         (command "_.PSPACE")                ; Change to paperspace
  549.       )
  550.       (cond
  551.         ((= (logand (cdr(assoc 70 xc_xrl)) 2) 2)
  552.           (setq xdpnd T
  553.                 xc_xrl (cdr(assoc 2 xc_xrl))
  554.           )
  555.         )
  556.         (T
  557.           (setq xdpnd nil)
  558.         )
  559.       )
  560.     )
  561.     (T
  562.       (setq flag 0)
  563.     )
  564.   )
  565.   flag
  566. )
  567. ;;; --------------------------------------------------------------------------;
  568. (defun c:xc       () (xcmain))
  569. (defun c:xrefclip () (xcmain))
  570. (princ
  571.   "\n\tíuC:XrefClipívñw╕ⁿñJ; ╜╨ÑH XC ⌐╬ XREFCLIP ▒╥░╩½ⁿÑOíC")
  572. (princ)
  573.