Block name and Description to Multileader

Block name and Description to Multileader

Francisco_Melo
Enthusiast Enthusiast
1,469 Views
3 Replies
Message 1 of 4

Block name and Description to Multileader

Francisco_Melo
Enthusiast
Enthusiast
I already have a lisp that converts the name of a block to a multileader.
I was wondering if it is possible for him to give the name and in another line the description of the block.
Thank you.
 
(defun c:BNameLabel (/ ent entl obj)
(cond ((not (setq ent (car (entsel "\nSelect block: ")))))
((not (eq (cdr (assoc 0 (entget ent))) "INSERT")) (princ "\nInvalid object!"))
((setq pt (getpoint "\nSpecify first point: "))
(setq entl (entlast))
(vl-cmdf "_.mleader" "_non" pt "\\")
(while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (vl-cmdf ""))
(if (not (equal entl (setq entl (entlast))))
(vla-put-textstring
(vlax-ename->vla-object entl)
(vlax-get-property
(setq obj (vlax-ename->vla-object ent))
(if (vlax-property-available-p obj 'EffectiveName)
'EffectiveName
'Name
)
)
)
)
)
)
(princ)
)
(vl-load-com)
(princ)
Accepted solutions (2)
1,470 Views
3 Replies
Replies (3)
Message 2 of 4

pbejse
Mentor
Mentor
Accepted solution

 

(defun c:BNameLabel (/ efnmae ent entl obj)
  (cond	((not (setq ent (car (entsel "\nSelect block: ")))))
	((not (eq (cdr (assoc 0 (entget ent))) "INSERT"))
	 (princ "\nInvalid object!")
	)
	((setq pt (getpoint "\nSpecify first point: "))
	 (setq entl (entlast))
	 (vl-cmdf "_.mleader" "_non" pt "\\")
	 (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (vl-cmdf ""))
	 (if (not (equal entl (setq entl (entlast))))
	   (vla-put-textstring
	     (vlax-ename->vla-object entl)
	     (strcat  (setq efnmae  
		     (vlax-get-property
		       (setq obj (vlax-ename->vla-object ent))
		        (if (vlax-property-available-p obj 'EffectiveName)
			 'EffectiveName
			 'Name)
		       )
		       )
		      "\\P"
		     (cdr (assoc 4 (tblsearch "block" efnmae)))
		     )
	   )
	 )
	)
  )
  (princ)
)
(vl-load-com)
(princ)

 

 

HTH

Message 3 of 4

Francisco_Melo
Enthusiast
Enthusiast

Good Morning.
Thank you very much Pbejse for your great contribution. But if by chance the block has nothing in the description it gives an error and does not advance says (Block does not have a description «!»). It could go ahead and put the data that had available.
Thank you.

0 Likes
Message 4 of 4

pbejse
Mentor
Mentor
Accepted solution

@Francisco_Melo wrote:

..But if by chance the block has nothing in the description it gives an error and does not advance says (Block does not have a description «!»).


 

Is it on one particular drawing or in any drawing?  This snippet will yield a blank string if the description is not availabe. unless the block with the specified named is not found of course.

 

(cdr (assoc 4 (tblsearch "block" efnmae)))

 

Can you explain that more in detail @Francisco_Melo .

 


@Francisco_Melo wrote:

 It could go ahead and put the data that had available.


Yup, that is the general idea. 

 

perhaps this

(if (setq desc (cdr (assoc 4 (tblsearch "block" efnmae)))) desc "")

in place of the above