小弟遇到了两个麻烦,望大虾指教
各位大虾,小弟日前用LISP写程序时遇到了点麻烦,但不知错在哪里,所以望大虾能不吝指教。小弟的程序主要是读取线的外部属性数据,然后根据读取的数据形成参数文件,再根据这个参数文件形成需要的图形。但小弟在写程序过程中却遇到了下面的问题:1.在读取外部属性数据时(小弟用的是画条线然后选中与画的线相交的实体),一遇到块或多线就死了,但后来过滤掉,还是不行,我不知道是什么问题,但把这些个东西全部Explode开后就不会出现。不知是什么原因?2.在绘图时,小弟用Entmake进行,但是在插入块时就遇到了问题,小弟的程序行是这样的:(entmake(list(cons 0 "insert")(cons 2 "xxx")(cons 10 basepoint))).但就是插不进去,但如果事先在图形中插入一次后,以后就都能行了,不知道是什么原因,希望大虾指教。小弟是刚开始用Lisp写程序,所以有些地方可能说得不对,还请指正! 1,不是很明白你的问题,要看看你的程序才可能发现问题2。可能你的图中没有"xxx"这个块,插入一次后(外部块),就会在图中生成一个"xxx"块,这样才可以使用entmake建立INSERT对象 带上块的全部路径试试。 (defun c:getdata(/)<BR> (setq pt1(getpoint"\n请输入管线断面的起始点坐标:"))<BR> (setq pt2(getpoint pt1"\n请输入管线断面的终点坐标:"))<BR> (setq datafile(getfiled "断面数据保存在" "" "txt" 1))<BR> (setq fdata(open datafile "a"))<BR> (setq dist 0.0)<BR> (setq depth 0.0)<BR> (setq n_zero 0)<BR> (setq kind "")<BR> (setq code "") <BR> (setq s_pt (list 0.0 0.0))<BR> (setq e_pt (list 0.0 0.0))<BR> (setq int_pt(list 0.0 0.0))<BR> (setq max_depth 0.0)<BR> (setq max_dist 0.0)<BR> (setq h_road(getstring"\n请输入路牙高度:"))<BR> (setq ss(ssget "C" pt1 pt2))<BR> (setq i 0)<BR> (setq n(sslength ss))<BR> (while (< i (- n 1))<BR> (setq ent1(ssname ss i))<BR> (setq i(+ i 1))<BR> (setq ent11(entget ent1))<BR> (setq name(cdr( assoc 0 ent11)))<BR> (setq name(strcase name T))<BR> (if (/= name "line")<BR> (ssdel ent1 ss)<BR> )<BR> )<BR> (setq n(sslength ss))<BR> (setq i 0)<BR> (repeat n<BR> (setq ent(ssname ss i))<BR> (setq i(+ i 1))<BR> (setq ent(entget ent '("*")))<BR> (setq s_pt(cdr(assoc 10 ent)))<BR> (setq x(nth 0 s_pt))<BR> (setq y(nth 1 s_pt))<BR> (setq s_pt(list x y 0))<BR> (setq e_pt(cdr(assoc 11 ent)))<BR> (setq x(nth 0 e_pt))<BR> (setq y(nth 1 e_pt))<BR> (setq e_pt(list x y 0))<BR> (setq int_pt(inters pt1 pt2 s_pt e_pt))<BR> (setq dist(distance pt1 int_pt))<BR> (setq kind(strcase(cdr(assoc 8 ent))T))<BR> (if (or(= kind "water")(= kind "gas")(= kind "swy")(= kind "sww")(= kind "spy")(= kind "spq")(= kind "pwg")(= kind "pwl")(= kind "pwc")(= kind "pwd")(= kind "pwz")(= kind "pwh")(= kind "tlg")(= kind "tll"))<BR> (progn<BR> (setq data(cdr (assoc -3 ent)))<BR> (if (or(= kind "water")(= kind "gas")(= kind "swy")(= kind "sww")(= kind "spy")(= kind "spq"))<BR> (progn<BR> (setq code(cdr(assoc 1000(cdr(assoc "E_HEIGHT" data)))))<BR> (if (= code nil)<BR> (progn<BR> (setq code "管径or孔数or根数未输入")<BR> )<BR> )<BR> (setq depth(cdr(assoc 1000(cdr(assoc "E_NOTE" data)))))<BR> (if (= depth nil)<BR> (progn<BR> (setq depth "0")<BR> (setq n_zero(+ 1 n_zero))<BR> )<BR> )<BR> (setq max_dist(max max_dist dist))<BR> (setq depth1 (atof depth))<BR> (setq max_depth(min max_depth depth1))<BR> (setq dist(rtos dist 2 2))<BR> (setq string(strcat dist "," depth "," kind "," code))<BR> (write-line string fdata)<BR> )<BR> )<BR> (if (or(= kind "pwg")(= kind "pwl")(= kind "pwc")(= kind "pwd")(= kind "pwz")(= kind "pwh")(= kind "tlg")(= kind "tll"))<BR> (progn<BR> (setq code(cdr(assoc 1000(cdr(assoc "E_NUMBER" data)))))<BR> (if (= code nil)<BR> (progn<BR> (setq code "管径or孔数or根数未输入")<BR> )<BR> )<BR> (setq depth(cdr(assoc 1000(cdr(assoc "E_NOTE" data)))))<BR> (if (= depth nil)<BR> (progn<BR> (setq depth "0")<BR> (setq n_zero(+ 1 n_zero))<BR> )<BR> )<BR> (setq max_dist(max max_dist dist))<BR> (setq depth1 (atof depth))<BR> (setq max_depth(min max_depth depth1))<BR> (setq dist(rtos dist 2 2))<BR> (setq string(strcat dist "," depth "," kind "," code))<BR> (write-line string fdata)<BR> )<BR> )<BR> )<BR> (progn<BR> (if (= kind "road")<BR> (progn<BR> (setq code "0")<BR> (setq depth h_road)<BR> (setq max_dist(max max_dist dist))<BR> (setq depth1 (atof depth))<BR> (setq max_depth(min max_depth depth1))<BR> (setq dist(rtos dist 2 2))<BR> (setq string(strcat dist "," depth "," kind "," code))<BR> (write-line string fdata)<BR> )<BR> )<BR> )<BR> )<BR> )<BR> (princ"\n本次选择共有")(princ n_zero)(princ"条管线的埋深未输入!")<BR> (command "line" pt1 pt2 "")<BR> (setq max_dist(distance pt1 pt2))<BR> (setq max_dist(rtos max_dist 2 2))<BR> (setq max_depth(rtos (* -1 max_depth) 2 2))<BR> (setq endline(strcat max_dist "," max_depth))<BR> (write-line endline fdata)<BR> (close fdata)<BR> (princ"\n")<BR> (princ"OVER!")<BR> )
;;注:这是其中的那个取外部数据的程序,请您帮忙看看,哪有问题.
页:
[1]