Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
wundrlik
Posts: 201
Registered: ‎04-15-2003
Message 1 of 3 (164 Views)

Rotate text lisp

164 Views, 2 Replies
08-22-2005 10:05 AM
I have an older lisp file (cirra 1993) that used to work up until the advent of LWPOLYLINES. Now I need to know if I can modify this to use them. It's supposed to rotate text to match the rotation of a line.

Thanks,

(princ "\nChange angle of TEXT to selected Line or Polyline")(princ)

(SETQ MARK 0)

(setq p1 (entget (car (nentsel "\nSelect text: "))))
(redraw (cdr (assoc -1 P1)) 3)
(setq P2 (nentsel "\nSelect Line: ")
P3 (entget (car P2)))
(cond ((= (cdr (assoc 0 P3)) "LINE")
(setq P6 (angle (cdr (assoc 10 P3)) (cdr (assoc 11 P3))))
)
((= (cdr (assoc 0 P3)) "VERTEX")
(setq P4 (cdr (assoc 10 P3))
P5 (osnap (cadr p2) "near")
P6 (angle P4 P5))
)
)
(if (and (< P6 4.7124)(> P6 1.5708)) (setq P6 (+ P6 3.1416)))
(entmod (subst (cons 50 P6) (assoc 50 P1) P1))

(SETQ ATOMLIST (CDR (MEMBER 'MARK ATOMLIST)))
(GC)(PRINC)
*Don Ireland
Message 2 of 3 (164 Views)

Re: Rotate text lisp

08-22-2005 10:34 AM in reply to: wundrlik
The following function will return a list of vertices for the selected
LWPolyline. You need to figure out WHICH 2 vertices your chosen point is
between and use them to define your angle. If and when I get a chance, I'll
see what I can come up with--unless someone else has something first. But
at least this can provide something to help get you started.

(defun GetPLVertices (ent / cnt ptlist)
(if (=(cdr(assoc 0 ent)) "LWPOLYLINE")
(progn(setq cnt 0)
(repeat (length ent)
(setq cnt (1+ cnt))
(if (= 10 (car (nth cnt ent)))
(if ptlist
(setq ptlist (append ptlist (list(nth cnt ent))))
(setq ptlist (list(nth cnt ent)))
)
)
)
ptlist)
;else - NOT LWPolyline!
(progn(Princ "\nERROR- This is NOT a valid element.")
(princ))
)
)

wrote in message news:4935082@discussion.autodesk.com...
I have an older lisp file (cirra 1993) that used to work up until the
advent of LWPOLYLINES. Now I need to know if I can modify this to use them.
It's supposed to rotate text to match the rotation of a line.

Thanks,

(princ "\nChange angle of TEXT to selected Line or Polyline")(princ)

(SETQ MARK 0)

(setq p1 (entget (car (nentsel "\nSelect text: "))))
(redraw (cdr (assoc -1 P1)) 3)
(setq P2 (nentsel "\nSelect Line: ")
P3 (entget (car P2)))
(cond ((= (cdr (assoc 0 P3)) "LINE")
(setq P6 (angle (cdr (assoc 10 P3)) (cdr (assoc 11 P3))))
)
((= (cdr (assoc 0 P3)) "VERTEX")
(setq P4 (cdr (assoc 10 P3))
P5 (osnap (cadr p2) "near")
P6 (angle P4 P5))
)
)
(if (and (< P6 4.7124)(> P6 1.5708)) (setq P6 (+ P6 3.1416)))
(entmod (subst (cons 50 P6) (assoc 50 P1) P1))

(SETQ ATOMLIST (CDR (MEMBER 'MARK ATOMLIST)))
(GC)(PRINC)
*Joe Burke
Message 3 of 3 (164 Views)

Re: Rotate text lisp

08-22-2005 11:35 PM in reply to: wundrlik
Don,

Here's a link to SegmentPts by John Uhden: http://tinyurl.com/bsgf4

Joe Burke

"Don Ireland" wrote in message
news:4935144@discussion.autodesk.com...
The following function will return a list of vertices for the selected
LWPolyline. You need to figure out WHICH 2 vertices your chosen point is
between and use them to define your angle. If and when I get a chance, I'll
see what I can come up with--unless someone else has something first. But
at least this can provide something to help get you started.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community