30
Sep

Today I wrote a little helper function that rotates selected text and inserts to the current BKS x-axis. The function is tested up to AutoCAD 2011.

(defun c:rotate_0 (/ sset element index)
 (setq sset (ssget))
 (setq index 0)
  (if (/= sset nil)
   (progn
    (repeat (sslength sset)
     (setq element (entget (ssname sset index)))
     (if (= (cdr (assoc 0 element)) "insert")
	(command "_rotate"
          (cdr (assoc -1 element))
          ""
          (cdr (assoc 10 element))
          "b"
          (* (/ 180 pi) (cdr (assoc 50 element)))
          "0.0"
	)
      ; else if	
      (progn
        (setq element (subst (cons 50 0.0) (assoc 50 element) element))
        (entmod element)
      )
    )
   (setq index (+ index 1))
   )
  )
 )
)

,

One Response to “AutoCAD Lisp – rotate_0”

Add reply