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

Change attribute text size of multiple attributes in multiple blocks

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
b_worland
500 Views, 7 Replies

Change attribute text size of multiple attributes in multiple blocks

Hi All,

 

Would any one have a lisp or could create a lisp that could change attribute text heights, of all attributes, of selected blocks in a drawing?

 

Problem  - I have a drawing that has multiple blocks. Each block has multiple attributes with the same and different attribute names.  All the attributes for each block are aligned vertically (see drawing attached and snapshot below). I would like to be able to select some blocks, enter a new attribute text height and have all attributes of the selected blocks change their attribute text height. I understand the lisp will also have to change the vertical separation between the attribute text so they can be read. If the vertical separation doesn't change and the attribute base point stays the same this could mean the text would overlap with the other attributes in the vertical stack and be unreadable. 

I don't want to change attribute text height by selecting attributes individually or one block at a time . I just want to select some blocks or every block in then have all attributes for every selected block change.

 

The drawing with blocks and attributes is attached.

 

So, would anyone have or be able to create a lisp that could allow for - 

1. User runs lisp. Lisp prompts for selection of some or all blocks (including ability to use previous selection set or select similar)

2. Lisp then selects all attributes of every selected block

3. Lisp prompts user to enter a new attribute text height.

4. Lisp changes all attribute text heights and maintains readability of the attributes in the vertical stack relative to each other. 

 

Snapshot of "readability" of attributes that are vertically stacked prior to changing text height. The same "readability" is needed after the change to text height. 

b_worland_0-1723682943400.png

 

 

I wish i had some programming knowledge but I don't. Any help appreciated.

 

Kind Regards

Ben

Labels (1)
7 REPLIES 7
Message 2 of 8
Sea-Haven
in reply to: b_worland

Bit rough and very little testing. 

 

 

 

(defun c:attsc ( / obj atts att pt ht sc x xp y yp)
(setq obj (vlax-ename->vla-object (car (entsel "\nSelect a block object "))))
(setq atts (vlax-invoke obj 'Getattributes))

(setq x 0.0 y 0.0)
(foreach att atts 
  (setq pt (vlax-get att 'Insertionpoint))
  (setq xp (car pt) Yp (cadr pt))
  (setq x (+ x xp) Y (+ y yp))
)
(setq x (/ x (length atts)) y (/ Y (length atts)))
(setq pt (list X y))

(setq ht (vlax-get (car atts) 'height))
(setq sc (/ (getreal "\nEnter new height ") ht))

(foreach att atts
  (command "scale" (vlax-vla-object->ename att) "" pt sc)
)
(princ)
)

 

 

 

 

Message 3 of 8
komondormrex
in reply to: b_worland

hey there,

in most simple terms

(defun c:atts_change_height (/ insert_sset height att_list scale_point scale_factor)
	(if (setq insert_sset (ssget '((0 . "insert") (66 . 1))))
		(progn 
			(setq height (getreal "\nEnter desirable heigth for all attributes: "))
			(foreach insert (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex insert_sset))))
				(setq att_list (vlax-invoke insert 'getattributes)
					  scale_point (mapcar '+ (list 0 (vla-get-height (car att_list)) 0) 
					  						 (vlax-get (car att_list) 'insertionpoint)
								  )
					  scale_factor (/ height (vla-get-height (car att_list)))  
				)
				(mapcar '(lambda (attribute) (vla-scaleentity attribute (vlax-3d-point scale_point) scale_factor))
						 att_list
				)
			)
		)
	)
	(princ)
)

 

Message 4 of 8
ec-cad
in reply to: Sea-Haven

Hmm.

That seems to scale the entire block ?

 

ECCAD

Message 5 of 8
b_worland
in reply to: komondormrex

Hi K,

Thanks very much, that works perfectly. 

 

I just want to say how fantastic this forum is. People like yourself, Sea-heaven and all others, extremely generous with your knowledge and time. 

 

Thanks again

Ben

 

Message 6 of 8
b_worland
in reply to: Sea-Haven

Hi Sea-haven,

Thank you for sending this through. I couldn't quite get it to work, but Komondormrex has sent a solution in. 

As I said in my reply to komondormrex, generous people, like yourself, make this a great forum.

 

Thanks

Ben

Message 7 of 8
Sea-Haven
in reply to: ec-cad

There are numerous blocks but I looked for one that matched and it seemed to work.

 

SeaHaven_0-1723780691701.png

 

Note the "X" has not changed which would have been the block scaling.

Message 8 of 8
komondormrex
in reply to: b_worland

your welcome) 

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