重复命令故障
尊敬的先生:,我的“repeat”命令有问题,我的lisp无法从take*重复到连续绘图。prn数据。这是lisp脚本和*。prn文件;
我不明白为什么repeat命令不能工作,可能是我错过了这个脚本中的其他命令,我希望我能为这个脚本找到任何解决方案。
如果我的英语不是很好,我很抱歉,谢谢你。
交叉rar公司 也许这个简单的修复
(repeat 3()
should be
(repeat 3
尊敬的Bigal:,
我认为这行不会发生任何事情,脚本只读取第一个数据,无法连续工作以读取下一个数据。也许我必须更努力地为命令脚本创造其他机会,我同意你的动机“一个从不犯错误的人从来没有做过任何事”。。。
(repeat 3
(setq p3 p0) (setq fp (open fnam "r")) (setq file (read-line fp)) (if (= file "") (setq file nil)) (if (= file nil) (setq stop 1) (setq stop 0)) (setq noptk (atof (substr file n 10))) (setq file (read-line fp)) (setq eldat (atof (substr file n 10))) (setq file (read-line fp)) (setq jar0 (atof (substr file n 10))) (setq elt1 (atof (substr file (+ n 10 ) 10))) (setq tbl (atof (substr file (+ n 30 ) 10))) (setq slp (atof (substr file (+ n 40 ) 10))) (setq p01 (polar p0 (* 0.5 pi) (* (- elt1 eldat) scv))) (setq p02 (polar p0 (* 0.5 pi) (* (- elt2 eldat) scv))) (command "color" 20 "-linetype" "s" "dashed2" "") (command "line" p0 p02 "") (command "color" 20 "-linetype" "s" "continuous" "") (command "line" p0 (polar p0 (* 1.5 pi) 50) "") (command "color" 7) (setq p01tx (polar p0 (* 1.5 pi) 15)) (setq p02tx (polar p0 (* 1.5 pi) 25)) (setq p0tx (polar p0 (* 1.5 pi) 35)) (setq p50 (polar p0 pi -5)) (setq p51 (polar p0 pi 50)) (setq p52 (polar p51 (* 1.5 pi) 5)) (setq p53 (polar p52 (* 1.5 pi) 10)) (setq p54 (polar p53 (* 1.5 pi) 10)) (setq p55 (polar p54 (* 1.5 pi) 10)) (setq p56 (polar p55 (* 1.5 pi) 10)) (setq p57 (polar p0 pi 53)) (setq p58 (polar p57 (* 1.5 pi) 10)) (setq p59 (polar p58 (* 1.5 pi) 10)) (setq p60 (polar p59 (* 1.5 pi) 10)) (setq p61 (polar p60 (* 1.5 pi) 10)) (setq p62 (polar p61 (* 1.5 pi) 10)) (command "text" "j" "tc" '(-30.0 25.0) "3.5" 0 (strcat "STA." (rtos noptk 2 0))) (command "text" "j" "tc" p01tx "2.5" 90 (rtos elt1 2 2)) (command "text" "j" "tc" p02tx "2.5" 90 (rtos elt2 2 2)) (command "text" "j" "tc" p0tx "2.5" 90 (rtos slp 2 2)) (if (> eldat 0) (command "text" "j" "bl" p50 "2.5" 0 (strcat "+" (rtos eldat 2 2) " m")) (command "text" "j" "bl" p50 "2.5" 0 (strcat (rtos eldat 2 2) " m")) );if (command "text" "j" "ml" p52 "2.5" 0 "JARAK (m)") (command "text" "j" "ml" p53 "2.5" 0 "TINGGI ASAL (m)") (command "text" "j" "ml" p54 "2.5" 0 "TINGGI RENCANA (m)") (command "text" "j" "ml" p55 "2.5" 0 "TEBAL RENCANA(m)") (command "text" "j" "ml" p56 "2.5" 0 "SLOPE RENCANA(m)") (command "color" 20 "-linetype" "s" "continuous" "") (command "line" p0 p57 "") (command "color" 20 "-linetype" "s" "continuous" "") (command "line" p58 (polar p58 (* 0.0 pi) 53) "") (command "line" p59 (polar p59 (* 0.0 pi) 53) "") (command "line" p60 (polar p60 (* 0.0 pi) 53) "") (command "line" p61 (polar p61 (* 0.0 pi) 53) "") (command "line" p62 (polar p62 (* 0.0 pi) 53) "") (command "line" p57 p62 "")(setq file (read-line fp)) (setq jar1 (atof (substr file n10))) (setq elt(atof (substr file (+ n 10 ) 10))) (setq elt3(atof (substr file (+ n 20 ) 10))) (setq tbl1(atof (substr file (+ n 30 ) 10))) (setq slp1(atof (substr file (+ n 40 ) 10))) (if (= jar1 "")(setq jar1 nil)) (if (= jar1 nil)(setq stop 1) (setq stop 0)) (while (= stop 0) (setq jar (- jar1 jar0)) (setq jar0 jar1) (setq p2(polar p0 0 (* jar sch)) p21 (polar p2 (* 0.5 pi) (* (- elt eldat) scv))) (setq jar3 (- jar1 jar0)) (setq jar0 jar1) (setq p2(polar p2 0 (* jar3 sch)) p22 (polar p2 (* 0.5 pi) (* (- elt3 eldat) scv))) (command "color" 211 "-linetype" "s" "dashed2" "") (command "line" p2 p22 "") (command "color" 140 "-linetype" "s" "continuous" "") (command "line" p01 p21 "") (command "color" 140 "-linetype" "s" "dashed2" "") (command "line" p02 p22 "") (command "color" 20 "-linetype" "s" "continuous" "") (command "line" p0 p2 "") (command "color" 20 "-linetype" "s" "continuous" "") (command "line"(polar p0 (* 1.5 pi) 10)(polar p2 (* 1.5 pi) 10)"") (command "line"(polar p0 (* 1.5 pi) 20)(polar p2 (* 1.5 pi) 20)"") (command "line"(polar p0 (* 1.5 pi) 30)(polar p2 (* 1.5 pi) 30)"") (command "line"(polar p0 (* 1.5 pi) 40)(polar p2 (* 1.5 pi) 40)"") (command "line"(polar p0 (* 1.5 pi) 50)(polar p2 (* 1.5 pi) 50)"") (setq p23 (polar p2 (* 1.5 pi) 50)) (command "line" p2 p23 "") (setq p2tx1 (polar p2 (* 1.5 pi) 15) p2tx3 (polar p0 0 (* (/ jar 2) sch)) p2tx2 (polar p2tx3 (* 1.5 pi) 5)) (if (< (* jar sch) 10) (setq sdttx2 90) (setq sdttx2 0)) (command "color" 7) (command "text" "j" "bc" p2tx1 "2.5" 90 (rtos elt 2 2)) (command "text" "j" "mc" p2tx2 "2.5" sdttx2 (rtos jar 2 2)) (setq p2tx4 (polar p2 (* 1.5 pi) 25) p2tx6 (polar p0 0 (* (/ jar3 2) sch)) p2tx5 (polar p2tx6 (* 1.5 pi) 5)) (if (< (* jar3 sch) 10) (setq sdttx5 90) (setq sdttx5 0)) (command "color" 7) (command "text" "j" "bc" p2tx4 "2.5" 90 (rtos elt3 2 2)) (setq p2tx7 (polar p2 (* 1.5 pi) 35) p2tx6 (polar p0 0 (* (/ jar3 2) sch)) p2tx5 (polar p2tx6 (* 1.5 pi) 5)) (command "color" 7) (command "text" "j" "bc" p2tx7 "2.5" 90 (rtos tbl1 2 2)) (setq p2tx8 (polar p0 0 (* (/ jar 2) sch)) p2tx9 (polar p2tx8 (* 1.5 pi) 45)) (if (< (* jar sch) 10) (setq sdttx9 90) (setq sdttx9 0)) (command "color" 7) (command "text" "j" "bc" p2tx9 "2.5" sdttx9 (rtos slp1 2 2)) (setq p0 p2) (setq p01 p21) (setq p02 p22) (setq file (read-line fp)) (setq jar1 (atof (substr file n10))) (setq elt(atof (substr file (+ n 10 ) 10))) (setq elt3(atof (substr file (+ n 20 ) 10))) (setq tbl1(atof (substr file (+ n 30 ) 10)))(setq slp1(atof (substr file (+ n 40 ) 10))) (if (= jar1 "")(setq jar1 nil)) (if (= jar1 nil)(setq stop 1)(setq stop 0))) (setq p0 (polar p3 (* 1.5 pi) 150)) (setq p3 p0) (setq n (+ n 50)) );repeat 只要第一个参数是整数,它就应该工作
(repeat int anything bla bla )
只需分享一些想法:
1.本地化变量,同时避免使用太多变量,这可能会造成混淆和拼写错误
LISP很适合列表操作,可以更好地将数据存储在列表中。看看这些函数:list、car、cdr、nth、assoc、mapcar、foreach、member等。。
2、关于文件检查。。为什么不归档?
(while (not fnam) (setqfnam(getfiled "\nFile Input Data Cross" "c:/cross/data" "prn" 16)))
3.(setq stop 1);旗帜在我看来,你可以尝试以下方式:
(if (setq str (read-line f)) .... )(while str .... )
4.当使用以下命令调用时:(命令行…)(命令“text”…)
有时,osmode启用将是导致该线路故障的罪魁祸首
绘制捕捉到其他对象
FWIW、entmake entity速度更快、效率更高,并且没有osmode捕捉问题
(defun _line ( p1 p2 co )
(entmakex (list '(0 . "LINE")(cons 62 co)(cons 10 p1 )(cons 11 p2 )))
)
;实例
;single call
(_line p1 p2 140 )
;multiple:
(mapcar ''((a b)(_line a b 140)) (list p1 p3 p5 pn)(list p2 p4 p6 pn))
附言:您应该恢复sysvar吗? https://www.cadtutor.net/forum/attachment.php?attachmentid=63520&cid=1&stc=1
我也快速看了一眼,我想我还有更多的话要说,韩胡克还没有说。刚刚标记的行是你的代码错误。确实得到了一些结果,足以让我看到这不是我的工作领域。但是,本地化变量名也是我的第一个建议。
8Rlx级
页:
[1]