乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 90|回复: 4

[编程交流] 重复命令故障

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 15:28:41 | 显示全部楼层 |阅读模式
尊敬的先生:,
 
我的“repeat”命令有问题,我的lisp无法从take*重复到连续绘图。prn数据。这是lisp脚本和*。prn文件;
 
我不明白为什么repeat命令不能工作,可能是我错过了这个脚本中的其他命令,我希望我能为这个脚本找到任何解决方案。
如果我的英语不是很好,我很抱歉,谢谢你。
交叉rar公司
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 15:57:11 | 显示全部楼层
也许这个简单的修复
 
  1. (repeat 3()
  2. should be
  3. (repeat 3
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:03:35 | 显示全部楼层
尊敬的Bigal:,
我认为这行不会发生任何事情,脚本只读取第一个数据,无法连续工作以读取下一个数据。也许我必须更努力地为命令脚本创造其他机会,我同意你的动机“一个从不犯错误的人从来没有做过任何事”。。。
 
  1. (repeat 3
  2. (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 n  10)))             (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 n  10)))             (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
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:20:03 | 显示全部楼层
只要第一个参数是整数,它就应该工作
  1. ([color="blue"][b]repeat[/b][/color] [color="red"]int[/color] anything bla bla )

 
 
只需分享一些想法:
 
1.本地化变量,同时避免使用太多变量,这可能会造成混淆和拼写错误
LISP很适合列表操作,可以更好地将数据存储在列表中。看看这些函数:list、car、cdr、nth、assoc、mapcar、foreach、member等。。
 
2、关于文件检查。。为什么不归档?
  1. ([color="blue"]while[/color] (not fnam) (setq  fnam  ([color="blue"]getfiled[/color] "\nFile Input Data Cross" "c:/cross/data" "prn" 16)))

 
3.(setq stop 1);旗帜在我看来,你可以尝试以下方式:
  1.    (if (setq str (read-line f)) [color="green"]....[/color] )  (while str [color="green"]....[/color] )

 
4.当使用以下命令调用时:(命令行…)(命令“text”…)
有时,osmode启用将是导致该线路故障的罪魁祸首
绘制捕捉到其他对象
 
FWIW、entmake entity速度更快、效率更高,并且没有osmode捕捉问题
 
  1. (defun _line ( p1 p2 co )
  2. ([b][color="blue"]entmakex[/color][/b] (list '(0 . "LINE")(cons 62 co)(cons 10 p1 )(cons 11 p2 )))
  3. )

 
;实例
  1. [color="green"];single call[/color]
  2. ([color="blue"]_line[/color] p1 p2 140 )
  3. [color="green"];multiple:[/color]
  4. (mapcar ''((a b)([color="blue"]_line[/color] a b 140)) (list p1 p3 p5 pn)(list p2 p4 p6 pn))

 
附言:您应该恢复sysvar吗?
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:41:23 | 显示全部楼层

                               
登录/注册后可看大图

 
我也快速看了一眼,我想我还有更多的话要说,韩胡克还没有说。刚刚标记的行是你的代码错误。确实得到了一些结果,足以让我看到这不是我的工作领域。但是,本地化变量名也是我的第一个建议。
 
  1. 8
Rlx级
162849kkw2cww2wwkdzw23.jpg
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 00:12 , Processed in 0.442167 second(s), 75 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表