Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: LISP to detach all XREF,PDF,IMAGE,ALL UNDERLAYS

  1. #21
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: LISP to detach all XREF,PDF,IMAGE,ALL UNDERLAYS

    Much more simplified, based on dictionary names definitions :

    * dictionary names :
    Code:
    (defun c:dict ( / dictcoll dictlst)
    (vl-load-com)
    (setq dictcoll (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for di dictcoll
    (setq dictlst (cons (vl-catch-all-apply 'vla-get-name (list di)) dictlst))
    )
    (setq dictlst (reverse dictlst))
    (princ dictlst)
    (textscr)
    (princ)
    )
    * detachall lsp - simplified :
    Code:
    (defun c:detachall ( / mspcoll dictcoll)
    (vl-load-com)
    (vl-cmdf "_.-xref" "D" "*")
    (vl-cmdf "_.-image" "D" "*")
    (setq mspcoll (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for ent mspcoll
    (if 
    (or 
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbDwfReference")
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbPdfReference")
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbDgnReference")
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbOle2Frame")
    )
    (vla-delete ent)
    )
    )
    (setq dictcoll (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for di dictcoll
    (if 
    (or 
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_IMAGE_DICT")
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_PDFDEFINITIONS")
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_DGNDEFINITIONS")
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_DWFDEFINITIONS")
    )
    (progn
    (vlax-for d di
    (vla-delete d)
    )
    (vla-delete di)
    )
    )
    )
    (vl-cmdf "_.externalreferences")
    (princ)
    )
    M.R.
    P.S. After detachall.lsp, dwg has to be saved and reopened in order to get rid of dgn unreferenced layers stored in purge definitions...
    Last edited by marko_ribar; 2011-07-05 at 07:53 AM.

  2. #22
    Member
    Join Date
    2005-08
    Posts
    8
    Login to Give a bone
    0

    Default Re: LISP to detach all XREF,PDF,IMAGE,ALL UNDERLAYS

    Quote Originally Posted by marko_ribar View Post
    Much more simplified, based on dictionary names definitions :

    * dictionary names :
    Code:
    (defun c:dict ( / dictcoll dictlst)
    (vl-load-com)
    (setq dictcoll (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for di dictcoll
    (setq dictlst (cons (vl-catch-all-apply 'vla-get-name (list di)) dictlst))
    )
    (setq dictlst (reverse dictlst))
    (princ dictlst)
    (textscr)
    (princ)
    )
    * detachall lsp - simplified :
    Code:
    (defun c:detachall ( / mspcoll dictcoll)
    (vl-load-com)
    (vl-cmdf "_.-xref" "D" "*")
    (vl-cmdf "_.-image" "D" "*")
    (setq mspcoll (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for ent mspcoll
    (if 
    (or 
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbDwfReference")
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbPdfReference")
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbDgnReference")
    (eq (vl-catch-all-apply 'vla-get-objectname (list ent)) "AcDbOle2Frame")
    )
    (vla-delete ent)
    )
    )
    (setq dictcoll (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for di dictcoll
    (if 
    (or 
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_IMAGE_DICT")
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_PDFDEFINITIONS")
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_DGNDEFINITIONS")
    (eq (vl-catch-all-apply 'vla-get-name (list di)) "ACAD_DWFDEFINITIONS")
    )
    (progn
    (vlax-for d di
    (vla-delete d)
    )
    (vla-delete di)
    )
    )
    )
    (vl-cmdf "_.externalreferences")
    (princ)
    )
    M.R.
    P.S. After detachall.lsp, dwg has to be saved and reopened in order to get rid of dgn unreferenced layers stored in purge definitions...
    Wow.. Fantastic Marko!!
    Thank you very much..

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 0
    Last Post: 2014-07-08, 02:28 PM
  2. .png image will not detach!
    By Openwheeler in forum AutoCAD Map 3D - General
    Replies: 3
    Last Post: 2010-03-10, 04:39 PM
  3. Unable to detach xref
    By michael.12445 in forum AutoCAD General
    Replies: 9
    Last Post: 2008-02-28, 01:19 PM
  4. Detach Image IF it exists
    By jpaulsen in forum AutoLISP
    Replies: 9
    Last Post: 2007-03-02, 11:01 PM
  5. Cannot detach a xref
    By kleenhippie in forum AutoCAD General
    Replies: 2
    Last Post: 2005-08-24, 04:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •