乐筑天下

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

[编程交流] 双脚到米Lisp程序?

[复制链接]

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 18:09:44 | 显示全部楼层 |阅读模式
你好
 
我不精通LISP语言。
 
有人可以编辑以下内容吗。lsp对我来说,将生成的电子表格从英尺和英寸更改为米?
 
提前谢谢。
 
 
  1. (defun c:ple (/        elist         en          i           layer    layer_list
  2.         leng         pline          row           ss            sumlen   total
  3.         x         xlApp          xlBook   xlBooks  xlCells  xlSheet
  4.         xlSheets
  5.        )
  6. (vl-load-com)
  7. (setq        xlApp           (vlax-get-or-create-object "Excel.Application")
  8. xlBooks  (vlax-get-property xlApp "Workbooks")
  9. xlBook           (vlax-invoke-method xlBooks "Add")
  10. xlSheets (vlax-get-property xlBook "Sheets")
  11. xlSheet           (vlax-get-property xlSheets "Item" 1)
  12. xlCells           (vlax-get-property xlSheet "Cells")
  13. )
  14. (vla-put-visible xlApp :vlax-true)
  15. ;headers
  16. (vlax-put-property xlCells "Item" 1 1 "Layer")
  17. (vlax-put-property xlCells "Item" 1 2 "Length")
  18. (setq row 2
  19. total 0)
  20. (setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))) i -1)
  21. (repeat (sslength ss)
  22.    (setq en (ssname ss (setq i (1+ i)))
  23.   elist (entget en)
  24.   layer (cdr (assoc 8 elist)))
  25.    (if (not (member layer layer_list))
  26.      (setq layer_list (cons layer layer_list))))
  27. (repeat (length layer_list)
  28.    (setq layer (car layer_list))
  29.    (vlax-put-property xlCells "Item" row 1 layer)
  30.    (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")(cons 8 layer))) i -1 sumlen 0)
  31.    (repeat (sslength ss)
  32.    (setq row (1+ row))  
  33.    (setq pline (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
  34.    (setq leng  (vlax-curve-getdistatparam pline
  35.           (vlax-curve-getendparam pline)))
  36.    (vlax-put-property xlCells "Item" row 2 (rtos leng 4 3))
  37.    ;;;    (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3)); for metric units  
  38.    (setq sumlen (+ sumlen leng)))
  39.    (setq row (1+ row))
  40.    (vlax-put-property xlCells "Item" row 1 "SubTotal:")
  41.    (vlax-put-property xlCells "Item" row 2 (rtos sumlen 4 3))
  42.    (setq total (+ total sumlen))
  43. ;;;    (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3)); for metric units
  44.    (setq layer_list (cdr layer_list))
  45.    (setq row (+ row 2))
  46.    
  47. )
  48. ; footers:
  49. (vlax-put-property xlCells "Item" row 1 "Total:")
  50. (vlax-put-property xlCells "Item" row 2 (rtos total 4 3))
  51. ;;;(vlax-put-property xlCells "Item" row 2 (rtos total 2 3)); for metric units  
  52. (mapcar (function (lambda(x)
  53.             (vl-catch-all-apply
  54.               (function (lambda()
  55.                           (progn
  56.                             (vlax-release-object x)
  57.                             (setq x nil)))))))
  58. (list xlCells xlSheet xlSheets xlBook xlBooks xlApp)
  59. )
  60. (alert "Close Excel file manually")
  61. (gc)(gc)
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 18:44:00 | 显示全部楼层
此外,如果可能,是否可以编辑LISP,以便除了显示多段线图层、单个长度和总长度外,CSV还显示与每个多段线相关的对象数据(每个多段线都附有对象数据格式的属性)
 
提前感谢
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 19:20:05 | 显示全部楼层
请阅读代码发布指南并使用代码标签,我现在已经修复了你的帖子。
 
对于第一个问题,似乎包含了度量部分,用;;;;注释掉了它;;;。
 
您只需要注释掉第一个(我会为Imperial添加注释),然后删除;;;从公制版本前面。
 
例子:
 
电流:
  1. (vlax-put-property xlCells "Item" row 2 (rtos leng 4 3))
  2.    ;;;    (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3)); for metric units

 
更改:
  1. ;;;  (vlax-put-property xlCells "Item" row 2 (rtos leng 4 3)); for Imperial units
  2. (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3)); for metric units
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 19:37 , Processed in 1.128649 second(s), 58 queries .

© 2020-2025 乐筑天下

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