LISP to shorten selected side of line by 3"

LISP to shorten selected side of line by 3"

mbracciahubbard
Contributor Contributor
430 Views
3 Replies
Message 1 of 4

LISP to shorten selected side of line by 3"

mbracciahubbard
Contributor
Contributor

I have no idea how to write my own lisp's, so if someone wants to help me understand that i'd love it.

 

aside from that, if anyone knows a lisp that will help me select a desired existing line and shorten the desired end of it by 3" that would be great. I am currently using the stretch command but i have to do it hundreds of times a day so i feel like if i'm saving a few seconds it will end up being beneficial long term.

 

in summary, i want to enter a command, click the line, click the side i want to shorten, and have it shorten automatically by 3" on that specific side

0 Likes
Accepted solutions (1)
431 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

Use LENGTHEN with the DElta option, and give it a negative value to shorten things.  You can go around and pick as many things as you want to shorten in one running of the command.  And you don't need to pick the Line [or whatever] and also pick the end you want shortened -- one pick nearer to that end will do.  And it remembers and offers as defaults that you chose the DElta option and the distance you gave it, for subsequent use.  That could be built into a custom command for a specific shortening distance easily enough, or a command macro for a Tool Palette button, if really necessary.

 

EDIT:

As a command:

(defun C:S3 (); = Shorten by 3 drawing units
  (command "_.lengthen" "_delta" -3)
)

or as a command macro:

^C^C_.lengthen _delta -3

 

Kent Cooper, AIA
Message 3 of 4

TomBeauford
Advisor
Advisor

You could use the LENGTHEN command with the "DElta" option of "-3" and pick the end you want modified. Picking each line closer to the endpoint you want modified afterwards it should default to the same values so you'd just tap the Spacebar or Enter two times after picking each line. 

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
Message 4 of 4

calderg1000
Mentor
Mentor

Regrads @mbracciahubbard 

Try this code...

;;;___
(defun c:Tr_line (/ s p vu px)
  (while
    (setq s  (entsel "\nSelect near end of the line to shorten,3...:")
	  )
    (setq
	  p  (vlax-curve-getclosestpointto (car s) (cadr s))
	  vu (mapcar
	       '(lambda (j) (* (/ 1. (vlax-curve-getendparam (car s))) j))
	       (mapcar '-
		       (cdr (assoc 11 (entget (car s))))
		       (cdr (assoc 10 (entget (car s))))
	       )
	     )
    )
     (if (> (vlax-curve-getparamatpoint (car s) p)
	    (/ (vlax-curve-getendparam (car s)) 2.)
	 )
       (progn
	 (setq px (mapcar '-
			  (vlax-curve-getendpoint (car s))
			  (mapcar '(lambda (k) (* 3. k)) vu);Here edit the value to shorten
		  )
	 )
	 (entmod (subst	(cons 11 px)
			(assoc 11 (entget (car s)))
			(entget (car s))
		 )
	 )
       )
       (progn
	 (setq px (mapcar '+
			  (vlax-curve-getstartpoint (car s))
			  (mapcar '(lambda (k) (* 3. k)) vu);Here edit the value to shorten
		  )
	 )
	 (entmod (subst	(cons 10 px)
			(assoc 10 (entget (car s)))
			(entget (car s))
		 )
	 )
       )
     )
  )
  (princ)
)

... 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes