maahee Posted January 29 Posted January 29 (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 January 29 by maahee Quote
GLAVCVS Posted January 29 Posted January 29 (edited) Your txt file does not have a uniform format You should fix that first. Edited January 29 by GLAVCVS Quote
maahee Posted January 30 Author Posted January 30 (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 January 30 by maahee Quote
GLAVCVS Posted January 30 Posted January 30 (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 January 30 by GLAVCVS 1 Quote
GLAVCVS Posted January 30 Posted January 30 The separator character is " " (1 space) and is stored in <->. You will need to change it when necessary. 1 Quote
GLAVCVS Posted January 30 Posted January 30 @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
BIGAL Posted January 30 Posted January 30 Just a comment most files like this don't have a double line entry makes life a bit easier. Can remove double lines in a word processor and save as a txt file. x y z 21.0937p1 200.4997p1 0p1 22.0937p2 201.4997p2 0p2 23.0937p3 203.4997p3 0p3 23.0807p4 203.4797p4 0p4 Do you have more points ? It looks a bit too simple, what about lines next p1 p7 p8 p9, p3 p7 and so on, multiple lines. If from an Excel then post the Excel. 1 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.