Jump to content

Recommended Posts

Posted (edited)
(defun c:mahi (/ pt p1 p2)
  (setq p1 (getpoint))						      ; point from the file
  (while (setq p2 (getpoint))					      ; point from the file
;;;; code point extration from txt or excel
    (command "line" p1 p2 "")
    (setq p1 p2)
  )
  (princ)

)

Extract a point from the txt file, then draw a  line in AutoCAD

point.txt

Edited by maahee
Posted (edited)

Your txt file does not have a uniform format

You should fix that first.

Edited by GLAVCVS
Posted (edited)
x           y            z

21.0937p1   200.4997p1    0p1

22.0937p2   201.4997p2    0p2

23.0937p3   203.4997p3    0p3

23.0807p4   203.4797p4    0p4

 The txt file should always be kept in the above uniform format and should have the prefix or suffix  from the point

point.txt

Edited by maahee
Posted (edited)

Try

(defun c:crgPts (/ nmarch arch lin p p0)
      (defun damePts (tx m / c p l l1 i num nm nmdo damePts)
	(setq num "" nm "")
        (while (/= (setq c (substr tx (setq i (if i (1+ i) 1)) 1)) "")
          (if (= c m)
	    (setq l (append l (list num)) l1 (if (not (member nm l1)) (append l1 (list nm)) l1) num "" nm "" nmdo nil)
	    (cond
	      ((and (not nmdo) (wcmatch c "#,[.]")) (setq num (strcat num c)))
	      ((or nmdo (wcmatch c "@")) (setq nm (strcat nm c) nmdo T))
	    )
	  )
	)
	(cons (car l1) (if (/= num "") (append l (list num)) l))
      )
      (setq <-> " "); change if need
      (if (setq nmarch (getfiled "Load file" "" "txt" 2))
	(if (setq arch (open nmarch "r"))
	  (while (setq lin (read-line arch))
	    (setq p (damePts lin <->)
		  p (list (atof (cadr p)) (atof (caddr p)) (if (cadddr p) (atof (cadddr p)) 0.0)) 
	    )
	    (if p0
	      (command "_line" p0 (setq p0 p) "")
	      (setq p0 p)
	    )
	  )
	)
      )
      (princ)
    )

 

Edited by GLAVCVS
  • Thanks 1
Posted

The separator character is " " (1 space) and is stored in <->.

You will need to change it when necessary.

  • Agree 1
Posted

@maahee

I think you should copy the code again.

I forgot to clean up the junk files before publishing it, and it might not be working properly because of that.

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