See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: Align Text to a Line

  1. #1
    Member
    Join Date
    2011-11
    Posts
    17
    Login to Give a bone
    0

    Default Align Text to a Line

    Good Morning,

    Is anyone aware of a LISP that aligns text to a line by select the line, then selecting the text. Ensuring the text is not turned upside down, leeping it in a north south or east west allignment.

    We previously had a LISP that did this but it would often turn the text upside down

    It is below for reference

    ;--------------------------------------------------------
    ;lisp program...............................aligntxt.lsp
    ;
    ; aligns text to a line
    ;
    ;---------------------------------------------------------
    (defun c:at (/ LINE ED SP EP A2 TEXT ED2)

    (setq LINE (entsel "\n Choose line: \n")
    ED (entget (car LINE))
    SP (cdr (assoc 10 ED))
    EP (cdr (assoc 11 ED))
    A2 (angle SP EP)
    TEXT (entsel "\n Choose text: \n")
    ED2 (entget (car TEXT))
    AT (cdr (assoc 50 ED2))
    ED2 (subst
    (cons 50 A2)
    (assoc 50 ED2)
    ED2)
    )
    (entmod ED2)

    (prompt "\n \n")
    (princ)
    )

  2. #2
    100 Club
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    147
    Login to Give a bone
    0

    Default Re: Align Text to a Line

    Quote Originally Posted by jarrod822295 View Post
    Good Morning,

    Is anyone aware of a LISP that aligns text to a line by select the line, then selecting the text. Ensuring the text is not turned upside down, leeping it in a north south or east west allignment.

    We previously had a LISP that did this but it would often turn the text upside down

    It is below for reference

    ;--------------------------------------------------------
    ;lisp program...............................aligntxt.lsp
    ;
    ; aligns text to a line
    ;
    ;---------------------------------------------------------
    (defun c:at (/ LINE ED SP EP A2 TEXT ED2)

    (setq LINE (entsel "\n Choose line: \n")
    ED (entget (car LINE))
    SP (cdr (assoc 10 ED))
    EP (cdr (assoc 11 ED))
    A2 (angle SP EP)
    TEXT (entsel "\n Choose text: \n")
    ED2 (entget (car TEXT))
    AT (cdr (assoc 50 ED2))
    ED2 (subst
    (cons 50 A2)
    (assoc 50 ED2)
    ED2)
    &nbsp
    (entmod ED2)

    (prompt "\n \n")
    (princ)
    )
    Hi,

    I have attached lisp file it is downloaded from lee-mac.com

    Thanks,

    Avinash
    Attached Files Attached Files

  3. #3
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Align Text to a Line

    Here is another simple version based on 2 pts.

    Code:
    (defun C:T2pts ( / pt1 pt2 ang tobj vlobj)
    (SETQ PT1 (GETPOINT "\nPick 1st pt" ))
    (SETQ PT2 (GETPOINT "\nPick 2nd pt" ))
    (setq ang (angle pt1 pt2))
    
    (SETQ TOBJ (ENTSEL "\nPick Text"))
    
    (setq vlobj (vlax-ename->vla-object (car tobj)))
    (vlax-put-property vlobj "Rotation" ang)
    
    )
    (C:T2pts)

  4. #4
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Align Text to a Line

    ;the first autolisp program I wrote!

    Code:
    (DEFUN C:RAT (/ LOOP LP ENT ENTN ENTL RP ENTRA ENTR)
    (PROMPT "*ROTATIONAL ALIGNMENT OF TEXT* ")
    (SETQ LOOP 1)
    (WHILE LOOP
    (SETQ LP 1)
    (WHILE LP
    (PRINT)
    (SETQ ENT (ENTSEL "Select text: "))
    (IF (/= ENT NIL) (SETQ LP NIL))
    )
    (SETQ ENTN (CAR ENT))
    (SETQ ENTL (ENTGET ENTN))
    (IF (= (CDR(ASSOC 0 ENTL)) "TEXT") (SETQ LOOP NIL) (PROMPT "SELECTED OBJECT IS NOT TEXT"))
    )
    (COMMAND "CHANGE" ENTN "" "" "" "" "" "90" "")
    (print)
    (Prompt "align to: ")
    (COMMAND "ROTATE" ENTN "" "@" "PER" PAUSE)
    (SETQ ENTL (ENTGET ENTN))
    (SETQ ENTRA (ASSOC 50 ENTL))
    (SETQ ENTR (CDR ENTRA))
    (SETQ ENTR (/ (* 180 ENTR) PI))
    (SETQ ENTR (- ENTR (* (FIX (/ ENTR 360)) 360)))
    (IF (AND (> ENTR 90) (< ENTR 270)) (SETQ ENTR (+ ENTR 180)))
    (COMMAND "CHANGE" ENTN "" "" "" "" "" ENTR "") 
    (print)
    (prompt "new position: ")
    (COMMAND "MOVE" ENTN "" "@" PAUSE)
    )
    Attached Files Attached Files
    Last edited by aaronic_abacus; 2017-04-28 at 11:46 AM.

  5. #5
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Align Text to a Line

    aaronic_abicus a couple of suggestions to look at use (setq ent (ssget (list (cons 0 "text")))) this will pick only text objects so no checking needed, you can pick just one object using ssget. Just me but I have started using Vl more vla-get-startpoint, endpoint then check its direction so get correct angle for text. Then use the vl "Rotation" as per previous post. I will try to find posted something recently pick the two end points and text is placed at midpoint correct angle. If your going to use the Assoc's of the entity, rather than (COMMAND "CHANGE" ENTN "" "" "" "" "" ENTR "") you can use a entmod on the assoc 50 that will change the text angle = vl rotation.

    Good effort though for 1st lisp.

  6. #6
    I could stop if I wanted to
    Join Date
    2014-08
    Posts
    448
    Login to Give a bone
    1

    Default Re: Align Text to a Line

    Question why don't you just use the orient text in express tools

  7. #7
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Align Text to a Line

    RAT.LSP will rotate text using perpendicular on all objects not just a line, and will not rotate upsidedown.

  8. #8
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    1

    Default Re: Align Text to a Line

    "Torient" seems to work for me.

Similar Threads

  1. align text to a line.
    By Chris Matira in forum AutoLISP
    Replies: 4
    Last Post: 2014-10-21, 09:08 AM
  2. Auto align line to text
    By j-majm in forum AutoLISP
    Replies: 3
    Last Post: 2010-04-19, 08:21 AM
  3. align text with angled line
    By ray salmon in forum Revit Architecture - General
    Replies: 4
    Last Post: 2008-12-29, 04:37 PM
  4. align text with angled line
    By ray salmon in forum Revit Architecture - General
    Replies: 6
    Last Post: 2008-08-12, 04:31 AM
  5. Align the control line AND the text?
    By m.vanitallie in forum AutoCAD Civil 3D - Sections
    Replies: 0
    Last Post: 2008-02-08, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •