I am in search of a LISP routine to strech a selection a pre-set distance. I have many different objects i need to stretch at different places and directions but i often am stretching them the same distance. I would like to input the distance once and use the selection window and click in the direction to stretch similar to the native offset command. i would like the command to remember the last input value when i run it again, and allow continuous operation, (multiple cycles before exiting).
Tricky request, but try this... Maybe you'll get used to it... Also worth of trying is MSTRETCH command...
(defun c:stretchdist ( / cmd d ss p1 p2 v ) (defun *error* ( msg ) (if cmd (setvar 'cmdecho cmd)) (if msg (prompt msg)) (princ) ) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 1) (initget 7) (setq d (getdist "\nPick or specify distance for stretching : ")) (while (setq ss (ssget "_:L")) (setq p1 (getpoint "\nPick or specify first point (base point) : ")) (setq p2 (getpoint p1 "\nPick or specify second point : ")) (setq v (mapcar '* (mapcar '/ (mapcar '- p2 p1) (list (distance p1 p2) (distance p1 p2) (distance p1 p2))) (list d d d))) (command "_.STRETCH" ss "" v "") ) (terpri) (*error* nil) )
HTH, M.R.
mstretch doesnt account for multiple directions, and doesnt keep the measurement that was stretched from the previous run of the command. mstretch gives multiple selection windows but only one distance and direction.
Interestingly, marko_ribar's routine works in AutoCAD 2015, but at my other location back on ol' 2004, it doesn't, because Stretch won't accept a mere selection set of entity names, but needs the crossing/polygon selection approach within the command. But even in newer versions where it works with pre-selection, I would be inclined to do part of it differently:
....
(while
(setq ss (ssget "_:L"))
(setq ang (getangle "\nDirection to Stretch [numerical angle or via two points]: "))
(command "_.STRETCH" ss "" (polar '(0 0 0) ang d) "")
); while
....
That way, the User has the option to designate the direction to Stretch in by either picking two points on-screen or typing in an angle [in whatever the current angle format is, or sometimes in more than one format -- for instance, with degrees/minutes/seconds as my setting, I can type either degrees/minutes/seconds or decimal degrees].
Sorry, Kent, I am looking it 3D - proffesional bugger...
@marko_ribar wrote:
Sorry, Kent, I am looking it 3D - proffesional bugger...
Oh, I hadn't thought about that. If multiple directions includes Z as well as XY directions, then my suggestion won't work, because (getangle) won't deal with the Z component.