srinivasarajug Posted October 2, 2009 Share Posted October 2, 2009 Dear Friends I need a one lisp program i.e. Lwpolyline total length and length between the vertex to vertex it's should be export as text file. pls give the solution Thank You Vasu Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 2, 2009 Share Posted October 2, 2009 Was bored (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)) Quote Link to comment Share on other sites More sharing options...
srinivasarajug Posted October 3, 2009 Author Share Posted October 3, 2009 Thank u very much for given code and one more thing i need the each vertex coordinate and length in text file sorry if you are feeling problem Thank You Vasu Quote Link to comment Share on other sites More sharing options...
stevesfr Posted October 3, 2009 Share Posted October 3, 2009 Was bored (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)) Why is the first point in the answer file always zero? Sorry to be so dense. Quote Link to comment Share on other sites More sharing options...
srinivasarajug Posted October 3, 2009 Author Share Posted October 3, 2009 Sorry again i am asking is each vertex coordinates and length also Quote Link to comment Share on other sites More sharing options...
srinivasarajug Posted October 6, 2009 Author Share Posted October 6, 2009 Sorry again i am asking is each vertex coordinates and length also Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 6, 2009 Share Posted October 6, 2009 >> 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. Quote Link to comment Share on other sites More sharing options...
stevesfr Posted October 6, 2009 Share Posted October 6, 2009 >> 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. Quote Link to comment Share on other sites More sharing options...
corfish Posted January 23, 2012 Share Posted January 23, 2012 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 Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted January 23, 2012 Share Posted January 23, 2012 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) ) Quote Link to comment Share on other sites More sharing options...
corfish Posted January 23, 2012 Share Posted January 23, 2012 Thanks a lot Stefen! This code help me immensely!! Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted January 23, 2012 Share Posted January 23, 2012 I am glad to hear that, corfish. You're welcome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.