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

rotating attribute text horizontal

11 REPLIES 11
Reply
Message 1 of 12
rodb
1448 Views, 11 Replies

rotating attribute text horizontal

Hi again, I would like to globally rotate an attributes text to be horizontal. When a block containing and attribute is inserted at a rotated angle the attributes text is of course also rotated - The tag is called circuit so I tried this - any help would be much appreciated oh and also some lisp to alter the size of the text would also be a big help?

 

(prompt "\nPick your Blocks..")
(setq ss (ssget '((0 . "insert")))
sl (sslength ss)
ct 0
ctr 0
ang 0.0
)
(repeat sl
(setq e1 (ssname ss ct))
(setq ck 2)
(while (not (equal ck "SEQEND"))
(setq e1 (entnext e1)
e2 (entget e1)
ck (cdr (assoc 0 e2)))
(if (= (cdr (assoc 2 e2)) "CIRCUIT")
(progn
(setq pos (cdr (assoc 10 e2)))
(command "rotate" e2 "" pos ang "" "")
(entmod e2)
(entupd e1)
(setq ctr (+ ctr 1))
)
)

)

 

having tried this which did not work

 

(prompt "\nPick your Blocks..")
(setq ss (ssget '((0 . "insert")))
sl (sslength ss)
ct 0
ctr 0
ang 0.0
)
(repeat sl
(setq e1 (ssname ss ct))
(setq ck 2)
(while (not (equal ck "SEQEND"))
(setq e1 (entnext e1)
e2 (entget e1)
ck (cdr (assoc 0 e2)))
(if (= (cdr (assoc 2 e2)) "CIRCUIT")
(progn
(setq e2 (subst (cons 1 ang)(assoc 50 e2)e2))
(entmod e2)
(entupd e1)
(setq ctr (+ ctr 1))
)
)

)

11 REPLIES 11
Message 2 of 12
pbejse
in reply to: rodb

Try this oldie code of mine

 

(defun c:ratb  (/  objs) 
      (vl-load-com)
;;;		Block Specific Routine		;;;
(setq ang (cond ((getangle (strcat "\nEnter Angle:  <"
          (angtos (setq ang (cond ( ang ) ( 0.0 ))) 
          )  ">: " )))  ( ang )
  )
)
      (if (ssget "_:L" '((0 . "INSERT") (2 . "CIRCUIT")))
            (progn
                  (vlax-for
                         att  (setq objs (vla-get-ActiveSelectionSet
                                               (vla-get-ActiveDocument
                                                     (vlax-get-acad-object))))
                        (mapcar
                              '(lambda (a)
                                     (vla-put-rotation a ang)
                                     (vla-put-alignment
                                           a
                                           acAlignmentMiddleCenter)
                                     (vlax-put
                                           a
                                           'TextAlignmentPoint
                                           (vlax-get att 'InsertionPoint))
                                     )
                              (vlax-invoke att 'Getattributes)
                              )
                        )
                  (vla-delete objs)
                  )
            )
      (princ)
      )

 

HTH

 

Message 3 of 12
rodb
in reply to: pbejse

Thanks for that at the moment its not finding any of the blocks when I make the selection but will go though the program and see if I can find out why.

Message 4 of 12
rodb
in reply to: pbejse

The irratating thing is that this macro works fine but you have to select each attribute one at a time and do them individually!

 

^C^C-attedit;;;;;\;A;0;; 
Message 5 of 12
pbejse
in reply to: rodb

Post the block here. --> make sure its 2009 or lower version.<--

 

Message 6 of 12
rodb
in reply to: pbejse

here is the block

 

 

Message 7 of 12
pbejse
in reply to: rodb


@RodB wrote:

here is the block

 


I never expected it had that much attributes in oneblock. you need to explain more on how you wanted the attributes to be rotated.

 

 

Message 8 of 12
rodb
in reply to: pbejse

Ah, its really only the CIRCUIT attribute tag that I would like to rotate to zero angle the others can remain as they are. It would be more efficient if the program checks to see if the tag needs rotating before rotating it which could be done with an if statement. What I don't understand is why the tag won't rotate when you can alter the contents of the tag easily.

Message 9 of 12
pbejse
in reply to: rodb


@RodB wrote:

Ah, its really only the CIRCUIT attribute tag that I would like to rotate to zero angle the others can remain as they are. It would be more efficient if the program checks to see if the tag needs rotating before rotating it which could be done with an if statement. What I don't understand is why the tag won't rotate when you can alter the contents of the tag easily.


Are you saying that only rotated blocks will be included

 

(defun c:ratb (/ ss att)
  (vl-load-com)
;;;		Block Specific Routine		;;;
  (if (setq ss (ssget "_:L" '((0 . "INSERT") (2 . "LED-DOWNLIGHT2"))))
    (repeat (sslength ss)
      (if (and
	    (not
	      (zerop (vla-get-rotation
		       (setq e (vlax-ename->vla-object (ssname ss 0)))
		     )
	      )
	    )
	    (Setq
	      att (vl-some '(lambda (j)
			      (if (eq (vla-get-tagstring j) "CIRCUIT")
				j
			      )
			    )
			   (vlax-invoke
			     e
			     'Getattributes
			   )
		  )
	    )
	  )
	(progn
	  (vla-put-rotation att 0)
	  (vla-put-alignment att acAlignmentMiddleRight)
	)
      )
      (ssdel (ssname ss 0) ss)
    )
  )
  (princ)
)

 

Message 10 of 12
rodb
in reply to: pbejse

Thanks everyone for your input I got mine working at last, my problem was inserting the angle 0.0 into the circuit tag instead of (50 .  0.0) silly me, works fine now, might just add a line to avoid rotating tags that are already at 0.0. Feel a bit of a fool now!

Message 11 of 12
braudpat
in reply to: rodb

 

Hello

 

An other routine : a little bit different that I am using sometimes !

coming from a french forum www.cadxp.com (Author: Patrick_35)

 

ROT0 : all attributs will be horizontal for the next insert ...

 

SROT0 : disable this special feature for the next insert ...

 

Bye, Patrice 

 

 

;;;
;;;=================================================================
;;;
;;; ROT_0.LSP v2.00
;;;
;;; Laisser l'Angle de Rotation à 0 de TOUS les attributs
;;;
;;; Copyright (C) Patrick_35
;;;
;;;=================================================================
;;;
;;; Commande :   ROT0   Pour mettre les Attributs a l'horizontale
;;;
;;; Commande :  SROT0   Pour revenir a la NORMALE ...
;;;


(defun Attributs_rot_0(rea obj / att)
  (cond
    ((eq (cdr (assoc 0 (entget (cadr obj)))) "INSERT")
      (foreach att (vlax-invoke (vlax-ename->vla-object (cadr obj)) 'getattributes)
	(vla-put-rotation att 0)
      )
    )
  )
)


(defun c:rot0()
  (if mrea_rot0
    (princ "\n\tL'Angle des Attributs = 0 est déjà activée ")
    (progn
      (setq mrea_rot0 (vlr-acdb-reactor nil '((:vlr-objectModified . Attributs_rot_0)(:vlr-objectAppended . Attributs_rot_0))))
      (princ "\n\tActivation de l'Angle des Attributs à 0 ")
    )
  )
  (princ)
)


(defun c:srot0()
  (if mrea_rot0
    (progn
      (vlr-remove mrea_rot0)
      (setq mrea_rot0 nil)
      (princ "\n\tDésactivation de l'Angle = 0 des Attributs ")
    )
    (princ "\n\tL'Angle des Attributs = 0 est déjà désactivé ")
  )
  (princ)
)


(vl-load-com)
(princ (strcat "\n\tPour activer l'Angle des Attributs à 0, lancez la commande ROT0 \n\tPour revenir à la NORMALE, faites la commande SROT0 "))
(princ)

 

 

 

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 12 of 12
rodb
in reply to: braudpat

Thanks for that, an interesting option!

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

Post to forums  

Autodesk Design & Make Report

”Boost