+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12
  1. #11
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Jul 2012
    Posts
    12

    Default

    Registered forum members do not see this ad.

    Working code:

    Code:
    ;;;  Program to read the output data from the Corpson6 coordinate conversion
    ;;;  By Ron Auble, 01/19/07, Auble Consulting.    Last update 01/19/07
    ;;;
    ;;;  Passed: Nothing, prompted to select a data file
    ;;;  Return: List of lines from data file in the form of '("Label" X-value Y-value)
    ;;;
    (defun ReadUTM ( / FName LINE xFN Comma LblStr RemStr Xord Yord DatITM DatLST)
      (setq FName (getfiled "Select Data File" (getvar "DWGPREFIX") "txt" 0))
      (if FName
        (if (setq FH (open FName "r"))
          (while (setq LINE (read-line FH))
            (if LINE
              (if (setq Comma (vl-string-position (ascii ",") LINE ))
                (if (setq LblStr (substr LINE 1 Comma))
                  (if (setq RemStr (substr LINE (+ Comma 2))
                             Comma (vl-string-position (ascii ",") RemStr)
                      )
                    (if (setq Xord (substr RemStr 1 Comma)
                            RemStr (substr RemStr (+ Comma 2))
                             Comma (vl-string-position (ascii ",") RemStr)
                              Yord (substr RemStr 1 Comma)
                        )
                        (progn
                          (setq DatITM (list LblStr (atof Xord) (atof Yord))
                                DatLST (append DatLST (list DatITM))
                          )
                        )
                        (princ (strcat "\n   Bad line '" LINE "'"))
                    )
                  )
                )
              )
              (close FH)
            )
          )
          (princ "\n  Unable to Open File!")
        )
        (princ "\n  No File Picked!")
      )
      (if DatLST
        (setq DatLST DatLST)
        (eval nil)
      )
    )
    ;;;____________________________________________________________________________
    ;;;
    ;;;  Program to Insert Points and Text at each location in list
    ;;;
    ;;;
    (defun C:PlacePTS ( / PosLST ITM Lbls Xord Yord TxtPT)
      (setq PosLST (ReadUTM))
      (if PosLST
        (progn
          (setvar "CMDECHO" 0)
          (command "UNDO" "Begin")
          (foreach ITM PosLST
            (setq Lbls (car   ITM)
                  Xord (cadr  ITM)
                  Yord (caddr ITM)
            )
            (princ (strcat "\n Placing " Lbls))
            (command)
            (if (> (atoi Lbls) 5)
              (setq TxtPT (polar (list Xord Yord 0.0) 0.0 -700.0))
              (setq TxtPT (polar (list Xord Yord 0.0) 0.0 0.0))
            )
    (command "_Text" "_non" TxtPT "150" "0" Lbls)
            (command)
          )
          (command "UNDO" "End")
          (setvar "CMDECHO" 1)
          (princ (strcat "\n  Placed " (itoa (length PosLST)) " items."))
        )
        (princ "\n  Nothing to place.")
      )
      (princ)
    )

  2. #12
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,738

    Default

    Registered forum members do not see this ad.

    A quick modification of my code from here, should perform as required:

    Code:
    (defun c:txtatpt ( / f p s x y )
        (if
            (and
                (setq f (getfiled "" "" "csv" 16))
                (setq f (open f "r"))
            )
            (progn
                (while (setq n (read-line f))
                    (if
                        (and
                            (setq p (vl-string-search "," n))
                            (setq s (substr n 1 p))
                            (setq p (vl-string-search "," (setq n (substr n (+ p 2)))))
                            (setq x (distof (substr n 1 p)))
                            (setq y (distof (substr n (+ p 2))))
                        )
                        (entmake
                            (list
                               '(0 . "TEXT")
                                (list 10 x y 0.0)
                                (cons 1 s)
                                (cons 40 (getvar 'textsize))
                            )
                        )
                    )
                )
                (close f)
            )
        )
        (princ)
    )
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. Placing text in circle
    By richard3009 in forum AutoCAD General
    Replies: 22
    Last Post: 15th Jul 2011, 04:19 pm
  2. Placing text on a solid
    By pauledward in forum AutoCAD 3D Modelling & Rendering
    Replies: 4
    Last Post: 12th Nov 2009, 02:43 pm
  3. Placing text
    By YoyoGraphics in forum AutoCAD General
    Replies: 2
    Last Post: 14th Jul 2009, 03:48 am
  4. Placing text acurately
    By richard3009 in forum AutoCAD Beginners' Area
    Replies: 13
    Last Post: 21st May 2009, 05:54 pm
  5. question about placing numbered text
    By ledesmaf71 in forum AutoCAD General
    Replies: 14
    Last Post: 29th Jan 2007, 12:18 am

Bookmarks

Posting Permissions

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