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

breaks selected line

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
477 Views, 6 Replies

breaks selected line

Good day!

I'm looking for a routine that will select a line, then that line will be broken at points where it intersect other lines.
Or better, to draw a line which will break when intersect with other lines.

Though I've found a few codes that can be modified, I'm not familiar with LISP. Any help will be much appreciated. Thanks!
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Here's one that will allow you to select the line to break and the lines with which to break it. To change the "gap", change the line (setq gap 1.5) to whatever number you desire. [code] ;| Original posted to autodesk.customization newsgroup by SMMASON on 4/02/03....modified for specific task by Jeff Mishler on 8/04/03 |; (defun c:brkint (/ BRK-PT1 BRK-PT2 GAP GAP1A INT-LIN1 INT-LIN1A INT-LIN2A INT-PT1 INT-PT2 INT-PT3 INT-PT4 INT-PT5 NUMLIN OLD-AUNITS OLD-LUNITS OLD-OSNAP OLD_ERROR ONSEG PICKTYPE PT1 PT2) (SETVAR "CMDECHO" 0) (setq old-osnap (getvar "osmode")) (setq old-lunits (getvar "lunits")) (setq old-aunits (getvar "aunits")) (setvar "osmode" 0) (setvar "lunits" 2) (setvar "aunits" 0) (setq old_error *error*) (defun *error* (msg) (if (not (member msg '("console break" "Function cancelled" "quit / exit abort") ) ) (progn (setvar "osmode" old-osnap) (setvar "lunits" old-lunits) (setvar "aunits" old-aunits) (redraw (car int-lin1) 4) (SETVAR "CMDECHO" 1) ) ) ) ;;;(setq gap2 (if (= gap nil) 0.125 gap)) ;;;(setq gap (getreal (strcat "\nEnter Break Gap Distance " "<" (rtos gap2) ">" ": "))) ;;;(if (= gap nil) (setq gap gap2)) (setq gap 1.5) (setq gap1a (/ gap 2)) (setq int-lin1 (entsel "\nSelect the Line to use as the Cutting Line: ")) (redraw (car int-lin1) 3) (setq int-lin1a (entget (car int-lin1))) (setq int-pt1 (cdr (assoc 10 int-lin1a))) (setq int-pt2 (cdr (assoc 11 int-lin1a))) (initget 1 "F P") (setq picktype (getkword "\nUse Fence or Pick Lines to Break? : ")) (if (= picktype "F") (progn (setq pt1 (getpoint "\nLines to Break -> Pick First Fence Point: ")) (setq pt2 (getpoint pt1 "\nPick Second Fence Point: ")) (setq fence-cut (ssget "F" (list pt1 pt2) '((0 . "LINE")) )) (setq numlin 0) (while (<= numlin (- (sslength fence-cut) 1)) (setq int-lin2 (entget (ssname fence-cut numlin))) (setq int-pt3 (cdr (assoc 10 int-lin2))) (setq int-pt4 (cdr (assoc 11 int-lin2))) (setq int-pt5 (inters int-pt1 int-pt2 int-pt3 int-pt4 onseg)) (setq brk-pt1 (polar int-pt5 (angle int-pt5 int-pt3) gap1a)) (setq brk-pt2 (polar int-pt5 (angle int-pt5 int-pt4) gap1a)) (command "break" (ssname fence-cut numlin) brk-pt1 brk-pt2) (setq numlin (+ numlin 1)) );end while );end progn (progn (while ;(= int-lin2 nil) (setq int-lin2 (entsel "\nSelect Line to Break: ")) (setq int-lin2a (entget (car int-lin2))) (setq int-pt3 (cdr (assoc 10 int-lin2a))) (setq int-pt4 (cdr (assoc 11 int-lin2a))) (setq int-pt5 (inters int-pt1 int-pt2 int-pt3 int-pt4 onseg)) (setq brk-pt1 (polar int-pt5 (angle int-pt5 int-pt3) gap1a)) (setq brk-pt2 (polar int-pt5 (angle int-pt5 int-pt4) gap1a)) (command "break" int-lin2 "f" brk-pt1 brk-pt2) ;(setq int-lin2 nil) );end while );end progn );end if (setvar "osmode" old-osnap) (setvar "lunits" old-lunits) (setvar "aunits" old-aunits) (redraw (car int-lin1) 4) (setq *error* old_error) (SETVAR "CMDECHO" 1) (princ) ) [/code] -- Jeff check out www.cadvault.com "chadidjaja" wrote in message news:27985252.1092952804153.JavaMail.jive@jiveforum1.autodesk.com... > Good day! > > I'm looking for a routine that will select a line, then that line will be broken at points where it intersect other lines. > Or better, to draw a line which will break when intersect with other lines. > > Though I've found a few codes that can be modified, I'm not familiar with LISP. Any help will be much appreciated. Thanks!
Message 3 of 7
Anonymous
in reply to: Anonymous

Hi Jeff, thanks a lot!
With gap = 0.0, this is really close to what I need.

The routine allows me to select a cutting line, then the lines to be broken; while I'm needing one that allows me to select which line to be broken, then the selected line will be cut by all (no need to ask which) intersecting lines on the same layer.
Message 4 of 7
ebrown
in reply to: Anonymous

I am getting an error brkint.lsp successfully loaded.
Command: ; error: malformed list on input
Can you attach the lisp file
Message 5 of 7
Kent1Cooper
in reply to: ebrown


@Anonymous wrote:
I am getting an error brkint.lsp successfully loaded.
Command: ; error: malformed list on input
Can you attach the lisp file

Jeff may not still be watching after nine years.  The passage of time and changes in website format, etc., may be why it's not working for you, if any of that has affected what happens when you copy and paste the code.  But there are various routines out there to do the same kind of thing, such as here.

Kent Cooper, AIA
Message 6 of 7
Kent1Cooper
in reply to: ebrown


@Anonymous wrote:
I am getting an error brkint.lsp successfully loaded.
Command: ; error: malformed list on input
Can you attach the lisp file

I looked at that, and the problem may be simply the fact that all line-wrapping is gone, because there are some semicolons commenting out certain things, but the commenting-out applies to more than it should because there are no new lines.  I made some assumptions about how much was intended to be commented out in each case, and re-introduced line breaks, resulting in the attached, which works here in very limited testing.

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

Hi

I have one, but I made it only for polylines. Se in attach

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

Post to forums  

Autodesk Design & Make Report

”Boost