Results 1 to 4 of 4

Thread: Need help with LISP calling TXTEXP.lsp(object selection issue)

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2013-10
    Posts
    1
    Login to Give a bone
    0

    Default Need help with LISP calling TXTEXP.lsp(object selection issue)

    Hello everyone, I am trying to write a LISP routine that will zoom to each text object and run TXTEXP on them individually.

    I have managed to get to a point where it will zoom to each text object and call TXTEXP, but I am having trouble passing coordinates to TXTEXP, or selecting the text object before the call to TXTEXP.
    The following code is "complete" except for the need for the user to click the text object and press enter.

    Code:
    (DEFUN C:EMT () (LOAD "TXTEXP.LSP")
     (PROMPT "\n*EXPLODE TEXT* ")
     (SETQ SS (SSGET "X" '((0 . "TEXT"))))
     (SETQ SSL (SSLENGTH SS))
     (SETQ LP 1)
     (SETQ CT (- SSL 1))
     (WHILE LP
      (SETQ EN (SSNAME SS CT))
      (SETQ CT (- CT 1))
      (SETQ ENL (ENTGET EN))
      (SETQ ENLIP (CDR (ASSOC 10 ENL)))
      (SETQ ENTH (CDR (ASSOC 40 ENL)))
      (COMMAND "ZOOM" "C" ENLIP (* ENTH 50))
      (C:TXTEXP)
      (IF (< CT 0) (SETQ LP NIL))
     );END LP
     (PRINC)
    );END EMT
    TXTEXP cannot be called with COMMAND, and (C:TXTEXP ENLIP) errors with "Too many arguments"

    The following code errors on the SELECT command with "*Invalid selection* Expects a point or Window...(etc)"

    Code:
    (DEFUN C:EMT () (LOAD "TXTEXP.LSP")
     (PROMPT "\n*EXPLODE TEXT* ")
     (SETQ SS (SSGET "X" '((0 . "TEXT"))))
     (SETQ SSL (SSLENGTH SS))
     (SETQ LP 1)
     (SETQ CT (- SSL 1))
     (WHILE LP
      (SETQ EN (SSNAME SS CT))
      (SETQ CT (- CT 1))
      (SETQ ENL (ENTGET EN))
      (SETQ ENLIP (CDR (ASSOC 10 ENL)))
      (SETQ ENTH (CDR (ASSOC 40 ENL)))
      (SETQ XCOORD (CAR ENLIP))
      (SETQ YCOORD (CADR ENLIP))
    
      (COMMAND "ZOOM" "C" ENLIP (* ENTH 50))
      (COMMAND "SELECT" '(XCOORD YCOORD))
      (C:TXTEXP)
      (IF (< CT 0) (SETQ LP NIL))
     );END LP
     (PRINC)
    );END EMT

    If I stop the code at the SELECT command, I am able to manually input the coordinates stored in XCOORD and YCOORD, and it will select the visible text object.

    What am I doing wrong here? Any help would be appreciated

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Need help with LISP calling TXTEXP.lsp(object selection issue)

    You can find txtexp.lsp in C:\Program Files\Autodesk\AutoCAD 2015\Express (or similar depending on your version of AutoCAD) - where you can examine the code.

    Alternatively, you could just write your own routine and use WMFOUT and WMFIN to physically "explode" the text, which is how txtexp does is, more or less.
    R.K. McSwain | CAD Panacea |

  3. #3
    Active Member
    Join Date
    2009-03
    Posts
    63
    Login to Give a bone
    0

    Default Re: Need help with LISP calling TXTEXP.lsp(object selection issue)

    (C:TXTEXP ENLIP) wont work because txtexp does not define an argument to be passed to it in the defun line (I don't think command line functions CAN be passed an argument)

    (COMMAND "SELECT" '(XCOORD YCOORD)) I'm kinda just guessing here, but I think this doesnt work because of the apostrophe. Apostrophes mean "run everything in these parentheses as literal, do no evaluations" so it doesn't think xcoord and ycoord are variables

    However we can pass all that by and kludge the fudge out of it.

    Code:
    (DEFUN C:EMT () (LOAD "TXTEXP.LSP")
     (PROMPT "\n*EXPLODE TEXT* ")
     (SETQ SS (SSGET "X" '((0 . "TEXT"))))
     (SETQ SSL (SSLENGTH SS))
     (SETQ LP 1)
     (SETQ CT (- SSL 1))
     (WHILE LP
      (SETQ EN (SSNAME SS CT))
      (SETQ CT (- CT 1))
      (SETQ ENL (ENTGET EN))
      (SETQ ENLIP (CDR (ASSOC 10 ENL)))
      (SETQ ENTH (CDR (ASSOC 40 ENL)))
      (COMMAND "ZOOM" "C" ENLIP (* ENTH 50))
      (command "pselect" en "")
      (C:TXTEXP)
      (IF (< CT 0) (SETQ LP NIL))
     );END LP
     (PRINC)
    );END EMT
    It ain't pretty but it seems to work.
    Last edited by ccalder; 2014-09-16 at 03:02 PM.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Need help with LISP calling TXTEXP.lsp(object selection issue)

    Shame they defined it as a command line function. Another option is to copy and rename it, then you can modify it to suit your needs.
    Good example: http://www.cadtutor.net/forum/archiv.../t-59981.html?
    TXTEXP.LSP modified to explode linetypes.

Similar Threads

  1. Calling up LISP routine from within another LISP
    By jimmy_goodall in forum AutoLISP
    Replies: 4
    Last Post: 2013-08-21, 05:56 AM
  2. Calling a LISP function in many drawings
    By daniel.j.wright112877 in forum AutoLISP
    Replies: 12
    Last Post: 2012-10-05, 09:48 PM
  3. Calling a script from with in a lisp
    By randy.sherwood597724 in forum AutoLISP
    Replies: 4
    Last Post: 2012-06-05, 04:13 PM
  4. Multiple Object Selection Issue
    By zackm in forum CAD Management - General
    Replies: 2
    Last Post: 2010-11-18, 01:36 AM
  5. Object selection using lisp
    By ReachAndre in forum AutoLISP
    Replies: 4
    Last Post: 2006-10-25, 08:53 PM

Posting Permissions

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