Lisp to Remove Points from blocks

Lisp to Remove Points from blocks

AutoBIx
Contributor Contributor
1,607 Views
7 Replies
Message 1 of 8

Lisp to Remove Points from blocks

AutoBIx
Contributor
Contributor

I'm Searching a lisp to remove the points (nodes) inside thousands of blocks (made by exported drawings).
i would like to remove them not turn them off with variable as show in many posts.
thanks a lot

0 Likes
Accepted solutions (1)
1,608 Views
7 Replies
Replies (7)
Message 2 of 8

ronjonp
Advisor
Advisor
Accepted solution

Try this:

 

(defun c:foo (/ a d)
  ;; RJP » 2020-12-02
  (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  )
  (vlax-for b (vla-get-blocks d)
    (if	(= 0 (vlax-get b 'isxref) (vlax-get b 'islayout))
      (vlax-for	o b
	(if (= (vla-get-objectname o) "AcDbPoint")
	  (vl-catch-all-apply 'vla-delete (list o))
	)
      )
    )
  )
  (foreach l a (vlax-put l 'lock -1))
  (vla-regen d acallviewports)
  (princ)
)

 

Message 3 of 8

AutoBIx
Contributor
Contributor

Thanks a lot RJP!!
It works flawlessy! You saved my days...

0 Likes
Message 4 of 8

braudpat
Mentor
Mentor

Hello @ronjonp 

 

1) Thanks for your routine !

 

2) Please I would like a version 1.1 ...

Use standard ACAD selection ... I don't want to "filter" ALL Blocks !

 

THE HEALTH, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 5 of 8

ronjonp
Advisor
Advisor

@AutoBIx wrote:

Thanks a lot RJP!!
It works flawlessy! You saved my days...


Glad to help 🍻

0 Likes
Message 6 of 8

ronjonp
Advisor
Advisor

@braudpat wrote:

Hello @ronjonp 

 

1) Thanks for your routine !

 

2) Please I would like a version 1.1 ...

Use standard ACAD selection ... I don't want to "filter" ALL Blocks !

 

THE HEALTH, Regards, Patrice

 


Try this:

(defun c:foo (/ a b d n r s)
  ;; RJP » 2020-12-03
  (if (setq s (ssget '((0 . "INSERT"))))
    (progn (vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
	     (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
	   )
	   (setq b (vla-get-blocks d))
	   (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	     (or (vl-position (setq n (vla-get-effectivename (vlax-ename->vla-object e))) r)
		 (vlax-for o (vla-item b n)
		   (if (= (vla-get-objectname o) "AcDbPoint")
		     (vl-catch-all-apply 'vla-delete (list o))
		   )
		 )
	     )
	     (setq r (cons n r))
	   )
	   (foreach l a (vlax-put l 'lock -1))
	   (vla-regen d acallviewports)
    )
  )
  (princ)
)

This still modifies the block definition so blocks outside of the selection set will change too. If you want just the blocks in the selset to change then the blocks would need to be converted to anonymous ( to make them unique ) then process .. but this is a bit messy IMO.

0 Likes
Message 7 of 8

GANGA_GUHA
Community Visitor
Community Visitor

I am not so familiar with lisp routine. can someone tell me what would be the command to be used after loading this in the dwg?

 

0 Likes
Message 8 of 8

braudpat
Mentor
Mentor
Hello
FOO <Enter>
Bye, Patrice
Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes