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

lisp to delete zero attributes

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
DOODLEANU
489 Views, 9 Replies

lisp to delete zero attributes

hi ,

Can anyone please help me to give a lisp;

check all attributes values of few block selection, if there is any att value zero, make all of them empty.

9 REPLIES 9
Message 2 of 10
komondormrex
in reply to: DOODLEANU

hey,

do you mean by 'value zero' "0" value or "" value?

=========

if "0" value

 

(defun c:empty_atts_if_zero (/ insert_sset all_atts_list )
  (if (setq insert_sset (ssget '((0 . "insert") (66 . 1))))
    	(mapcar '(lambda (attribute) (if (= "0" (vla-get-textstring attribute)) (vla-put-textstring attribute "")))
		  (setq all_atts_list (apply 'append (mapcar '(lambda (insert) (vlax-invoke insert 'getattributes))
						   	      (mapcar 'vlax-ename->vla-object
								      (vl-remove-if 'listp
										    (mapcar 'cadr (ssnamex insert_sset))
								      )
							      )
						     )
				      )
		  )
	)
  )
  (princ)
)

 

updated

Message 3 of 10
Moshe-A
in reply to: DOODLEANU

@DOODLEANU  hi,

 

check this EMPTYATT command

 

enjoy

moshe

 

(defun c:emptyatt (/ ss ent AcDbBlkRef AcDbAttrib)

 (if (setq ss (ssget '((0 . "insert") (66 . 1))))
  (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq AcDbBlkRef (vlax-ename->vla-object ent))
   (foreach AcDbAttrib (vlax-invoke AcDbBlkRef 'GetAttributes)

    (if (eq (vla-get-textString AcDbAttrib) "0")
     (vla-put-textString AcDbAttrib "")
    )

    (vlax-release-object AcDbAttrib)
   )
   (vlax-release-object AcDbBlkRef)
  ); foreach
 ); if

 (princ)
)

 

 

 

 

Message 4 of 10
DOODLEANU
in reply to: komondormrex

I wanna make 0 to """

Message 5 of 10
DOODLEANU
in reply to: Moshe-A

its works perfect for me thank you

Message 6 of 10
DOODLEANU
in reply to: komondormrex

Thank you
Message 7 of 10
DOODLEANU
in reply to: DOODLEANU

@Moshe-A @komondormrex 

 

how about  all blocks with a specific name lets say

block name example Block1

 

instead of selecting them

Message 8 of 10
komondormrex
in reply to: DOODLEANU

and 'Block1' is static or dynamic?

Message 9 of 10
DOODLEANU
in reply to: komondormrex

Dynamic block.

Message 10 of 10
komondormrex
in reply to: DOODLEANU

check the following

(defun c:empty_atts_if_zero (/ insert_sset all_atts_list )
  (if (setq insert_sset (ssget "_x" '((0 . "insert") (66 . 1))))
    	(mapcar '(lambda (attribute) (if (= "0" (vla-get-textstring attribute)) (vla-put-textstring attribute "")))
		  (setq all_atts_list (apply 'append (mapcar '(lambda (insert) (vlax-invoke insert 'getattributes))
								  (vl-remove-if-not '(lambda (insert) (member (strcat (vla-get-effectivename insert)) 
								  											  (mapcar 'strcat '("block1")))
													 )
								  					 (mapcar 'vlax-ename->vla-object
								  					    	(vl-remove-if 'listp
								  								    (mapcar 'cadr (ssnamex insert_sset))
								  					    	)
							      					 )
								  )
						     )
				      )
		  )
	)
  )
  (princ)
)

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report