srinivasarajug 发表于 2022-7-6 08:23:50

LW多段线长度(顶点到v

亲爱的朋友们
 
我需要一个lisp程序,即Lwpolyline总长度和顶点到顶点之间的长度,它应该导出为文本文件。
 
请给出解决方案
 
非常感谢。
瓦苏

Lee Mac 发表于 2022-7-6 08:31:09

很无聊
 

(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))

srinivasarajug 发表于 2022-7-6 08:36:46

非常感谢Stefen!
这段代码对我帮助很大!!

stevesfr 发表于 2022-7-6 08:41:05

听到这个我很高兴,科菲什。不客气。

srinivasarajug 发表于 2022-7-6 08:47:43

srinivasarajug 发表于 2022-7-6 08:53:55

Sorry again i am asking is each vertex coordinates and length also

Lee Mac 发表于 2022-7-6 08:59:58

>> 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.

stevesfr 发表于 2022-7-6 09:02:31

 
as he utters a sigh of relief !!!   thanks LM, I'm not so dizzy now.

corfish 发表于 2022-7-6 09:08:59

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

Stefan BMR 发表于 2022-7-6 09:16:20

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
查看完整版本: LW多段线长度(顶点到v