Jump to content

How to write series of text at specified coordinates automatically


Recommended Posts

Posted

Hi,

 

I am newbie in creating AutoLISP. Is is possible to write series of texts for a given sets of coordinates? I attached a tab delimited textfile wherein my data are tabulated. First column data are the X coordinates, then at 2nd column are the Y coordinates and the 3rd column are the text to be written on these coordinates.

 

Please help.

 

Regards

ExampleData.txt

Posted

Try something simple like:

 

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

Posted

Thanks Lee Mac, that works perfectly. Problem solved.:excited:

Posted

You're welcome Bª™ªN; if you have any questions about the code, just ask :thumbsup:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...