乐筑天下

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

[编程交流] 带有多个

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:03:45 | 显示全部楼层
 
正如我所说,它确实做出了很多假设,它假设信息的形式如下:
 
x、 y,zr
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:08:24 | 显示全部楼层
  1. (defun c:CirMake  (/ file nl) ; Define Function/Localise Variables
  2. (vl-load-com) ; Load VL functions
  3. (if ; If the following is true
  4.    (setq file (getfiled "Select Text File to Read" "" "csv" ) ; Select a file
  5.    (progn ; Wrap the following statements
  6.      (setq file (open file "r")) ; Opent the file for reading
  7.      (while ; While the following
  8.        (setq nl (read-line file)) ; Read a line from the file
  9.        (command "_.circle" ; Invoke the circle command
  10.                 "_non" ; Ignore OSNAPS
  11.                 (substr nl 1 (vl-string-position 9 nl)) ; Detect the Space in the line and get the text before the space
  12.                 (substr nl (+ (vl-string-position 9 nl) 2)))) ; Get the text after the space
  13.      (close file)) ; Close the file
  14.    (princ "\n<!> No File Selected <!>")) ; Else no File was selected
  15. (princ)) ; Exit Cleanly
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 2022-7-6 15:10:40 | 显示全部楼层
试试这个。
使用记事本创建名为ctxt的文本文件。txt并将其保存到C:驱动器
文件格式如下:
10,10
1.
15,15
2.
20.75,16.5
0.75
首先是坐标,然后是半径
加载lisp文件并在命令行上键入ccs
 
 
  1. [font=Times New Roman](defun c:ccs (/ ff cl n ctx opf rln cnt lynum retv)[/font]
  2. [font=Times New Roman] (setq ff (findfile "c:/ctxt.txt"));_look for text file[/font]
  3. [font=Times New Roman] (if ff[/font]
  4. [font=Times New Roman] (progn[/font]
  5. [font=Times New Roman] (command "undo" "be");_set undo marker[/font]
  6. [font=Times New Roman] (setq cl (getvar "clayer"));_get current layer[/font]
  7. [font=Times New Roman] (setq n 1);_while loop killer[/font]
  8. [font=Times New Roman] (setq ctx '());_empty list[/font]
  9. [font=Times New Roman] (setq opf (open ff "r"));_if file found open it[/font]
  10. [font=Times New Roman] (while (= n 1);_loop to read lines of file[/font]
  11. [font=Times New Roman]   (setq rln (read-line opf))[/font]
  12. [font=Times New Roman] (if rln (setq ctx(cons rln ctx))(setq n nil));_if line not nil write to list else kill loop[/font]
  13. [font=Times New Roman]   );_while[/font]
  14. [font=Times New Roman] (close opf);_close file[/font]
  15. [font=Times New Roman] (if ctx  ;_if file has info continue [/font]
  16. [font=Times New Roman]  (progn[/font]
  17. [font=Times New Roman] (setq ctx (reverse ctx));_flip list from file[/font]
  18. [font=Times New Roman] (setq cnt 0);_loop counter[/font]
  19. [font=Times New Roman] (setq lynum 1);_layer number added to end of layer name[/font]
  20. [font=Times New Roman] (while (< cnt (length ctx));_loop through list[/font]
  21. [font=Times New Roman] (setq x (nth cnt ctx));_coordinates[/font]
  22. [font=Times New Roman] (setq r (nth (1+ cnt) ctx));_redius[/font]
  23. [font=Times New Roman] (setq retv (crly lynum));_call to layer maker[/font]
  24. [font=Times New Roman] (setvar "clayer" (nth 0 retv));_set layer to new layer[/font]
  25. [font=Times New Roman] (setq lynum (nth 1 retv));_layer # counter[/font]
  26. [font=Times New Roman] (command "_circle" x r);_make circle[/font]
  27. [font=Times New Roman] (setq cnt (+ cnt 2));_up loop counter by 2[/font]
  28. [font=Times New Roman] (setq lynum (1+ lynum));_up layer number by 1[/font]
  29. [font=Times New Roman] );_while[/font]
  30. [font=Times New Roman]    );_progn  [/font]
  31. [font=Times New Roman] );_if[/font]
  32. [font=Times New Roman] (setvar "clayer" cl);_reset back to old layer[/font]
  33. [font=Times New Roman] (command "undo" "END");_end undo group[/font]
  34. [font=Times New Roman]   );_progn if txt[/font]
  35. [font=Times New Roman]   );_if txt[/font]
  36. [font=Times New Roman]   (princ)[/font]
  37. [font=Times New Roman]  );_defun[/font]
  38. [font=Times New Roman] [/font]
  39. [font=Times New Roman](defun crly (aug1 / lp1 tbs retval)[/font]
  40. [font=Times New Roman] (command "-purge" "LA" "cir-*" "n");_purge any unused circle layers  [/font]
  41. [font=Times New Roman] (setq lp1 1);_loop killer[/font]
  42. [font=Times New Roman] (while (= lp1 1)[/font]
  43. [font=Times New Roman] (setq tbs (tblsearch "layer" (strcat "cir-" (itoa aug1))));_search for layer[/font]
  44. [font=Times New Roman] (if tbs  ;_if found  [/font]
  45. [font=Times New Roman] (setq aug1 (1+ aug1));_up layer # by 1[/font]
  46. [font=Times New Roman] (progn[/font]
  47. [font=Times New Roman] (setq lp1 nil);_kill loop if layer not found[/font]
  48. [font=Times New Roman] (setq retval (strcat "cir-" (itoa aug1)));_new layer name[/font]
  49. [font=Times New Roman] (command "-layer" "n" retval "");_make new layer[/font]
  50. [font=Times New Roman] );_progn[/font]
  51. [font=Times New Roman] );_if[/font]
  52. [font=Times New Roman]   );_while[/font]
  53. [font=Times New Roman] (list retval aug1);_return layer name and layer number[/font]
  54. [font=Times New Roman]);_defun[/font]
  55. [font=Times New Roman][/font]
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:14:35 | 显示全部楼层
如果已将Excel文件的内容直接复制到txt文件中,并且Excel文件中的数据格式为:
 
x y r
 
正如您之前提到的,这可能会起作用:
 
  1. (defun c:CirMake (/ *error* vlst ovar file nl lst)
  2. (vl-load-com)
  3. (defun *error* (msg)
  4.    (if ovar (mapcar 'setvar vlst ovar))
  5.    (if (not (member msg '("Function cancelled" "quit / exit abort")))
  6.      (princ (strcat "\n<< Error: " msg " >>")))
  7.    (princ))
  8. (setq vlst '("CMDECHO" "OSMODE")
  9.        ovar (mapcar 'getvar vlst))
  10. (mapcar 'setvar vlst '(0 0))
  11. (if (setq file (getfiled "Select Text File to Read" "" "txt" )
  12.    (progn
  13.      (setq file (open file "r"))
  14.      (while (setq nl (read-line file))
  15.        (setq lst (StrBrk nl 9))
  16.        (command "_.circle"
  17.                 (list (distof (car lst))
  18.                       (distof (cadr lst)) 0.0) (caddr lst)))
  19.      (close file))
  20.    (princ "\n<!> No File Selected <!>"))
  21. (princ))
  22. (defun StrBrk (str chrc / pos lst)
  23. (while (setq pos (vl-string-position chrc str))
  24.    (setq lst (cons (substr str 1 pos) lst)
  25.          str (substr str (+ pos 2))))
  26. (reverse (cons str lst)))
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 2022-7-6 15:18:24 | 显示全部楼层
哇,这是错误的方式张贴
 
 
  1. (defun c:ccs (/ ff cl n ctx opf rln cnt lynum retv)
  2. (setq ff (findfile "c:/ctxt.txt"));_look for text file
  3. (if ff
  4. (progn
  5. (command "undo" "be");_set undo marker
  6. (setq cl (getvar "clayer"));_get current layer
  7. (setq n 1);_while loop killer
  8. (setq ctx '());_empty list
  9. (setq opf (open ff "r"));_if file found open it
  10. (while (= n 1);_loop to read lines of file
  11.   (setq rln (read-line opf))
  12. (if rln (setq ctx(cons rln ctx))(setq n nil));_if line not nil write to list else kill loop
  13.   );_while
  14. (close opf);_close file
  15. (if ctx  ;_if file has info continue
  16. (progn
  17. (setq ctx (reverse ctx));_flip list from file
  18. (setq cnt 0);_loop counter
  19. (setq lynum 1);_layer number added to end of layer name
  20. (while (< cnt (length ctx));_loop through list
  21. (setq x (nth cnt ctx));_coordinates
  22. (setq r (nth (1+ cnt) ctx));_redius
  23. (setq retv (crly lynum));_call to layer maker
  24. (setvar "clayer" (nth 0 retv));_set layer to new layer
  25. (setq lynum (nth 1 retv));_layer # counter
  26. (command "_circle" x r);_make circle
  27. (setq cnt (+ cnt 2));_up loop counter by 2
  28. (setq lynum (1+ lynum));_up layer number by 1
  29. );_while
  30.    );_progn  
  31. );_if
  32. (setvar "clayer" cl);_reset back to old layer
  33. (command "undo" "END");_end undo group
  34.   );_progn if txt
  35.   );_if txt
  36.   (princ)
  37. );_defun
  38. (defun crly (aug1 / lp1 tbs retval)
  39. (command "-purge" "LA" "cir-*" "n");_purge any unused circle layers  
  40. (setq lp1 1);_loop killer
  41. (while (= lp1 1)
  42. (setq tbs (tblsearch "layer" (strcat "cir-" (itoa aug1))));_search for layer
  43. (if tbs  ;_if found  
  44. (setq aug1 (1+ aug1));_up layer # by 1
  45. (progn
  46. (setq lp1 nil);_kill loop if layer not found
  47. (setq retval (strcat "cir-" (itoa aug1)));_new layer name
  48. (command "-layer" "n" retval "");_make new layer
  49. );_progn
  50. );_if
  51.   );_while
  52. (list retval aug1);_return layer name and layer number
  53. );_defun
回复

使用道具 举报

SSA

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:21:47 | 显示全部楼层
正在加载C:\Auto Files试用版\CirMake。lsp
:STRBRK
 
这就是我得到的。
我创建了名为ctxt的文本文件。txt文件
上传cirmake
回复

使用道具 举报

SSA

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:24:07 | 显示全部楼层
 
为此我得到了
 
_加载
:ccs
:撤消
撤消:标记/返回到标记/开始设置/结束设置/控制/自动/:be
:-purgeerror:拒绝的函数
 
我错过了什么?
谢谢
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 2022-7-6 15:27:28 | 显示全部楼层
我不熟悉IntelliCAD
因此,这可能只是undo和purge命令的一些语法错误。
看起来它希望(命令“undo”“END”)读取(命令“undo”“E”)
或(命令“undo”“End set”)
所以只要做出改变,看看会发生什么。
 
清除错误是另一回事。在您的IntelliCAD上
命令行类型–清除并查看它是否为可用命令。如果没有,请找出IntelliCAD中是否有清除命令
 
. 现在,您可以用分号注释清除命令行
像这样放在括号之前;(命令“-清除………。
 
如果IntelliCAD
有一个不同的清除命令,我们必须将其替换为我的命令,并使其工作。
我只是觉得如果你删除了圆圈,最好清除未使用的图层。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:29:52 | 显示全部楼层
 
你复制了框架中的所有代码吗?
回复

使用道具 举报

SSA

1

主题

8

帖子

7

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:34:18 | 显示全部楼层
是的,我做了。
框架中的所有代码。
我会再试一次,也许文本文件有一些格式问题?
 
谢谢大家今天的帮助。我真的很感激。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 00:26 , Processed in 0.364646 second(s), 70 queries .

© 2020-2025 乐筑天下

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