LW多段线长度(顶点到v
亲爱的朋友们我需要一个lisp程序,即Lwpolyline总长度和顶点到顶点之间的长度,它应该导出为文本文件。
请给出解决方案
非常感谢。
瓦苏 很无聊
(defun c:PlLen (/ i ss file ent j str)
(vl-load-com)
(cond ((and (setq i -1 ss (ssget '((0 . "LWPOLYLINE"))))
(setq file (getfiled "Output File" "" "txt" 1)))
(setq file (open file "w"))
(while (setq ent (ssname ss (setq i (1+ i))))
(setq j (1- (vlax-curve-getStartParam ent)) Str "")
(while (<= (setq j (1+ j)) (vlax-curve-getEndParam ent))
(setq Str
(strcat Str
(rtos (- (vlax-curve-getDistatParam ent j)
(if (zerop j) 0
(vlax-curve-getDistatParam ent (1- j)))) 2 2) (chr 9))))
(write-line (strcat Str (rtos (vlax-curve-getDistatParam ent
(vlax-curve-getEndParam ent)) 2 2)) file))
(close file)))
(princ))
非常感谢Stefen!
这段代码对我帮助很大!! 听到这个我很高兴,科菲什。不客气。 Sorry again i am asking is each vertex coordinates and length also >> Steve,
You're not dense
I have formatted it in such a way that each entry in the file is the distance to each vertex in turn (from the start of the curve), hence the distance from the start vertex to the start vertex is always zero.. - I probably could have ignored this point, but I wanted the number of distances to equal the number of points... with the length being the last entry.
as he utters a sigh of relief !!! thanks LM, I'm not so dizzy now. Hi friends,
This is what I wanted from ages!!
but I nneed result that means segment lengths as stored in variables as that I can assign them as values of attributes in a block!
Can we do this!
Thanks in advance.
corfish Try this variant
(defun C:TEST ( / SegmLen ss lst) (defun SegmLen (e / i l) (repeat (setq i (fix (vlax-curve-GetEndParam e))) (setq l (cons (apply '- (mapcar '(lambda (x) (vlax-curve-GetDistAtParam e x)) (list i (setq i (1- i))))) l)) ) ) (if (setq ss (ssget ":E:S" '((0 . "*POLYLINE")))) (progn (setq lst (SegmLen (ssname ss 0))) (princ lst) ;just to show result ;do whatever you want with lst variable ) ) (princ))
页:
[1]
2