Jump to content

How to extract points coordinates quickly ?


Recommended Posts

Posted
your code cannot work on my computer,my AutoCAD 2006 is

Chinese version ,It only can accept Chinese and English ,

maybe you can translate your code into English ,then your

code maybe used by the people around the world who like me whose AutoCAD can only accept English command !

 

Look EcoorE.lsp

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • bbb120

    11

  • Lee Mac

    5

  • Tiger

    3

  • VVA

    2

Top Posters In This Topic

Posted
There is a mix of expressions here. You get two identical sets of coordinates for two different entitys because they share start and end point. As eldon said, if you use Polyline or Rectangle command, you get one entity and one set of coordinates.

 

Or, you can add POINTs to eaach point that you want and use Lee Macs original lisp.

 

Also something to think about: I have complete faith in Lee Mac, Eldon or any of the Lisp Gurus here that they can do a lisp that does exactly what you want. But they, like you have a job to do as well, and are helping you because they are friendly souls - with a little gratitude you can come a long way.

 

maybe my English is very poor ,I cannot express my ideas clear .I want to get the startpoints and endpoints of all lines,because I want to put these coordinate pairs(for example (0,0,0),(600,400,0) etc ) into ANSYS ,so I do not want to get the same coordinator pairs ,I only want to get every coordinator pairs one time(if two lines have the same endpoints coordinates ,I only want to get the endpoints coordinates one time ,I know point and endpoints of a line does not belong to the same entity until last night from this forum :D.thanks for your forum

 

I not use AutoCAD frequently ,and I do not know much about it ,and know nothing about LISP language .I think it maybe a difficult thing to write the LISP codes which can achieve my purpose。

 

I do not know whether I express my idea clearly .If you have any question ,please contact me .

Posted

To get the most benefit from AutoCAD, sometimes you have to learn how data is stored. If you "list" your lines, you will see that for every line, there is a start coordinate and an end coordinate. If you now join the lines to make a polyline, and "list" the polyline, you will see that now there is a list of coordinates for each vertex of the polyline and arranged in order. There are no intermediate duplicate coordinates, and it is so much more simple to make code that does not have to inspect each coordinate and delete duplicates.

 

It is usual in life to take the easier path, and not to climb unnecessary mountains.

Posted
maybe my English is very poor ,I cannot express my ideas clear .I want to get the startpoints and endpoints of all lines,because I want to put these coordinate pairs(for example (0,0,0),(600,400,0) etc ) into ANSYS ,so I do not want to get the same coordinator pairs ,I only want to get every coordinator pairs one time(if two lines have the same endpoints coordinates ,I only want to get the endpoints coordinates one time ,I know point and endpoints of a line does not belong to the same entity until last night from this forum :D.thanks for your forum

 

I not use AutoCAD frequently ,and I do not know much about it ,and know nothing about LISP language .I think it maybe a difficult thing to write the LISP codes which can achieve my purpose。

 

I do not know whether I express my idea clearly .If you have any question ,please contact me .

 

Do you have an overlapped lines in the selection?

If so try this one instead

(defun point_str  (pt prec /)
 (strcat (rtos (car pt) 2 prec)
  " "
  (rtos (cadr pt) 2 prec)
  " "
  (rtos (caddr pt) 2 prec))
 )


(defun get_linepts  (lst)
 (mapcar 'cdr
  (vl-remove-if-not
    (function (lambda (a)
		(member (car a) '(10 11))))
    lst)
  )
 )

(defun C:IPT  (/ collect elist en fd fn sset tmp)
 (if
   (setq sset (ssget "_:L" (list (cons 0 "LINE")))
  )
    (progn
      (while (setq en (ssname sset 0)
	    )
 (setq elist (entget en)
       )
 (setq tmp (mapcar (function (lambda (x)
			       (point_str x 3))
			     )
		   (get_linepts elist)
		   )
       )

 (foreach pt  tmp
   (if (not (member pt collect))
     (setq collect (cons pt collect))
     )
   )

 (ssdel en sset)
 )
      (setq collect (reverse collect)
     )
      (setq fn (getfiled "Select text file for append points" "" "txt" 16)
     )
      (setq fd (open fn "a")
     )
      (setq i 0)
      (foreach	pt collect
 (setq i (1+ i))
 (if (not (zerop (rem i 2)))
 (write-line pt fd)
   (progn
     (write-line pt fd)
     (write-line (chr 32) fd)
     )
   )
 )

      (close fd)
      )
    )
 (princ)
 )
(prompt
 "\n\t\t>>>\tType IPT to import points\t<<<"
 )
(prin1)

 

~'J'~

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