maahee Posted yesterday at 10:30 AM Posted yesterday at 10:30 AM (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 yesterday at 10:30 AM by maahee Quote
GLAVCVS Posted 22 hours ago Posted 22 hours ago (edited) Your txt file does not have a uniform format You should fix that first. Edited 22 hours ago by GLAVCVS Quote
maahee Posted 6 hours ago Author Posted 6 hours ago (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 6 hours ago by maahee Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago (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 57 minutes ago by GLAVCVS 1 Quote
GLAVCVS Posted 1 hour ago Posted 1 hour ago The separator character is " " (1 space) and is stored in <->. You will need to change it when necessary. 1 Quote
GLAVCVS Posted 54 minutes ago Posted 54 minutes ago @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. Quote
Recommended Posts
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.