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

ASSIGN "HANDLE" OF A BLOCK ON A ATRIBUTE with VLISP

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
eduardo.centeno.m
307 Views, 2 Replies

ASSIGN "HANDLE" OF A BLOCK ON A ATRIBUTE with VLISP

Hello, I would like a lisp that extract "Handle" of a Block and put it in an atribute of the same block.

I have 2 problems:

First: I want to edit all blocks in drawing (include blocks in layouts)

Second: When I extract handle information its from atributes

I read this post https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/auto-number-lisp-based-on-layout-tab...

but I dont understand

what else should i do, this is my code

 

 

(defun c:ASGHANDLE  (/ bname ss1 ent entdata handle)
 (setq bname (getstring"\nEnter block to give handle: "))
 (if (setq ss1 (ssget "_x" (list '(0 . "INSERT") (cons 2 bname))))
  (mapcar
   '(lambda (x)
     (setq ent (cadr x)
           entdata (entget ent))
     (while (/= (cdr (assoc 0 entdata)) "SEQEND")
      (cond (
	     (= "HANDLE" (cdr (assoc 2 entdata)))
             (entmod
	       (subst(
		      (vla-get-handle (vlax-ename->vla-object ent))
		      (assoc 1 entdata)
		      entdata)
			  )
		    )
              )
	    )
            (setq entdata (entget (setq ent (entnext ent))))))
     (ssnamex ss1))
  "No atributes found")
 (princ))

 

 

Tags (3)
2 REPLIES 2
Message 2 of 3

Perhaps like this. Hopefully, your blocks are not dynamic.

 

(defun c:HandleAssignment ( / e i e)

  (if (and (setq b (getstring t "Block name: "))
	   (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 b) '(66 . 1))))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setpropertyvalue e "HANDLE" (cdr (assoc 5 (entget e))))))
  (princ)
  )

 

Just a side note: If a block has an attribute named HANDLE, we are not able to get a real handle (the property) by (getpropertyvalue e "Handle"). The attribute takes priority.

Message 3 of 3

It´s normal block and lisp is working

Tanks

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

Post to forums  

Forma Design Contest


AutoCAD Beta