Lee Mac 发表于 2022-7-6 04:29:24

Nice, it will be interesting to see if it works or not

ScribbleJ 发表于 2022-7-6 04:31:49

Just an update Lee. Sorry I have not posted an update about the Lisp you wrote for me but emergencies came up and then I had to dive into Civil 3D for a volume balance calc for some detention ponds. I will get to the lisp soon. Hopefully this week.

Lee Mac 发表于 2022-7-6 04:34:43

Hey, no probs. - do what you gotta do

BIGAL 发表于 2022-7-6 04:38:58

Not sure but doing (read line) twice may do just that ! Skip a line each loop?
 
lisp carries out each instruction within pairs
 
try
(while (setq new_line (read-line fileopen))
 
code here
then use variable new_lineif its Nil loop exits
 
) ;end while

BIGAL 发表于 2022-7-6 04:39:56

Forgot do you now want the code for reading a xyz file, how is your file set up does it use commas to seperate variables or are the x y z a set number of characters ?
 
 
100.123, 200,456,300.789
 
123456789012345678901
100.123 200.456 300.789

Lee Mac 发表于 2022-7-6 04:45:18

 
 
Good point AL, and good solution - I must admit, I have never used this method for inserting blocks into drawings, and my posted LISP was untested also. - but thanks for your input.

wannabe 发表于 2022-7-6 04:48:12

Have you guys figured this one out?
 
I would be quite keen to use it myself and could provide you with some feedback if necessary (relating to its function, not its code).
 
currently I use Microstation for this tool. But I plan on doing an all encompassing form driven block/coordinate functions menu when I feel more competent with C#.

Lee Mac 发表于 2022-7-6 04:48:52

Hiya Wannabe,
 
This should worked (although untested!):
 

(defun c:ITREE (/ *error* file1 blk pts)   (defun *error* (msg)   (setvar "cmdecho" 1)   (if (= msg "")       (princ (strcat (itoa blk) " Blocks Inserted."))       (princ "\nError or Esc Pressed.")   ) ;_end if   ) ;_end defun   (selfile)   (setvar "cmdecho" 0)   (setq file1    (open file "r")   blk    0   ) ;_end setq   (while   (/= (setq pts (read-line file1)) nil)      (command "-insert" "C:\\" ;

ScribbleJ 发表于 2022-7-6 04:52:55

 
The order of the file does not matter because I can export to any format, (i.e. xyz, yxz, etc and comma, tab or space delimited). My preference though would be yxz comma delimited.

BIGAL 发表于 2022-7-6 04:56:21

Here is two example the first uses fixed lengths for x yx z etc (please note code wont work as is but can be used within you program check brackets etc)
 

(defun lay_name ()   (setq ans "")   (setq char_found "")   (while (/= x y)   (setq char_found (substr new_line x 1))   (setq x (+ x 1));      (if (= char_found (chr 92))   (if (= char_found " ")       (setq x y)       (setq ans (strcat ans char_found))   )   ))(while (setq new_line (read-line fo)) (setq x 1) (setq y 17) (lay_name) (setq new_name ans ) (setq x 17) (setq y 32) (lay_name) (setq name ans) (setq x 33) (setq y 36) (lay_name) (setq col ans) (setq x 37) (setq y 47) (lay_name) (setq line ans) (setq ans_var (strcat "(" "setq" name " " (chr 34)new_name (chr 34) ")" )) (setq ans_col (strcat "(" "setq" (strcat name "col") " "col ")" ))(setq ans_line (strcat "(" "setq" (strcat name "lin") " "(chr 34) line (chr 34) ")" ))
 
2nd example is comma delimted
 

(defun xyz () (setq ans "") (setq char_found "") (while (/= char_found ",")   (setq char_found (substr new_line x 1))   (setq x (+ x 1))   (setq ans (strcat ans char_found)) )                  ;end while)                  ;end defun (defun xyzend () (setq ans "") (setq char_found "") (while (/= char_found (chr 13))   (setq char_found (substr new_line x 1))   (setq x (+ x 1))   (setq ans (strcat ans char_found)) )                  ;end while)                  ;end(setq xyzfiles (getfiled "\nENTER CO-ORD File name" "" "" 4))(setq fopen (open xyzfiles "R"))(SETQ XX 1)(while (setq new_line (read-line fopen))(PRINC XX) (setq x 1) (setq y 5) (xyz) (setq ptno ans)            ;pull ptno out (xyz) (setq easting ans) (xyz) (setq northing ans) (xyzend) (setq height ans)
页: 1 [2]
查看完整版本: 插入带a的多个块