Jump to content

Recommended Posts

Posted

Dear friends,

 

Greetings

 

I need a help to extract the coordinates of the polyline. I have some rectangles and squares. i would like to extract the 4 vertices coordinates to .txt file.

 

I found that entget is giving coordinates of all vertices of rectangle but the dxf code 10 is same for all vertices, how to extract them independently. Please help me with which function i can get the vertices where i can send them to txt file with file handling function.

 

regards

 

Ramana

Posted

I must have been bored...

Try this - no error control

 

(defun c:test (/ ed v-lst fn pt str)
 (vl-load-com)
 (setq ed (entget (car (entsel "\nSelect polyline")))
    v-lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) ed));list of vertices
       fn (open "c:\\test.txt" "w")
   str "")
 (if (assoc 38 ed)
     (setq z (rtos (cdr (assoc 38 ed)) 2 4));4 = precision
     (setq z (rtos 0.0 2 4))
     )
 (foreach pt v-lst
   (setq x (rtos (car pt) 2 4)
     y (rtos (cadr pt) 2 4)
     )
   (setq str (strcat x "," y "," z))
   (write-line str fn)
   (setq str "")
   )
 (close fn)
 (princ)
 )

Posted

Take a look at the Point Manager Program in my Signature, it should be able to do what you want, and a lot more.

 

Lee

Posted

Dear friends,

 

thanks a lot, i have got an idea with the code which you have given. Now i will work for the rest to take the text also along with coordinates to txt file.

 

thanks a lot once again.

 

Ramana

Posted

Dear friends,

 

Greetings

 

I have followed and used to export the coordinates of the pline and i have added few more lines of functions for my requirement.

 

Actually my requirement is i need to export the coordinates of rectange and two more text information by selecting all at a time. for my ease i am selecting the plines first and then all text. I am able to export to txt file but the first text is only repeating.

 

i am unable to get to mistake what am doing in this program.

 

I am attaching drawing and lisp routine also

 

Please help me where i am going wrong.

(defun c:test (/ ed v-lst fn pt str)
 (vl-load-com)
  
 (setq pl(ssget '( ( 0 . "LWPOLYLINE")))
   mtxt(ssget '((0 . "MTEXT")))
   PLNO(SSLENGTH PL)
   mtno (sslength mtxt)
   POS 0
   MTPOS 0
   PTLIST1(LIST "")
   fn (open "c:\\test.csv" "w")
   OUTPUT ""
   )
 (REPEAT PLNO
   
   (SETQ BOOTH(SSNAME PL POS))
 (setq ed (entget BOOTH)
    v-lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) ed));list of vertices

   str "" str1 "")

 (foreach pt v-lst
   (setq x (rtos (car pt) 2 4)
     y (rtos (cadr pt) 2 4)
    str (strcat x "," y )
     str1 (strcat str1 "," str)  )
   ;(setq str (strcat x "," y ))
;CALCULATING CO-ORINDATES FOR TESTING TEXT
   (setq x (car pt)
     y     (cadr pt) )
    
 (setq ptlist(list x y )
   ptlist1(append ptlist1 ptlist))
   
         ); FOR EACH
    
   
(while (/= count 2)

 (SETQ    
       MTEXT(SSNAME MTXT MTPOS)
   MTEXTinfo(entget MTEXT)
   MTXY(CDR (ASSOC 10 MTEXTINFO))
   MTX(CAR MTXY)
   MTY(CADR MTXY)
   )

 (IF (AND (< MTX (NTH 3 PTLIST1) ) (< MTY (NTH 4 PTLIST1) )(> MTX (NTH 7 PTLIST1) ) (> MTY (NTH 8 PTLIST1) ))
   (PROGN (SETQ MTCONT(cdr (assoc 1 MTEXTINFO))
        COUNT(1+ COUNT)
        MTPOS(1+ MTPOS)
        )    (setq output(strcat output "," mtcont))     
    )
     (PROGN (SETQ MTPOS(1+ MTPOS)))
   );IF
     
   ); while
   (alert output)     
   
(write-line (strcat output str1) fn)
  
   (SETQ pos(1+ pos)
     count 0
     mtpos 0
    output ""
    
     )
    
     );PL REPEAT 
  (close fn)
   
 
 )

Ramana

ext_text_layers(2).dwg

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