• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Mentor
    Posts: 766
    Registered: ‎12-26-2005

    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
    Please use plain text.
    Mentor
    alanjt_
    Posts: 192
    Registered: ‎08-25-2008

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

     

    Please use plain text.
    Contributor
    Posts: 15
    Registered: ‎07-27-2009

    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!

    Please use plain text.
    Mentor
    Posts: 766
    Registered: ‎12-26-2005

    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
    Please use plain text.
    *Pro
    scot-65
    Posts: 1,927
    Registered: ‎12-11-2003

    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!

     

    :-)

    Please use plain text.