本帖最后由 小鸟 于 2023-7-26 21:06 编辑
- ;;;以下是线段统计长度的脚本
- ;;;===============================
- (princ "\n程序:duoduanxianqiuhe 命令:duoduanxian")
- (defun C:duoduanxian (/ CURVE TLEN SS N
- ;SUMLEN
- )
- (vl-load-com)
- (setq SUMLEN 0)
- (setq SS (ssget '((0 . "CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC"))))
- (setq N 0)
- (repeat (sslength SS)
- (setq CURVE (vlax-ename->vla-object (ssname SS N)))
- (setq TLEN (vlax-curve-getdistatparam CURVE (vlax-curve-getendparam CURVE)))
- (setq SUMLEN (+ SUMLEN TLEN))
- (setq N (1+ N)))
- (setq sumlen(/ sumlen 1000))
- (SET-CLIP-STRING (rtos SUMLEN 2 2))
- (princ (strcat "\n共选择 " (itoa (sslength SS)) " 条线段. 线段总长: " (rtos SUMLEN 2 2)" m"))
- (princ) )
- ;;;==================================
- ;;;我想让这个脚本里统计的线段长度自动复制到剪贴板里用于复制到EXCEL
- ;;;需要怎么修改这个脚本?
- ;;;如果有用的话,我可以微信转账30块答谢
- ;;;
- ;;;=======================
- ;;;说一下我得软件环境,天正T20V9平台,AutoCAD2013_64
- ;;;=================================================================*
- ;;;功能:向系统剪贴板写入文字 *
- (defun SET-CLIP-STRING (STR / HTML RESULT)
- (and (= (type STR) 'STR)
- (setq HTML (vlax-create-object "htmlfile"))
- (setq RESULT (vlax-invoke
- (vlax-get (vlax-get HTML 'PARENTWINDOW)
- 'CLIPBOARDDATA
- )
- 'SETDATA
- "Text"
- STR
- )
- )
- (vlax-release-object HTML)
- (princ "复制到剪贴板")
- )
- )
- ;;;=================================================================*
|