• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Valued Contributor
    Posts: 50
    Registered: ‎03-24-2009

    rotating attribute text horizontal

    233 Views, 11 Replies
    10-27-2012 07:16 AM

    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))
    )
    )

    )

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: rotating attribute text horizontal

    10-27-2012 08:33 AM 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

     

    Please use plain text.
    Valued Contributor
    Posts: 50
    Registered: ‎03-24-2009

    Re: rotating attribute text horizontal

    10-27-2012 10:08 AM 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.

    Please use plain text.
    Valued Contributor
    Posts: 50
    Registered: ‎03-24-2009

    Re: rotating attribute text horizontal

    10-27-2012 10:16 AM 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;; 
    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: rotating attribute text horizontal

    10-27-2012 10:22 AM in reply to: rodb

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

     

    Please use plain text.
    Valued Contributor
    Posts: 50
    Registered: ‎03-24-2009

    Re: rotating attribute text horizontal

    10-27-2012 01:07 PM in reply to: pbejse

    here is the block

     

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: rotating attribute text horizontal

    10-28-2012 02:19 AM 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.

     

     

    Please use plain text.
    Valued Contributor
    Posts: 50
    Registered: ‎03-24-2009

    Re: rotating attribute text horizontal

    10-28-2012 04:50 AM 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.

    Please use plain text.
    *Expert Elite*
    Posts: 2,066
    Registered: ‎11-24-2009

    Re: rotating attribute text horizontal

    10-28-2012 05:25 AM 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)
    )

     

    Please use plain text.
    Valued Contributor
    Posts: 50
    Registered: ‎03-24-2009

    Re: rotating attribute text horizontal

    10-28-2012 08:11 AM 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!

    Please use plain text.