Jump to content

Need the code for import the coordinate of text to file


Nad SK

Recommended Posts

Dear all.

 

I have a problem: I need to import the coordinate of many text on the screen to the file (.txt fomart) like this:

text content; x coordinate; y coordinate

Thank for all.

Link to comment
Share on other sites

export you mean?

Are the X and Y corrdinate from a text string and not a point or object on the screen?

 

There's a lot of codes for similar to that on this forum, I suggest you utilize the search button first, i'm pretty sure you'll find one that suit your needs.

Otherwise, post a sample dwg or image, and if possible, provide more information :)

 

 

TRY THIS THREAD

http://www.cadtutor.net/forum/showthread.php?42954-Point-Manager&highlight=EXPORT+COORDINATE

Link to comment
Share on other sites

This old Lisp does almost that. Change the code to suit your needs:

(defun c:tex2file()
 (setq dwg (getvar "dwgname")
   nam (substr dwg 1 (- (strlen dwg) 3))
   nam (strcat (getvar "dwgprefix") nam "tXt")
   f (open nam "w")
   sep ",")
 (setq ss (ssget "X" '((0 . "TEXT"))))
 (repeat (setq i (sslength ss))
   (setq el (entget (ssname ss (setq i (1- i))))
     str (strcat (cdr (assoc 1 el)) sep
             (rtos (cadr (assoc 10 el))) sep
             (rtos (caddr (assoc 10 el)))))
   (print str f)
   )
 (close f)
 (strcat "   " nam " Saved")
 )

Link to comment
Share on other sites

Thank for all.

 

@pBe: Export the coodinate. Right. Thanks. The link for point only, not for text.

@fuccaro: It's nearly perfect. It select all the text in the drawing.

@Geobuilder: Thanks. It's goodddddddddddddddddd.

Edited by Nad SK
Link to comment
Share on other sites

ie Link to your same Point Manager

 

@pBe: The link for point only, not for text.

To be honest, not only points, but also blocks and polylines But there is no text export
Link to comment
Share on other sites

 

@pBe: Export the coodinate. Right. Thanks. The link for point only, not for text.

 

A point on the screen? or POINT the object entity?

anyway.....

What about a simple one like this:

 

 
(defun c:testme (/ cdwg cms cutl pt_nm pt_ds pt_fn fso file ptw pn-vl wtxt ptwo)
  (vl-load-com)
  (setq cdwg (vla-get-activedocument (vlax-get-acad-object))
      cms (vla-get-modelspace cdwg)
      cutl (vla-get-utility cdwg)
      )
  (setq pt_nm (vla-getinteger cutl  "\nEnter Point Number: ")
      pt_ds (strcase (vla-GetString  cutl 1 "\nEnter Description Number: "))
      pt_fn (strcat (vla-get-path cdwg) "\\"
      (vla-GetString  cutl 1 "\nEnter File Name: ") ".txt")
        fso (vlax-create-object "Scripting.FileSystemObject")
   file (vlax-invoke-method
                  fso 'CreateTextFile pt_fn 8 :vlax-true )
   )
   (while
   (not (vl-catch-all-error-p
                   (vl-catch-all-apply (function
                           (lambda ()
   (setq ptw (vla-getpoint cutl ptwo "\nPick Coordinate point: "))
      ))))
      )

       (setq pn-vl  (vlax-safearray->list (vlax-variant-value ptw))
        wtxt (strcat (itoa pt_nm) ","  pt_ds ","
       (rtos (car pn-vl) 2 3) "," (rtos (cadr pn-vl) 2 3)
       "," (rtos (caddr pn-vl) 2 3)
        )
       )
    (vlax-invoke file 'Writeline wtxt)
  (setq pt_nm (1+ pt_nm) ptwo ptw ptw nil)

  );while

  (vlax-release-object fso)
  (vlax-invoke file 'close)
)

 

 

The format would be:

 

 
Command: testme
Enter Point Number: 500 <---- series number
Command:
Enter Description Number: lot 65 <----- description of area
Command:
Enter File Name: lot 65 coordinates <------ name of file 
Command: Pick Coordinate point:
Command: Pick Coordinate point:
Command: Pick Coordinate point:
Command: Pick Coordinate point:
Command: Pick Coordinate point:
Command: Pick Coordinate point:
Command:
<<<<< File Path: C:\CAD\Help_others\lot 65 coordinates.txt >>>>>

500,LOT 65,-1512.367,3719.373,0.000
501,LOT 65,-186.069,4384.833,0.000
502,LOT 65,480.002,3731.048,0.000
503,LOT 65,-787.869,2440.990,0.000
504,LOT 65,-1617.536,3497.553,0.000
comma delimited file
Series number, Description, Coordinates (X,Y,Z)

 

Had time to play around :)

Link to comment
Share on other sites

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...