Autotrim lines

rseyda

Usenet Archive
Joined
Aug 13, 2003
Messages
9
Reaction score
0
Is there a simple way to have lines that you draw get the ends trimmed back a certain distance, like 6"? I have been working with the code but I keep running into dead ends. The problem I have is if the line is at a certain angle other than zero I get undesirable results. Any help?

Thanks,
 
Kinda tough to help without seeing what you are trying, but I'll start with:
get the angle of the line immediately after drawing it (getvar "lastang"), set the new endpoint (polar endpt ang dist). BTW, using vla-* functions will make this easier.....

Jeff

rseyda said:
Is there a simple way to have lines that you draw get the ends trimmed
back a certain distance, like 6"? I have been working with the code but I keep running into dead ends. The problem I have is if the line is at a certain angle other than zero I get undesirable results. Any help?
 
See the lisp attached under the "overshoots" thread. It will shorten or extend selected lines by a given amount on both ends.

rseyda said:
Is there a simple way to have lines that you draw get the ends trimmed
back a certain distance, like 6"? I have been working with the code but I keep running into dead ends. The problem I have is if the line is at a certain angle other than zero I get undesirable results. Any help?
 
I tried to check it but it said that the file was not uploaded because it was too big. It sounds like what I need though.
 
(defun chglen (ename len / ent pt1 pt2 pt3)
(setq
ent (entget ename)
pt1 (cdr (assoc 10 ent))
pt2 (cdr (assoc 11 ent))
pt3 (polar pt2 (angle pt1 pt2) len)
)
(entmod (subst (cons 11 pt3) (assoc 11 ent) ent))
)

(chglen (entlast) -6) will shorten the last line
(chglen (entlast) 6) will lengthen it

rseyda said:
Is there a simple way to have lines that you draw get the ends trimmed
back a certain distance, like 6"? I have been working with the code but I keep running into dead ends. The problem I have is if the line is at a certain angle other than zero I get undesirable results. Any help?
 
Something simple like this will work:

(defun c:sline (/ sp ep ed)
(if (not tv)
(progn
(initget 7)
(setq tv (getdist "\nTrim Distance: "))))
(initget 1)
(setq sp (getpoint "\nStart Point: "))
(initget 1)
(setq ep (getpoint sp "\nEnd Point: "))
(command "_.LINE" sp ep "")
(setq ed (entget (entlast)))
(entmod (subst (cons 10 (polar (cdr (assoc 10 ed))
(angle (cdr (assoc 10 ed))
(cdr (assoc 11 ed)))
tv))
(assoc 10 ed) ed))
(setq ed (entget (entlast)))
(entmod (subst (cons 11 (polar (cdr (assoc 11 ed))
(angle (cdr (assoc 11 ed))
(cdr (assoc 10 ed)))
tv))
(assoc 11 ed) ed))
(prin1))

-David
 
First you don't have to see the actual line until the end, and I'm assuming you're possibly going to insert a block or something at the beginning and end point.

With that said you could do the following:

(defun c:yourline (/ p1 p2 a1 a2 b1 b2)
(setq p1 (getpoint "\nPick Start: "))
(if p1
(progn
(setq p2 (getpoint p1 "\nPick End: "))
(if p2
(progn
(setq a1 (angle p1 p2)
a2 (angle p2 p1)
b1 (polar p1 a1 6)
b2 (polar p2 a2 6)
)
(entmake (list (cons 0 "LINE")(cons 10 b1)(cons 11 b2))) ) ) ) ) (princ)
)
rseyda said:
Is there a simple way to have lines that you draw get the ends trimmed
back a certain distance, like 6"? I have been working with the code but I keep running into dead ends. The problem I have is if the line is at a certain angle other than zero I get undesirable results. Any help?
 
just use the LENGTHEN command

(COMMAND "._LENGTHEN" "DELTA" -6)

rseyda said:
Is there a simple way to have lines that you draw get the ends trimmed
back a certain distance, like 6"? I have been working with the code but I keep running into dead ends. The problem I have is if the line is at a certain angle other than zero I get undesirable results. Any help?
 
Sorry, try again, it's only 1.4 kb and I can open it.

rseyda said:
I tried to check it but it said that the file was not uploaded because it
was too big. It sounds like what I need though.
 
Tom,
They are undoubtedly tryin to acces it from the web interface which is still not functioning as advertised. The big thing is NO attachments are seen as available in most groups when using the web interface.

Jeff
 
Sorry, I'd put it in customer files except I can't seem to get that NG synchronized, can't do anything with it.
 
Here it is.

;EXTLINES.LSP
;Extend selected lines.
;Written by Tom Smith

;Change length of line in <edata> by <amount> on both ends:
(defun chglen (edata amount / p1 p2 a1 a2 d1 d2 short)
(setq
p1 (trans (cdr (assoc 10 edata)) 0 1)
p2 (trans (cdr (assoc 11 edata)) 0 1)
a1 (angle p2 p1)
a2 (angle p1 p2))
(if (minusp amount)
(if (< (distance p1 p2) (* 2 (abs amount)))
(progn
(princ "\nLine is too short.")
(setq short t))))
(if (null short)
(entmod
(setq edata
(subst
(cons 10 (trans (polar p1 a1 amount) 1 0))
(assoc 10 edata)
(subst
(cons 11 (trans (polar p2 a2 amount) 1 0))
(assoc 11 edata)
edata))))))

;Change length of multiple lines:
(defun chgmlin (prmpt amount / oce i ss ent)
(setq oce (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "undo" "g")
(princ prmpt)
(setq
i 0
ss(ssget '((0 . "LINE"))))
(if ss
(repeat (sslength ss)
(setq
ent (chglen (entget (ssname ss i)) amount)
i (1+ i))))
(command "undo" "e")
(setvar "cmdecho" oce)
(princ))

(defun c:extlines (/ def)
(princ "\nShorten or Extend lines...")
(setq def (getvar "userr5"))
(chgmlin
"\nSelect lines to change: "
(setvar
"userr5"
(cond
((getdist (strcat "\nAmount to change lines <" (rtos def) ">: ")))
(def)))))

(princ)
 
Back
Top