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))
)
)
)
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
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.
The irratating thing is that this macro works fine but you have to select each attribute one at a time and do them individually!
@Anonymous 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.
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.
@Anonymous 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) )
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!
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 BRAUD
Can't find what you're looking for? Ask the community or share your knowledge.