points and text

Discussion in 'AutoCAD' started by jurven007, May 9, 2004.

  1. jurven007

    jurven007 Guest

    I have a txt file with coordinates and text. I would like to create a lsp file which will take the coordinates and create a point on it and afterwards put text on the same coordinates.
    I was wondering if that's possible?
    The information in the text file is displayed as followed:
    23795,26435 MM-1
     
    jurven007, May 9, 2004
    #1
  2. Yes it is possible with a little coding. Hopefully someone
    here may have some code that can be adapted for use.




    create a point on it and afterwards put text on the same coordinates.
     
    Tony Tanzillo, May 9, 2004
    #2
  3. jurven007

    bob.at Guest

    jurven,

    you have to posibilities to do this: if you must improt such files many times in the future you should write a lisp program:
    - open file
    - read a line
    - split the text string at " "
    - start point command with first part of string as coordinates
    - start text command with 1. part as coordinates and 2. part as textstring
    - repeat this until you are at the end of file

    If you have to do it only one time, IMO the best way is to improt text file to excel and add the colums so that you get a script file; than saving as plain text with ;-delimiter. In the script file there must be the same as you would input it via keyboard, using a ";" for the enter key:

    point;23795,26435;text;23795,26435;3.5;0;MM-1

    assuming that 3.5 ist the hight and 0 is the direction for the text

    bob.at
     
    bob.at, May 9, 2004
    #3
  4. jurven007

    Rudy Tovar Guest

    I see X and Y, but no Z, am I correct, or perhaps that should also be taken
    into consideration.

    file which will take the coordinates and create a point on it and afterwards
    put text on the same coordinates.
     
    Rudy Tovar, May 9, 2004
    #4
  5. jurven007

    btlsp Guest

    btlsp, May 9, 2004
    #5
  6. jurven007

    jurven007 Guest

    First of all I would like to thank everyone for the fast replies.
    I have to import such files many times and the text files can contain over 200 coordinates with text.
    Since I want to connect a database to my drawing in Autodesk MAP I also have an excel version of it with the x,y,text in separate columns.
    I found out that it's quite easy to make point with the coordinates; just use multipoint, copy all the coordinates and paste them on the command line. It's not possible to use a same approach for the text since you have to enter height and direction all the time.
     
    jurven007, May 9, 2004
    #6
  7. jurven007

    jurven007 Guest

    Re: points and text
    First of all I would like to thank everyone for the fast replies.
    I have to import such files many times and the text files can contain over 200 coordinates with text.
    Since I want to connect a database to my drawing in Autodesk MAP I also have an excel version of it with the x,y,text in separate columns.
    I found out that it's quite easy to make point with the coordinates; just use multipoint, copy all the coordinates and paste them on the command line. It's not possible to use a same approach for the text since you have to enter height and direction all the time.
     
    jurven007, May 9, 2004
    #7
  8. jurven007

    James Murphy Guest

    The new AutoCAD Map 3D (R2005) has the command for this.

    Murph


    have an excel version of it with the x,y,text in separate columns.
    use multipoint, copy all the coordinates and paste them on the command line.
    It's not possible to use a same approach for the text since you have to
    enter height and direction all the time.
     
    James Murphy, May 10, 2004
    #8
  9. jurven007

    jurven007 Guest

    Too bad I have Autodesk MAP 2004...
    Is there another way?
     
    jurven007, May 10, 2004
    #9
  10. jurven007

    ECCAD Guest

    Something like this might work. (Untested)

    ; The information in the text file is displayed as followed:
    ; 23795,26435 MM-1
    ; Lisp to read .txt file (as above sample line), add a point
    ; and lay-in the text.
    (setvar "cmdecho" 0)
    (setq T_Ht "3.50"); Text Height
    ;
    ; Open the text file..
    ;
    (setq filename (strcat "C:" "/temp/" "points.txt"))
    (if (findfile filename)
    (progn
    (setq ifil (open filename "r")); open the file
    (while (setq rd-line (read-line ifil))
    (if rd-line
    (progn
    (setq x (strlen rd-line))
    (setq i 1 Field 1 Tex "" Px nil Py nil)
    (repeat x
    (setq c (substr rd-line i 1)); read a character
    (if (or (= c ",")(= c " "))
    (progn
    (setq Field (+ Field 1))
    (setq c "")
    ); end progn
    ); end if
    (if (and (/= c "")(= Field 1))
    (setq Px (strcat Px c)); stack first point
    ); end if
    (if (and (/= c "")(= Field 2))
    (setq Py (strcat Py c)); stack second point
    ); end if
    (if (and (/= c "")(= Field 3))
    (setq Tex (strcat Tex c)); stack text
    ); end if
    (setq i (+ i 1))
    ); end repeat
    (if (and (/= Px nil)(/= Py nil))
    (progn
    (setq Px (atof Px))
    (setq Py (atof Py))
    (setq P (list Px Py 0.0)); Insertion point
    (command "_point" P)
    (command "_text" "M" P T_Ht "0" Tex "")
    ); end progn
    ); end if
    ); end progn
    ); end if
    ); end while
    (close ifil)
    ); end progn
    ); end if
    (princ)
     
    ECCAD, May 10, 2004
    #10
  11. jurven007

    jurven007 Guest

    Hi ECCAD(Bob),

    Sorry for my late reply but I have been awayfor some days.
    Thanks for the script I will try it today. I have a few questions though. I copy everything with the ; to a text file and save it as *.scr? When I load it in AutoCAD what is the command to start it? I can't find a defun function in the script....;-)
    Thanks a lot for your help,

    Jurven007
     
    jurven007, May 14, 2004
    #11
  12. jurven007

    ECCAD Guest

    Jurven007,
    No. Is not a script file -- is a lisp program.
    In Notepad, Paste from 1st ";" to (princ) and saveas read_points.lsp
    Place the read_points.lsp in your AutoCAD \Support folder.
    In AutoCAD, to run the program..load it as an application, or
    at command prompt do:
    (load "read_points.lsp")<enter>

    Note, also in the program:
    (setq filename (strcat "C:" "/temp/" "points.txt"))
    ...is where you can specify which folder and which 'file' to use.

    Hope this helps.
    Bob
     
    ECCAD, May 14, 2004
    #12
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.