Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete all OLE objects from drawing

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
miroko
6550 Views, 8 Replies

Delete all OLE objects from drawing

Hello

 

Question is how to delete all OLE objects from drawing by most efficient way.

There are abt 150 drawings, each has from 2 to 20 or so OLE objects which need to be deleted. OLE objects are on many paper spaces.

 

I tried to use qselect but it selects only what is in current space.

Would need some lisp or some other methode than all can be deleted (excluding those which resides in blocks).

Tried also yto use ssx and then erase but still it deletes only what is on current space.

 

Does anyone have idea?

 

Just as additional info, those OLE are all pictures, not xls files for example.

 

regards

miroko

8 REPLIES 8
Message 2 of 9
_Tharwat
in reply to: miroko

Not that sure , but try this at the moment .

 

(defun c:Del-OLE (/ ss i)
  (if (setq ss (ssget "_x" '((0 . "OLE2FRAME,IMAGE"))))
    (repeat (setq i (sslength ss))
      (entdel (ssname ss (setq i (1- i))))
    )
    (princ "\n Couldn't find any OLE object or Images  ")
  )
  (princ)
)

 

Message 3 of 9
miroko
in reply to: _Tharwat

hello

 

thank you for writing.

 

The code which you provided is deleting OLE objects but only one of them - i have to use it few times to delete all.

And actually there is something strange because the last OLE object i cannot delete unless i switch to this paper space where it is located.

 

do not know how to solve it.

 

 

regards

miroko

Message 4 of 9
_Tharwat
in reply to: miroko

I did not get what you mean .

Message 5 of 9
miroko
in reply to: _Tharwat

hei

 

i will give example

 

we have a drawing with 3 paper spaces.

There are 3 OLE objects (one on each paper space)

 

whern i start the lisp it removes only one at a time so i have to start it 3 times

but the thing is that 3-rd one (last) is not removed by lisp unless the paper space on which it resides is active

 

 

regards

miroko

Message 6 of 9
_Tharwat
in reply to: miroko

So try this now ..

 

(defun c:Test (/ _D)
  (defun _D (spc / ss i)
    (if (setq ss (ssget "_x" (list '(0 . "OLE2FRAME,IMAGE") (cons 410 spc))))
      (repeat (setq i (sslength ss)) (entdel (ssname ss (setq i (1- i)))))
      (princ "\n Couldn't find any OLE object or Images  ")
    )
  )
  (_D "Model")
  (foreach l (layoutlist) (setvar 'ctab l) (_D l))
  (setvar 'ctab "Model")
  (princ "\nWritten by Tharwat Al Shoufi")
  (princ)
)

 

Message 7 of 9
miroko
in reply to: _Tharwat

now it is working

 

i understand that that there is no way to avoid switching between paper spaces?

 

some drawings are large so takes time

 

miroko

Message 8 of 9
bobdobbs
in reply to: miroko

user pbesje wrote some code that would delete blocks from all layouts. I changed it a bit to delete all OLE2FRAME objects. It seems to work for me on 2008.

 

A link to the original: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Delete-Block-from-multiple-Layouts/td...

 

(defun c:delole ()
(vl-load-com)  
  	(if (ssget "_x" (list '(0 . "OLE2FRAME")))
	  	(vlax-for n (vla-get-activeselectionset
                          (vla-get-activedocument
                                (vlax-get-acad-object)))
                  (vla-delete n)
                  )
	  )
)

 

Message 9 of 9
miroko
in reply to: bobdobbs


@bobdobbs wrote:

user pbesje wrote some code that would delete blocks from all layouts. I changed it a bit to delete all OLE2FRAME objects. It seems to work for me on 2008.

 

A link to the original: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Delete-Block-from-multiple-Layouts/td...

 

(defun c:delole ()
(vl-load-com)  
  	(if (ssget "_x" (list '(0 . "OLE2FRAME")))
	  	(vlax-for n (vla-get-activeselectionset
                          (vla-get-activedocument
                                (vlax-get-acad-object)))
                  (vla-delete n)
                  )
	  )
)

 


hei

this worked perfectly!

very quick.

 

thank you for help (to both  @bobdobbs and @_Tharwat  )

 

ragards

miroko

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost