
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I found a LISP routine to lengthen multiple polylines at once by a set number. However, what I need is to shorten them by a set amount, and this routine isn't working right with a negative delta. If the last line segment in the polyline is shorter than the trim amount, it reverses that line - in other words, it draws a new segment going backwards from the vertex, instead of trimming the next segment.
Attaching a file to illustrate the issue. The first polyline is the original. The second is the desired result (the result of using LENGTHEN). The third is what happens with this routine.
Does anyone have a fix? I need to trim hundreds of polylines by a fixed amount on each end and I don't want to do it manually. If there is a different command that might work, I'm all ears.
This is the code I am using:
(defun c:plen(/ plSet plDel plLst doMode dxfLst newEn newSt newPl)
(princ "\n <<< SELECT POLYLINES >>>")
(if
(and
(setq plSet(ssget '((0 . "LWPOLYLINE"))))
(setq plDel(getreal "\nSpecify delta: "))
); ena and
(progn
(setq plLst(vl-remove-if 'listp
(mapcar 'cadr(ssnamex plSet))))
(initget 1 "Positive Negative Both")
(if(setq doMode
(getkword "\nSpecify direction [Positive/Negative/Both]: "))
(progn
(foreach pl plLst
(setq dxfLst(entget pl)
verLst(mapcar 'cdr(vl-remove-if-not
'(lambda(x)(= 10(car x)))dxfLst))
newEn(polar(cadr(reverse verLst))
(angle(cadr(reverse verLst))(car(reverse verLst)))
(+(distance(cadr(reverse verLst))(car(reverse verLst)))plDel))
newSt(polar(cadr verLst)
(angle(cadr verLst)(car verLst))
(+(distance(cadr verLst)(car verLst))plDel))
); end setq
(cond
((= "Positive" doMode)
(setq newPl(reverse
(subst(cons 10 newEn)
(assoc 10(reverse dxfLst))(reverse dxfLst))))
); end conditon #1
((= "Negative" doMode)
(setq newPl(subst(cons 10 newSt)
(assoc 10 dxfLst)dxfLst))
); end condition #2
((= "Both" doMode)
(setq dxfLst(subst(cons 10 newSt)
(assoc 10 dxfLst)dxfLst)
newPl(reverse
(subst(cons 10 newEn)
(assoc 10(reverse dxfLst))(reverse dxfLst))))
); end condition #3
); end cond
(entmod newPl)
); end foreach
); end progn
); end if
); end progn
); end if
(princ)
); end of c:plen
Solved! Go to Solution.