Looking to rotate and change size of an attribute inside a block globally

Looking to rotate and change size of an attribute inside a block globally

matthew.mccormack2257W
Advocate Advocate
820 Views
14 Replies
Message 1 of 15

Looking to rotate and change size of an attribute inside a block globally

matthew.mccormack2257W
Advocate
Advocate

Hi  I'm wondering or looking to find if anyone has an lisp routine that can help me rotate an attribute to horizontal to the ucs  (it has angle of 20º to make it look horizontal) and change the height of the text to 125...

 

so what i need to do as you'll see in the snapshots I've provided, I need to change the height from 187.4999999999996 to 125 and the rotation from 303.526847085602 to 20.... globally to all of the same block in the drawing...

 

snapshot 1 is the block in question

snapshot 2 is the attribute information I need to change

 

does this make sense and can anyone help?

0 Likes
Accepted solutions (2)
821 Views
14 Replies
Replies (14)
Message 2 of 15

ВeekeeCZ
Consultant
Consultant
Accepted solution

It sets an absolute angle. 

 

(defun c:AttRot ( / s a i)

  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   (setq a (getangle "\nSpecify angle: "))
	   )
    (repeat (setq i (sslength s))
      (setpropertyvalue (entnext (ssname s (setq i (1- i)))) "Rotation" a)))
  (princ)
  )

 

0 Likes
Message 3 of 15

matthew.mccormack2257W
Advocate
Advocate

Thanks for that... but unfortunately that didnt work, nothing changed in the attribute... 😞

0 Likes
Message 4 of 15

matthew.mccormack2257W
Advocate
Advocate

Thanks for that... but unfortunately that didnt work, nothing changed in the attribute... 

matthewmccormack2257W_0-1675442019125.png

 

0 Likes
Message 5 of 15

ВeekeeCZ
Consultant
Consultant

Then post a sample dwg

0 Likes
Message 6 of 15

matthew.mccormack2257W
Advocate
Advocate

I've attached a sample dwg... I need to change and rotate all the L1 and L2 text so its size is 125 and its horizontal to the ucs...

 

many thanks for your assistance with this

0 Likes
Message 7 of 15

ВeekeeCZ
Consultant
Consultant

It worked.. it just did not show the prompt when blocks were pre-selected.

Try the updated code.

0 Likes
Message 8 of 15

matthew.mccormack2257W
Advocate
Advocate

Thank you, I tried again and the prompt came up this time and it worked, nice one! buts that's only half the solution I also need it to change the text height from 187..... to 125

0 Likes
Message 9 of 15

change the height globally that is... 🙂

0 Likes
Message 10 of 15

Kent1Cooper
Consultant
Consultant

@matthew.mccormack2257W wrote:

... but unfortunately that didnt work, nothing changed in the attribute... 


Did you run ATTSYNC afterwards?

Kent Cooper, AIA
0 Likes
Message 11 of 15

ВeekeeCZ
Consultant
Consultant
Accepted solution

@matthew.mccormack2257W wrote:

change the height globally that is... 🙂


 

Not sure whether this means that you figured it out or not... In any case...

 

(defun c:AttHeight ( / s a i)

  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   (setq a (getreal "\nSpecify height: "))
	   )
    (repeat (setq i (sslength s))
      (setpropertyvalue (entnext (ssname s (setq i (1- i)))) "Height" a)))
  (princ)
  )

 

Message 12 of 15

matthew.mccormack2257W
Advocate
Advocate

Perfect!.... thank you ever so much for your time and help!.... 🙂

0 Likes
Message 13 of 15

matthew.mccormack2257W
Advocate
Advocate

just a quick one...  I've been using the lisp that you provided, great! Thank you... but whilst using it I've noticed it does rotate the first attribute in a block but if the block as two editable attributes (or more I'm guessing) the 2nd attribute doesnt rotate...  is there away to adjust the lisp to include the 2nd (or more) to rotate them,  or a way of selecting the attribute you want to rotate (within a block) and the lisp would rotate it...

 

 

0 Likes
Message 14 of 15

ВeekeeCZ
Consultant
Consultant

Anything..........

 

(defun c:AttPicRot ( / s a i r)

  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   (setq r (car (nentsel "\nPick att to rotare: ")))
	   (setq r (cdr (assoc 2 (entget r))))
	   (setq a (getangle "\nSpecify angle: "))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (while (and (setq e (entnext e))
		  (= "ATTRIB" (cdr (assoc 0 (entget e)))))
	(and (= r (cdr (assoc 2 (entget e))))
	     (setpropertyvalue e "Rotation" a)))))
  (princ)
  )



(defun c:AttAllRot ( / s a i)

  (if (and (setq s (ssget '((0 . "INSERT") (66 . 1))))
	   (setq a (getangle "\nSpecify angle: "))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (while (and (setq e (entnext e))
		  (= "ATTRIB" (cdr (assoc 0 (entget e)))))
	(setpropertyvalue e "Rotation" a))))
  (princ)
  )

 

Message 15 of 15

matthew.mccormack2257W
Advocate
Advocate

Awesome Many Thanks once again...  wish I knew how to write lisp language, it would be helpful.  🙂 

0 Likes