Visual LISP, AutoLISP and General Customization

Reply
Mentor
Posts: 825
Registered: ‎12-26-2005
Message 11 of 15 (410 Views)

Re: Need LISP to draw line / pline to match TEXT rotation!

10-11-2011 08:15 AM in reply to: Kent1Cooper

Saving UCS as Temp, in reply to Kent, etal:  Yep, and your "P" for Previous is the better way, for that case, and for most cases.

 

Save the UCS is a debug habit, not normally required.

S
Valued Mentor
alanjt_
Posts: 459
Registered: ‎08-25-2008
Message 12 of 15 (405 Views)

Re: Need LISP to draw line / pline to match TEXT rotation!

10-11-2011 10:54 AM in reply to: stevor

Just account for the UCS being something other than world...

 

(defun c:Test (/ e d p)
  (vl-load-com)
  (setvar 'ERRNO 0)
  (if
    (and
      (progn
        (while (progn (setq e (car (entsel "\nSelect *Text object for angle: ")))
                      (cond ((eq (getvar 'ERRNO) 7) (princ "\nMissed, try again."))
                            ((eq (type e) 'ENAME)
                             (if (not (wcmatch (cdr (assoc 0 (setq d (entget e)))) "MTEXT,TEXT"))
                               (princ "\nInvalid object!")
                             )
                            )
                      )
               )
        )
        e
      )
      (setq p (getpoint "\nSpecify first point: "))
    )
     (progn
       (vl-cmdf
         "_.line"
         "_non"
         p
         (strcat
           "<"
           (angtos (if (and (eq (cdr (assoc 0 d)) "TEXT") (zerop (getvar 'WORLDUCS)))
                     (- (cdr (assoc 50 d))
                        (angle '(0. 0. 0.) (trans (getvar 'UCSXDIR) 0 (trans '(0. 0. 1.) 1 0 T) T))
                     )
                     (cdr (assoc 50 d))
                   )
                   (getvar 'AUNITS)
                   4
           )
         )
         PAUSE
       )
       (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (vl-cmdf ""))
     )
  )
  (princ)
)

 

Contributor
Posts: 15
Registered: ‎07-27-2009
Message 13 of 15 (401 Views)

Re: Need LISP to draw line / pline to match TEXT rotation!

10-11-2011 11:08 AM in reply to: stevor

PERFECT! Thank you very very much!

Mentor
Posts: 825
Registered: ‎12-26-2005
Message 14 of 15 (388 Views)

Re: Need LISP to draw line / pline to match TEXT rotation!

10-11-2011 03:52 PM in reply to: econnerly

To Econnerly;

 

1. Notice the post of alanjt: I do not recall if my post included UCS translations.

 

2. And notice that you can change the Layer and LINE offset down distance, in the code.

 

And remove the temp UCS, as per Kent1's post.

 

 

S
*Expert Elite*
scot-65
Posts: 2,082
Registered: ‎12-11-2003
Message 15 of 15 (388 Views)

Re: Need LISP to draw line / pline to match TEXT rotation!

10-11-2011 03:56 PM in reply to: econnerly

I was actually thinking of another alternative that goes something like this:

 

(setq p1 (cdr (assoc 10 (setq b (entget (car (entsel)))))))

(command ".xline" p1 (polar p1 (cdr (assoc 50 b)) 1) "")

 

Yes, it's tested!

 

:-)

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.

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
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

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

Ask the Community