dcpanchal_2005 Posted July 25, 2009 Posted July 25, 2009 hi, can any one have lsp routine for break lines intersect with each other.. Thanks Quote
lpseifert Posted July 25, 2009 Posted July 25, 2009 Have a l ook here,,, requires registration but it's free http://www.theswamp.org/index.php?topic=10370.0 Quote
Lee Mac Posted July 25, 2009 Posted July 25, 2009 As an alternative, just something I knocked up quickly: ;;; Break All, by Lee McDonnell. 25/07/2009 (defun c:brkAll (/ *error* doc spc ss Objlst Obj iLst Altlst lst) (vl-load-com) (defun *error* (msg) (if doc (vla-EndUndoMark doc)) (if ov (mapcar 'setvar vl ov)) (if (not (wcmatch (strcase msg) "*BREAK,*EXIT*,*CANCEL*")) (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl)) (vla-StartUndoMark doc) (or *brk$dis* (setq *brk$dis* 5.)) (if (setq ss (ssget '((0 . "*LINE,ARC")))) (progn (or (not (setq tmp (getdist (strcat "\nSpecify Break Distance <" (rtos *brk$dis* 2 2) "> : ")))) (setq *brk$dis* tmp)) (setq Objlst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) (while (setq Obj (car Objlst)) (foreach iObj (setq Objlst (cdr Objlst)) (setq iLst (cons (cons Obj (vlax-list->3D-point (vlax-invoke Obj 'IntersectWith iObj acExtendNone))) iLst)))) (mapcar 'setvar vl '(0 0)) (foreach Int (vl-remove-if-not (function (lambda (x) (vl-consp (cdr x)))) iLst) (setq Obj (car Int)) (foreach Pt (cdr Int) (and Altlst (setq lst Altlst)) (if (not (setq bDis (vlax-curve-getDistatPoint Obj Pt))) (while (and (not bDis) lst) (setq bDis (vlax-curve-getDistatPoint (setq Obj (car lst)) Pt) lst (cdr lst)))) (if bDis (progn (or (setq bPt1 (vlax-curve-getPointatDist Obj (+ bDis (/ *brk$dis* 2.)))) (setq bPt1 (vlax-curve-getEndPoint Obj))) (or (setq bPt2 (vlax-curve-getPointatDist Obj (- bDis (/ *brk$dis* 2.)))) (setq bPt2 (vlax-curve-getStartPoint Obj))) (command "_.Break" (list (vlax-vla-object->ename Obj) pt) "_F" bPt1 bPt2) (setq AltLst (cons (vlax-ename->vla-object (entlast)) AltLst))))))) (princ "\n** Nothing Selected **")) (vla-EndUndoMark doc) (mapcar 'setvar vl ov) (princ)) (defun vlax-list->3D-point (lst) (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (vlax-list->3D-point (cdddr lst))))) Quote
rayg11757 Posted December 13, 2009 Posted December 13, 2009 Very cool routine!!! Questions: 1. Is it possible to specify that either vertical or horizontal lines are broken based on user input? 2. Is it possible to break only lines that completely cross each other while ignoring lines that just touch without crossing, such as lines drawn using the perpendicular osnap? Thank you. Ray Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 Very cool routine!!! Questions: 1. Is it possible to specify that either vertical or horizontal lines are broken based on user input? 2. Is it possible to break only lines that completely cross each other while ignoring lines that just touch without crossing, such as lines drawn using the perpendicular osnap? Thank you. Ray Thanks Ray, I should think both are possible, if I had a bit more time, but I shall see what I can do. In the mean time, check this out - someone who spent a bit more time on the same kind of routine... http://www.theswamp.org/index.php?topic=10370.0 Quote
kyosmith Posted April 16, 2010 Posted April 16, 2010 Very cool routine!!! Questions: 1. Is it possible to specify that either vertical or horizontal lines are broken based on user input? 2. Is it possible to break only lines that completely cross each other while ignoring lines that just touch without crossing, such as lines drawn using the perpendicular osnap? Thank you. Ray thats exactly what i need! some one can help ?please! Quote
kyosmith Posted April 16, 2010 Posted April 16, 2010 yeah but the macro on the link does not break only the vertical lines that crosses a horizontal one and it also breaks the perpendicular lines to Quote
kyosmith Posted April 16, 2010 Posted April 16, 2010 the thing i need : select a bunch of lines (many lines) and then break only the vertical lines that crosses a horizontal one Quote
alanjt Posted April 16, 2010 Posted April 16, 2010 the thing i need : select a bunch of lines (many lines) and then break only the vertical lines that crosses a horizontal one c:BreakwObjects - Break many objects with a single object Quote
kyosmith Posted April 16, 2010 Posted April 16, 2010 c:BreakwObjects - Break many objects with a single object ive already saw this man... ok thats not exactly what i need... i will tell you all : i have a lisp that create lines with an arrow at its endpoint: here is the code (defun C:FLUXO (/ PT ENT PT1 PT2 ANG PTA PTB TP ARANG ARROW Slist OK FIM ) (setq Pt1 (getpoint "\nSpecify first point: ")) (initget 1) (setq Pt2 (getpoint Pt1 "\nSpecify second point: ")) (command "._line" Pt1 Pt2 "") (setq old_lay (getvar "clayer")) (command "layer" "set" "0" "") (setq setinha (entlast) ARANG (angle PT1 PT2) FIM (polar PT2 ARANG -3) ; fim da seta ARROW (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 8 (getvar "clayer")) (cons 100 "AcDbPolyline") (cons 90 3) (cons 70 128) (cons 38 0) (cons 39 0) (cons 10 PT2) (cons 40 0) (cons 41 1.5) (cons 42 0) (cons 10 FIM) (cons 40 0) (cons 41 0) (cons 42 0) (cons 40 0) (cons 41 0) (cons 42 0) ) ) (entmake ARROW) (princ) (command "layer" "set" old_lay "") (setq SList (ssadd (entlast)) ; begin a selection set of center line OK T ; set flag ) ;_ closes setq (while OK ; while still drawing lines (setq Pt1 (getvar "LastPoint")) ; used for next line command (setq Pt2 (getpoint Pt1 "\nSpecify next point: ")) ; get next point (if Pt2 ; if a point was chosen (progn ; then... (command "._line" Pt1 Pt2 "") ; draw next line (setq old_lay (getvar "clayer")) (command "layer" "set" "0" "") (setq setinha (entlast) ARANG (angle PT1 PT2) FIM (polar PT2 ARANG -3) ; fim da seta ARROW (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 8 (getvar "clayer")) (cons 100 "AcDbPolyline") (cons 90 3) (cons 70 128) (cons 38 0) (cons 39 0) (cons 10 PT2) (cons 40 0) (cons 41 1.5) (cons 42 0) (cons 10 FIM) (cons 40 0) (cons 41 0) (cons 42 0) (cons 40 0) (cons 41 0) (cons 42 0) ) ) (entmake ARROW) (princ) (command "layer" "set" old_lay "") (setq SList (ssadd (entlast) SList)) ) (progn (setq OK NIL) ) ) ) ) my lisp coding sucks so i modified anothers person code to do that. i need to draw the lines with the arrows and then break the vertical ones that intercept the horizontal lines like this : Quote
fixo Posted April 18, 2010 Posted April 18, 2010 the thing i need : select a bunch of lines (many lines) and then break only the vertical lines that crosses a horizontal one Try these lisps from my old code library (don't remember how it works, sorry) BreakVert.lsp ;;break vertical lines only (defun C:BreakVert(/ copya ent_list hlines hobjs points tmp vlines vobjs) ;;get all lines entity lists (setq ent_list (mapcar 'entget (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget (list '(0 . "LINE")))))))) ;;vertical lines (setq vlines (mapcar 'cdr (mapcar 'car (vl-remove-if-not (function (lambda(x) (equal (car (cdr (assoc 10 x))) (car (cdr (assoc 11 x))) 0.001))) ent_list)))) ;;horizontal lines (setq hlines (mapcar 'cdr (mapcar 'car (vl-remove-if-not (function (lambda(x) (equal (cadr (cdr (assoc 10 x))) (cadr (cdr (assoc 11 x))) 0.001))) ent_list)))) ;;convert to vla-objects (setq vobjs (mapcar 'vlax-ename->vla-object vlines)) (setq hobjs (mapcar 'vlax-ename->vla-object hlines)) (foreach a vobjs (setq tmp (list (vlax-curve-getstartpoint a) (vlax-curve-getendpoint a)) ) (foreach b hobjs (setq points (vlax-invoke a 'Intersectwith b 0)) (if (= 3 (length points));two perpendicular lines has just one intersection (setq tmp (cons points tmp )))) (if (> (length tmp) 2) (progn (setq tmp (vl-sort tmp (function (lambda(x y) (< (vlax-curve-getparamatpoint a x) (vlax-curve-getparamatpoint a y)))))) (vla-put-startpoint a (vlax-3d-point (car tmp))) (vla-put-endpoint a (vlax-3d-point (cadr tmp))) (setq tmp (cdr tmp)) (repeat (1- (length tmp)) (setq copya (vla-copy a)) (vla-put-startpoint copya (vlax-3d-point (car tmp))) (vla-put-endpoint copya (vlax-3d-point (cadr tmp))) (setq tmp (cdr tmp))))) ) (princ) ) BreakHorz.lsp ;;break horizontal lines only (defun C:BreakHorz(/ copya ent_list hlines hobjs points tmp vlines vobjs) ;;get all lines entity lists (setq ent_list (mapcar 'entget (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget (list '(0 . "LINE")))))))) ;;vertical lines (setq vlines (mapcar 'cdr (mapcar 'car (vl-remove-if-not (function (lambda(x) (equal (car (cdr (assoc 10 x))) (car (cdr (assoc 11 x))) 0.001))) ent_list)))) ;;horizontal lines (setq hlines (mapcar 'cdr (mapcar 'car (vl-remove-if-not (function (lambda(x) (equal (cadr (cdr (assoc 10 x))) (cadr (cdr (assoc 11 x))) 0.001))) ent_list)))) ;;convert to vla-objects (setq vobjs (mapcar 'vlax-ename->vla-object vlines)) (setq hobjs (mapcar 'vlax-ename->vla-object hlines)) (foreach a hobjs (setq tmp (list (vlax-curve-getstartpoint a) (vlax-curve-getendpoint a)) ) (foreach b vobjs (setq points (vlax-invoke a 'Intersectwith b 0)) (if (= 3 (length points));two perpendicular lines has just one intersection (setq tmp (cons points tmp )))) (if (> (length tmp) 2) (progn (setq tmp (vl-sort tmp (function (lambda(x y) (< (vlax-curve-getparamatpoint a x) (vlax-curve-getparamatpoint a y)))))) (vla-put-startpoint a (vlax-3d-point (car tmp))) (vla-put-endpoint a (vlax-3d-point (cadr tmp))) (setq tmp (cdr tmp)) (repeat (1- (length tmp)) (setq copya (vla-copy a)) (vla-put-startpoint copya (vlax-3d-point (car tmp))) (vla-put-endpoint copya (vlax-3d-point (cadr tmp))) (setq tmp (cdr tmp))))) ) (princ) ) ~'J'~ Quote
kyosmith Posted April 19, 2010 Posted April 19, 2010 fixo how to set an offset distance in that vertical code? Quote
kyosmith Posted April 19, 2010 Posted April 19, 2010 CAB: i need the perpendicular snaps intact. the "BreakWith" breaks it to Fixo: i added this line to the code (setq pt1 (polar (car tmp) 1.57079633 -2)) (setq pt2 (polar (cadr tmp) 4.71238898 -2)) (vla-put-startpoint copya (vlax-3d-point pt1)) (vla-put-endpoint copya (vlax-3d-point pt2)) but it also breaks the perpendicular snaps Quote
Lee Mac Posted April 19, 2010 Posted April 19, 2010 The ObjectSnap issue is something else entirely, that functionality relies on just the entity data - bear in mind that AutoCAD doesn't know that the line is only broken for clarity - AutoCAD will treat them as two separate lines. You are asking too much. If you wanted to keep all the snaps in tact, you would need to use a wipeout or similar. Quote
alanjt Posted April 19, 2010 Posted April 19, 2010 can anyone help me please!! LoL I would say several are. Quote
kyosmith Posted April 19, 2010 Posted April 19, 2010 LoLI would say several are. man im just asking for help! i really need this and dont know how to do Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.