什么';李,那是不对的
(Defun C:DSS ()(setq bnum (getint "\nEntre com um numero: "))
(setq inum (itoa bnum))
(Setq PT1 (GetPoint "\nPonto de Desapropriação: " ))
(Command "-INSERT""PONTO" PT1 "1""1""0" inum inum "")
(while (/= nil PT1)
(setq bnum (+ bnum 1))
(setq inum (itoa bnum))
(setq PT1 (getpoint "\nEscolha proximo ponto: "))
(Command "-INSERT""PONTO" PT1 "1""1""0" inum inum "")
)
(setq ptlist (append ptlist (list PT1)))
(setq file (open (getfiled "Output file" "" "" 5) "w"))
(write-line (strcat (rtos (cadr PTLIST)) "," (rtos (caddr PTLIST))) file)
(close file)
(Princ)
)
这是一个lisp,我想把每个“插入点坐标”,并把它放在一个“.csv”文件中,我将在excel中打开它并生成一个坐标表…但不起作用…我需要一些提示,我不想要解决方案。我想从我自己的。如果有人可以帮助我,我将非常感谢。
PS:对不起,我的英语不好 你不想扩展我之前在你的另一个线程中发布的LISP来帮助你完成上述任务吗
(defun c:DSS(/ oldatt bnum pt1)
(setq oldatt (getvar "ATTREQ"))
(setvar "ATTREQ" 1)
(if (and (setq bnum (getint "\nEntr com um numero: "))
(or (tblsearch "BLOCK" "PONTO")
(findfile "PONTO.dwg")))
(while (setq pt1 (getpoint "\nPonto de Desapropriação: "))
(command "-insert" "ponto" pt1 "1" "1" "0" (itoa bnum) (itoa bnum) "")
(setq bnum (1+ bnum))))
(setvar "ATTREQ" oldatt)
(princ))
也许像这样的东西可以写入文件?
(defun c:DSS(/ oldatt file bnum pt1 ptlst)
(setq oldatt (getvar "ATTREQ"))
(setvar "ATTREQ" 1)
(if (and (setq bnum (getint "\nEntr com um numero: "))
(or (tblsearch "BLOCK" "PONTO")
(findfile "PONTO.dwg"))
(setq file (getfiled "Output File" "" "csv" 9)))
(progn
(while (setq pt1 (getpoint "\nPonto de Desapropriação: "))
(command "-insert" "ponto" pt1 "1" "1" "0" (itoa bnum) (itoa bnum) "")
(setq bnum(1+ bnum)
ptlst (cons pt1 ptlst))) ; Add the point to the list
(setq file (open file "w")) ; Open the file for writing
(mapcar
(function
(lambda (x)
(write-line
(strcat (rtos (car x)) "," (rtos (cadr x))) file))) ptlst)
; Write each pt in the list to the file
(close file)))
; Close the file
(setvar "ATTREQ" oldatt)
(princ))
这对我来说很先进,啊哈,但我能理解你的台词。。。我已经有1个lsp与你的增量,工作得很好!!!所以,我想增加更多,得到一个*。带有坐标的csv文件。我可以用“append”吗?
我的代码怎么了?
“EDIT”=你太快了,忽略上面的文字 这绝对是我想的!非常感谢你。我甚至不知道这个函数lambda。。。
谢谢
至于“lambda”,它被称为“匿名函数”,当你想对列表中的每个成员执行一组操作时,你可以将“mapcar”与“lambda”函数结合起来,后者是你想执行的操作的一般示例。。。如果这有意义的话。。。
即
(mapcar '(lambda (x) (+ x 2)) '(1 2 3))
or
(mapcar (function (lambda (x) (+ x 2))) (list 1 2 3))
将返回:
(3 4 5)
可以看到,通用函数“lambda”已经应用于列表中的每个成员,结果是一个返回列表。
页:
[1]