Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need a LISP to cut a line back

7 REPLIES 7
Reply
Message 1 of 8
jsbernholt
1468 Views, 7 Replies

Need a LISP to cut a line back

I struggle with LISP's and would greatly appreciate if someone could find or write one.

 

What I need is a command to cut back a line. There are a lot of lines we need to add in paper space such as grid and hand rail lines. These lines get cut back 1/16" back from where they connect to. Right now I have to click on the line, grab the grip, move the mouse back and type in 1/16" and then enter, and then repeat a bunch more time on all the other lines that require a cut back. Would it be possible to have a command that once prompted would let me click on the desired line, then click on an end point, then click in the direction that I want the line cut back, and end up with a 1/16" gap?

 

Respectfully,

John S. Bernholt

7 REPLIES 7
Message 2 of 8
jsbernholt
in reply to: jsbernholt

I forgot to add, somtimes I need it to extend 1/16". Could the LSP mentioned above not just be able to cut the line back 1/16", but aslo be able to extend it 1/16" depending upon which side of the end point you click on?

 

 

Thanks.

Message 3 of 8
Patchy
in reply to: jsbernholt

You can use LENGTHEN command, DE for delta and type in (minus) -1/16" or 1/16" for extending.

Message 4 of 8
jsbernholt
in reply to: Patchy

I appreciate the respose, but I have to invoke the lengthen command and type DE everytime. I was looking for a LSP where I could just click on the line and then click the direct that needs to move by 1/16". I'm really looking for two clicks and not typing anything in. Thanks again for your time.

Message 5 of 8
Patchy
in reply to: jsbernholt

(defun c:LEN ()
(gc)
(setvar "cmdecho" 0)
(command "lengthen" "DE" "1/16")
)

 

 

(defun c:LEN- ()
(gc)
(setvar "cmdecho" 0)
(command "lengthen" "DE" "-1/16")
)

Message 6 of 8
Kent1Cooper
in reply to: jsbernholt


@jsbernholt wrote:

....

.... Would it be possible to have a command that once prompted would let me click on the desired line, then click on an end point, then click in the direction that I want the line cut back, and end up with a 1/16" gap?

....

....somtimes I need it to extend 1/16". Could the LSP mentioned above not just be able to cut the line back 1/16", but aslo be able to extend it 1/16" depending upon which side of the end point you click on?


If they're always only Line entities, and you don't have to deal with other-than-World Coordinate Systems or other such complications, try the code below, which lets you change Lines in either direction under the same command, and as many as you want with one invocation of it.

 

Select a Line, and it will Zoom in close enough to the nearer end that you can easily see the 1/16" increment, and you pick where you want that endpoint changed to, in either direction [or to the side if you wish, though I assume you wouldn't].  It turns on Snap to 1/16", aligned with the Line and with the snap origin at that endpoint, so the new endpoint location you pick will be a clean 1/16" from the old endpoint [or a multiple of 1/16" -- you can change it by more if you want, though I assume you wouldn't].  It pauses for half a second so you can see that the Change took place, and then Zooms back and asks you to pick another.  Escape to get out of it, and all the settings return to what they were.

 

Minimally tested, and without other possible enhancements it could have, such as allowing only Lines, or conversely, working with Polylines too [much more complicated], or asking again if you miss, etc., but see what you think.

 

(defun C:CES ; = Change End by Sixteenths
  (/ *error* snapu snapa snapb ls lin ne)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); end if
    (setvar 'snapunit snapu)
    (setvar 'snapang snapa)
    (setvar 'snapbase snapb)
    (princ)
  ); defun - *error*
  (setq
    snapu (getvar 'snapunit)
    snapa (getvar 'snapang)
    snapb (getvar 'snapbase)
  ); setq
  (setvar 'snapunit '(0.0625 0.0625))
  (while T
    (setq
      ls (entsel "\nSelect Line to change end of [Esc to exit]: "); = Line Selection
      lin (car ls)
      ne (osnap (cadr ls) "_end"); = Near End
    ); setq
    (setvar 'snapbase (list (car ne) (cadr ne)))
    (setvar
      'snapang
      (angle
        '(0 0 0)
        (vlax-curve-getFirstDeriv
          lin
          (vlax-curve-getParamAtPoint lin ne)
        ); FirstDeriv
      ); angle
    ); setvar
    (command
      "_zoom" "_c" ne 0.5
      "_change" lin "" pause
      "_delay" 500
      "_zoom" "_previous"
    ); change
  ); while
); defun

Kent Cooper, AIA
Message 7 of 8
Patchy
in reply to: Kent1Cooper

That's some fancy work you created Kent

Message 8 of 8
scot-65
in reply to: jsbernholt

Here's another method for your use (I'm in a generous mood today).

 

You can declare any value weather adding to the line or subtracting.

Just declare these in your favorite ACAD**.MNL/LSP file and have the attached file loaded.

 

(if (findfile "STR_TRIM.lsp") (load "STR_TRIM"))

 

(defun c:T16 () (STR_TRIM -0.0625)) ;trims 1/16 inch.

(defun c:S4 () (STR_TRIM 4.0)) ;stretch 4 inch.

(defun c:SB () (STR_TRIM 5.5)) ;stretch 5 1/2" for brick.

...populate with any other distances you see fit.

 

If you select something else besides a LINE, you will be asked to try again.

The nearest endpoint of where you selected will be the end that is edited.

The program lets you know if the trim value is greater than the line's length.

This program does not loop.

 

Scot-65

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost