GET BLOCK ATTRIBUTE VALUE

GET BLOCK ATTRIBUTE VALUE

atawk
Enthusiast Enthusiast
804 Views
5 Replies
Message 1 of 6

GET BLOCK ATTRIBUTE VALUE

atawk
Enthusiast
Enthusiast

I need a Lisp routine that allows to get the block attribute values into a multileader. I need to get the TAG value and PROMPT value into 2 different lines. (see attached picture). 

0 Likes
805 Views
5 Replies
Replies (5)
Message 2 of 6

dmfrazier
Advisor
Advisor

Assuming the attribute values are coming from the object (assuming it's an attributed block) that the mleader points to, can you simply add fields in the mleader text that reference the attributes in the block?

0 Likes
Message 3 of 6

atawk
Enthusiast
Enthusiast

yes the attribute values will come from the selected block that include attribute. then the multileader will include these attribute values. 

0 Likes
Message 4 of 6

dmfrazier
Advisor
Advisor

Can you simply add fields in the mleader text that reference the attributes in the block?

0 Likes
Message 5 of 6

paullimapa
Mentor
Mentor

Here are multiple threads online that will give you the tag and prompt values on the screen. It’s just a matter of modifying the code to feed this into mleader command

https://www.cadtutor.net/forum/topic/70636-get-tag-prompt-value-of-block-attributes/

https://www.theswamp.org/index.php?topic=36833.0


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 6

komondormrex
Mentor
Mentor

for all attribute definitions in block

 

 

 

 

 

(setq tag_prompt_list nil)
(setq insert (vlax-ename->vla-object (car (entsel "\nPick block reference: "))))
(vlax-map-collection (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-effectivename insert))
	'(lambda (attribute_definition)
	 	(cond
			(
			 	(= "AcDbAttributeDefinition" (vla-get-objectname attribute_definition))
			 		(setq tag_prompt_list (append tag_prompt_list (list (list (vla-get-tagstring attribute_definition)
												      	    (vla-get-promptstring attribute_definition)
											    	      )
										       		)
							      	   )
					)
			)
			(
			 	t
			)
		)
	  )
)
(setq mleader_text (apply 'strcat (mapcar '(lambda (_list) (apply 'strcat _list))
					   (mapcar '(lambda (_list)
						    	(mapcar '(lambda (list_element) (strcat list_element "\\P"))
								_list
							)
						    )
						    tag_prompt_list
					   )
			   	  )
		   )
)
(command "_mleader" "_h" (getpoint "\nPick mleader landing point: ") pause mleader_text "")

 

 

 

 

0 Likes