Lisp Routine to match the text rotation only

Discussion in 'AutoCAD' started by gatordea, Feb 23, 2005.

  1. gatordea

    gatordea Guest

    Is there a LISP routine to match the rotation of different text to a chosen rotated text. Im new with LISP and would appreciate your help greatly. I tried changing the settings on "_matchprop", but it changes other attributes I dont want changed.
    Thanks......
     
    gatordea, Feb 23, 2005
    #1
  2. gatordea

    Adesu Guest

    Hi gatordea,test my script

    ; mrto is stand for match rotation of text to others
    ; Design by Ade Suharna <>
    ; 23 February 2005
    ; program no. 200/02/2005
    ; edit by
    (defun c:mrto (/ ent info50 opt ed)
    (setq osm (getvar "osmode"))
    (setvar "osmode" 64)
    (prompt "\nCLICK A TEXT AS SOURCE FOR ROTATION")
    (setq ss1 (ssget '((0 . "TEXT")))
    ssn1 (ssname ss1 0)
    sse1 (entget ssn1)
    ang1 (cdr (assoc 50 sse1)))
    (prompt "\nCLICK A TEXT TO BE CHANGE")
    (setq ss2 (ssget '((0 . "TEXT")))
    ssn2 (ssname ss2 0)
    sse2 (entget ssn2)
    ang2 (cdr (assoc 50 sse2))
    ed (subst (cons 50 ang1)(assoc 50 sse2) sse2))
    (entmod ed)
    (princ)
    (setvar "osmode" osm)
    )


    chosen rotated text. Im new with LISP and would appreciate your help
    greatly. I tried changing the settings on "_matchprop", but it changes
    other attributes I dont want changed.
     
    Adesu, Feb 23, 2005
    #2
  3. gatordea

    DaveD Guest

    nice. If you don't, I might tweak it some more to make it select base text
    and then be able to apply that rotation to any number of selected text/mtext
    entities - but here it is as a start with mtext included:

    ; mrto stands for match rotation of text to others
    ; Design by Ade Suharna <>
    ; 23 February 2005
    ; program no. 200/02/2005
    ; edit by
    (defun c:mrto (/ ent info50 opt ed)
    (setq osm (getvar "osmode"))
    (setvar "osmode" 64)
    (prompt "\nCLICK A TEXT AS SOURCE FOR ROTATION")
    (setq ss1 (ssget '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(-4 . "OR>")))
    ssn1 (ssname ss1 0)
    sse1 (entget ssn1)
    ang1 (cdr (assoc 50 sse1)))
    (prompt "\nCLICK A TEXT TO BE CHANGE")
    (setq ss2 (ssget '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(-4 . "OR>")))
    ssn2 (ssname ss2 0)
    sse2 (entget ssn2)
    ang2 (cdr (assoc 50 sse2))
    ed (subst (cons 50 ang1)(assoc 50 sse2) sse2))
    (entmod ed)
    (princ)
    (setvar "osmode" osm)
    )
     
    DaveD, Feb 24, 2005
    #3
  4. gatordea

    Adesu Guest

    Hi DaveD,thanks for your corrected,it's good feedback for me.
     
    Adesu, Feb 25, 2005
    #4
  5. gatordea

    hulioman Guest

    first... read and understand the AutoCAD help file on dxf codes. You will understand that text objects have specific dxf codes for each property.
    The codes you can use with this routine...
    1= the text value
    40= the text height
    50= the text rotation angle

    In your example you wanted to match the rotation angle.
    So... run the following routine and enter 50 for the dxf value.
    Then select the source text entity. Then select the text entities to be changed.

    This can match any dxf code... so look at the dxf help file.


    (DEFUN C:TMATCHDXF()
    (if dxfval
    (progn
    (setq xx dxfval)
    (setq dxfval (getint (strcat "\nDXF VALUE?: <" (RTOS XX 2 0) ">")))
    (IF (NOT DXFVAL)
    (SETQ DXFVAL XX)
    )
    )
    (SETQ DXFVAL (GETINT "\nDXF VALUE?: "))
    )
    (SETQ ENT (CAR (ENTSEL "\nSELECT THE TEXT TO MATCH")))
    (SETQ EN (ENTGET ENT))
    (REDRAW ENT 3)
    (sETQ INS (CDR (ASSOC DXFVAL EN)))
    (SETQ SS (SSGET (LIST (CONS 0 "TEXT,MTEXT,RTEXT,DTEXT"))))
    (REDRAW ENT 4)
    (IF (/= SS NIL)
    (PROGN
    (REPEAT (SSLENGTH SS)
    (SETQ ENT (SSNAME SS 0))
    (SETQ EN (eNTGET ENT))
    (ENTMOD (SUBST (CONS DXFVAL INS) (ASSOC DXFVAL EN) EN))
    (SSDEL ENT SS)
    )
    )
    )
    )
     
    hulioman, Feb 25, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.