LISP to break multiple lines (
Currently using the below LISP to break lines. The selection of lines is picking 1 line at a time. As some polylines are overlapped, i may need to repeat the command 2 or 3 times.If someone could advise on how to include a code to select the lines through a cross window selection that would be great time saver
(defun c:BB ( / oldos ent1 p1) (setq oldos (getvar "osmode")) (while (setq ent1 (entsel "\nSelect object to break... ")) (initget 1) (setq p1 (getpoint "\nPoint at which to break... ")) (setvar "osmode" 0) (command "_.BREAK" ent1 "_f" p1 "@" "") (setvar "osmode" oldos)) (princ "\nBreak at Done") (princ))To clarify further I also tried Charles Alan Butler LISP, but there were some issues:-
1)I can select line to be break but my breaking object is an xref, therefore it cannot be selected.
2) i bind the xref into the drawing so now can be selected but the lines to break & breaking object criss cross each other & break point is only at selected points of the lines.
3) Since it is only at selected points, i also try to instead draw a line connecting each desired break point. So then this line can be now a breaking object.
But now it take me twice as long to break this lines since i have to draw additional lines for very break point (i time myself)
So would appreciate if someone can help me to amend the LISP to allow cross window selection.
Thanks did you try
command: ncopy before runing lisp?
If you mean to run ncopy & select the desired lines from the xref as breaking objects before running the Charles Alan Butler LISP command, it does not work.
That would not help as the breaking object criss cross with the lines that need to break.
And to clarify further, if you mean to use the posted break LISP after ncopy, that is unnecessary steps since I can select "point" to break on the xref object.
So The main issue is the first posted BREAK lisp cannot select multiple lines that I want to break.
And although Charles Alan Butler LISP can select multiple lines that I want to break, it does not work on "points" as a break but instead on whole lines as a break Maybe, untested...
(defun c:BB ( / *error* el ss p i ent ) (vl-load-com) (defun *error* ( msg ) (vla-endundomark (vla-get-activedocument (vlax-get-acad-object))) (if msg (prompt msg)) (princ) ) (vla-startundomark (vla-get-activedocument (vlax-get-acad-object))) (setq el (entlast)) (if (null el) (progn (alert "DWG has no entities... Add some curve entities and restart routine...") (exit) ) ) (prompt "\nSelect curve entities you want to apply break at point to...") (setq ss (ssget "_:L")) (while (not ss) (if (and ss (not (vl-every '(lambda ( x ) (eq x t)) (mapcar '(lambda ( x ) (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartparam (list x))))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))))) (progn (prompt "\nSome of selected entities doesn't belong to curves... Try selecting exlusively curve entities again...") (setq ss (ssget "_:L")) ) (if (not ss) (progn (prompt "\nEmpty sel.set... Try selecting curve entities again...") (setq ss (ssget "_:L")) ) ) ) ) (setq p t) (while p (setq p (getpoint "\nPick or specify point at which you want to break multiple curve entities - ENTER to finish : ")) (if p (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i)))) (if (vlax-curve-getparamatpoint ent p) (command "_.BREAK" ent "_non" p "_non" p)) (if (not (eq el (entlast))) (ssadd (entlast) ss)) ) ) ) (*error* nil))M.R. Thanks marko.
Will test it immediately when I reach office. Hi marko.
Tested & does not seem to work.
1)when i select 2 lines, both seems highlighted.
2)But when i click the break point (Base on only 1 break point) it gave me an error
3) So i continue clicking the same break point (it seem to ask for 2 point regardless of how many lines I selected)
4) Command ends. Only 1 line is broken.
Code updated, retest it...
M.R. Just tested it marko.
No error but lines did not break.
Have you turned OSNAP on... You should pick "int" between curves or "nea" on just single curve... I had no problems with A2014...
Regards, try to debug - I think that there may be differences in line (command "_.BREAK"...), but it's just a hunch... Hi marko. Yes the osnap was turn on. i also did base on INT for the break point but still no avail. I am not sure what is wrong.
edit
I tried on autocad architecture 2014 & it works. But why my office's AutoCAD 2014 do not?
页:
[1]
2