这个是一个统计多线段长度的lsp文件,我现在想要获取他的输出值,方便看一下可以怎么加入写入变量的内容吗?
(princ "\n程序:统计线段长度 命令:te")(defun C:TE (/ 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))(princ (strcat "\n共选择 " (itoa (sslength SS)) " 条线段. 线段总长: "(rtos SUMLEN 2 3) "米."))(princ) )
你试试这个,直接把获取到的长度输出到剪贴板,然后quicker获取剪贴板做变量就行
(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)
)
)
(defun C:TE (/ 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 3))
(princ (strcat "\n共选择 " (itoa (sslength SS)) " 条线段. 线段总长: "(rtos SUMLEN 2 3) "米."))
(princ)
)