
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I'm the AutoCAD administrator of a drawing office, and we work with an application to draw P&ID's. This application is developed by a third party and contains pieces of code from the ealy 90's (when i was still a kid).
There is a problem, and although I am the CAD Administrator, i can't write lisp.
I can read it, edit it, and paste it, but not write it. A true script kiddie.
Problem
One of the buttons of the application breaks two crossing polylines, using a lisp routine.
However, since 2k11 the lisp routine doesn't work anymore, we need to convert the polylines (2D polylines) into LWpolylines first.
I've tried a couple of things, including changing the variable LWPOLYLINE to POLYLINE, AcadPolyLine, AcDbPolyline, AcDb2dPolyline etc.
What does work is breaking 2 normal lines.
But, when i draw two crossing polylines, it doesn't do anything
Here's the code.
(prompt "\n breakver.lsp") ; (defun BreakVer (brkdst / brkdst bdir osn insp x y ss len index found ent e1 ang flg p1 pd1 e1 p2 d0 d1 d2) (initerr) (if (or (= brkdst Nil)(= brkdst 0))(setq brkdst 2.0)) (setq bdir "V") (setq osn(getvar "osmode")) (setvar "osmode" 32) (initget (+ 1 2)) (setq insp(getpoint "\nCrossing point: \n")) (setq x(car insp)) (setq y(cadr insp)) (setq ss(ssget "c" (list (- x 1)(- y 1))(list (+ x 1)(+ y 1)))) (if (/= ss nil) (setq len(sslength ss)) ) (if(> len 1) (progn (setq index 0) (setq found 0) (while (and (< index len)(= found 0)) (setq ent(ssname ss index)) (setq index(1+ index)) (setq e1(entget ent)) (if(= (cdr(assoc 0 e1)) "LINE") (progn (setq ang(rng(angle(cdr(assoc 10 e1))(cdr(assoc 11 e1))))) (setq ang (if (> ang 315)(- ang 360) ang)) (if (= bdir "V") (progn ; vert. lijn onderbreken (if(or(and(< ang 135)(> ang 45))(and(> ang 225.0)(< ang 315.0))) (progn (setvar "osmode" 0) (command "break" ent (list x (- y brkdst))(list x (+ y brkdst))) (setq found 1) )))))) ;endprogn (if(= (cdr(assoc 0 e1)) "LWPOLYLINE") (progn (setq flg 1) (while (and (= flg 1) (assoc 10 e1)) (setq p1 (cdr (setq pd1(assoc 10 e1)))) (setq e1 (cdr (member pd1 e1))) (setq p2 (cdr (assoc 10 e1))) (setq d0 (distance p1 p2)) (setq d1 (distance p1 insp)) (setq d2 (distance p2 insp)) (if (< (Abs(-(+ D1 D2) D0)) 0.001) (progn (setq flg 0) (setq ang(rng(angle p1 p2))) (setq ang (if (> ang 315)(- ang 360) ang)) (if (= bdir "V") (progn ; vert. lijn onderbreken (if(or(and(< ang 135)(> ang 45))(and(> ang 225.0)(< ang 315.0))) (progn (setvar "osmode" 0) (command "break" ent (list x (- y brkdst))(list x (+ y brkdst))) (setq found 1) )))))))))))) ;endprogn (setvar "osmode" osn) (reset nil) ) (defun rng(ho) (* ho(/ 180.0 pi)) ) (prompt "...............Loaded.") (princ)
The weird thing is that when we insert a valve into a polyline (also via a lisp routine) this does break the polyline, without converting.
Part of that code:
(setq pt1 (polar pt (+ ang1 hk1) dist1)) (setq pt2 (polar pt (+ ang2 hk1) dist2)) (setq s (ssget "c" pt1 pt2)) (if s (progn (setq l 0 n(sslength s)) (while (< l n) (setq e(ssname s l)) (if (or (= "LINE" (cdr(assoc 0(entget e))))(= "POLYLINE" (cdr(assoc 0(entget e))))) (command "break" e pt1 pt2) ) (setq l(1+ l)) ) )
Could anyone help me or point me in the right direction? I'm a bit clueless.
Thanks in advance!
Regards,
Chris
Solved! Go to Solution.