Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Allen Johnson
Message 11 of 21 (113 Views)

Re: LISP for intersection clean up

07-14-2004 09:37 AM in reply to: zorroxxxx
I was looking at your code and fixed (I think!) the arc problem: (defun C:CI () (c:CleanIntersections)) (defun c:CleanIntersections ( / *Error* doc osm pkbx pt tempobj coord ptlist p1 p2 p3 p4 zmpt1 zmpt2 ) (defun *Error* (Msg) (cond ((or (not Msg) (member Msg '("console break" "Function cancelled" "quit / exit abort")))) ((princ (strcat "\nError: " Msg))) ) (setvar "osmode" osm) (setvar "cmdecho" 1) (princ) ) ;end (defun MidPoint (p1 b p2 / p b) (setq p (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5 0.5))) ; midpoint of projection (setq d (/ (* b (distance p1 p2)) 2)) ; bulge distance (setq p (polar p (+ (angle p1 p2) (dtr -90)) d)) ; actual midpoint considering bulge factor (print p) ) ;end (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq osm (getvar "osmode")) (setvar "osmode" 0) (setvar "cmdecho" 0) (while (setq pt (getpoint "\nPick point inside intersection: ")) (vla-StartUndoMark doc) (command "-boundary" pt "") (setq ent (entget (entlast))) ;(setq tempobj (vlax-ename->vla-object (entlast))) ;(setq coord (print (vlax-get tempobj 'Coordinates))) (setq ptlist (massoc 10 (entget (entlast)))) (setq blglst (massoc 42 (entget (entlast)))) ;(repeat 4 ; (setq ptlist (cons (list (car coord) (cadr coord)) ptlist)) ; (setq coord (cddr coord)) :smileywink: ;(vla-delete tempobj) (entdel (entlast)) (setq ptlist (mapcar '(lambda (x) (trans x 0 1)) ptlist)) (setq p1 (MidPoint (car ptlist) (car blglst) (cadr ptlist))) (setq p2 (MidPoint (cadr ptlist) (cadr blglst) (caddr ptlist))) (setq p3 (MidPoint (caddr ptlist) (caddr blglst) (last ptlist))) (setq p4 (MidPoint (car ptlist) (car blglst) (last ptlist))) (setq zmpt1 (polar pt 0.0 (* (distance p1 p3) 5))) (setq zmpt2 (polar pt pi (* (distance p1 p3) 5))) (command "zoom" "w" zmpt1 zmpt2) (command "_break" p1 "F" (car ptlist) (cadr ptlist) "_break" p2 "F" (cadr ptlist) (caddr ptlist) "_break" p3 "F" (caddr ptlist) (last ptlist) "_break" p4 "F" (car ptlist) (last ptlist) ) (command "zoom" "p") (vla-EndUndoMark doc) (setq ptlist nil) ) ;while (*Error* nil) (princ) ) ;end (defun massoc(key inlist / outlist) (foreach element inlist (if (= (car element) key) (setq outlist (cons (cdr element) outlist)) ) ) (reverse outlist) )
*Allen Johnson
Message 12 of 21 (113 Views)

Re: LISP for intersection clean up

07-14-2004 09:39 AM in reply to: zorroxxxx
Forgot that the (dtr) function isn't included: (defun DTR (a) ;Degrees to radians conversion (* pi (/ a 180.0))) (defun RTD (a) ;Radians to degrees conversion (* 180.0 (/ a pi)))
*GaryDF
Message 13 of 21 (113 Views)

Re: LISP for intersection clean up

07-14-2004 11:50 AM in reply to: zorroxxxx
Good this got ride of the AutoCAD error...which locked up the drawing sometimes. On another note, how would you mode the code to do a tee intersction and a corner intersection? Gary "Allen Johnson" wrote in message news:40f561ea$1_2@newsprd01... > Forgot that the (dtr) function isn't included: > > (defun DTR (a) ;Degrees to radians conversion > (* pi (/ a 180.0))) > > (defun RTD (a) ;Radians to degrees conversion > (* 180.0 (/ a pi))) > >
*Joe Burke
Message 14 of 21 (113 Views)

Re: LISP for intersection clean up

07-15-2004 04:58 AM in reply to: zorroxxxx
Allen, I haven't tried your modified code. It looks like a good idea to deal with arcs. BTW, when I wrote the one-click thing I thought it wouldn't work with arcs. The fact it did in most cases given Gary's examples was an unexpected bonus. Thanks Joe Burke
*Doug Broad
Message 15 of 21 (113 Views)

Re: LISP for intersection clean up

07-15-2004 05:25 AM in reply to: zorroxxxx
Nice Joe, It did however crash autocad under certain situations, specifically, when the intersection picked was not entirely closed (boundary failure leads to activeX failure when entlast is not a polyline). Crash occurs sometimes after undoing the operation. Suggest adding a check to see if the last entity is a new polyline entity. Regards, Doug "Joe Burke" wrote in message news:40f3cd9a$1_1@newsprd01... > Gary, > > Just fooling around with how it might be done without selecting objects. One click, > pick point. Seems to work fairly well with arcs and lines given your examples. It's > certainly not bulletproof and needs more error checking. Zoom in/out is annoying, but > the break commands are more reliable this way. > > Joe Burke > > (defun c:CleanIntersections ( / *Error* doc osm pkbx pt tempobj coord > ptlst p1 p2 p3 p4 zmpt1 zmpt2 ) > > (defun *Error* (Msg) > (cond > ((or (not Msg) > (member Msg '("console break" > "Function cancelled" > "quit / exit abort")))) > ((princ (strcat "\nError: " Msg))) > ) > (setvar "osmode" osm) > (setvar "cmdecho" 1) > (princ) > ) ;end > > (defun MidPoint (p1 p2) > (mapcar '* (mapcar '+ p1 p2) '(0.5 0.5 0.5)) > ) ;end > > (setq doc (vla-get-activedocument (vlax-get-acad-object))) > (setq osm (getvar "osmode")) > (setvar "osmode" 0) > (setvar "cmdecho" 0) > > (while > (setq pt (getpoint "\nPick point inside intersection: ")) > (vla-StartUndoMark doc) > (command "-boundary" pt "") > (setq tempobj (vlax-ename->vla-object (entlast))) > (setq coord (vlax-get tempobj 'Coordinates)) > (vla-delete tempobj) > (repeat 4 > (setq ptlst (cons (list (car coord) (cadr coord)) ptlst)) > (setq coord (cddr coord)) > ) > (setq ptlst (mapcar '(lambda (x) (trans x 0 1)) ptlst)) > (setq p1 (MidPoint (car ptlst) (cadr ptlst))) > (setq p2 (MidPoint (cadr ptlst) (caddr ptlst))) > (setq p3 (MidPoint (caddr ptlst) (last ptlst))) > (setq p4 (MidPoint (car ptlst) (last ptlst))) > (setq zmpt1 (polar pt 0.0 (* (distance p1 p3) 5))) > (setq zmpt2 (polar pt pi (* (distance p1 p3) 5))) > (command "zoom" "w" zmpt1 zmpt2) > (command "_break" p1 "F" (car ptlst) (cadr ptlst) > "_break" p2 "F" (cadr ptlst) (caddr ptlst) > "_break" p3 "F" (caddr ptlst) (last ptlst) > "_break" p4 "F" (car ptlst) (last ptlst)) > (command "zoom" "p") > (vla-EndUndoMark doc) > (setq ptlst nil) > ) ;while > (*Error* nil) > (princ) > ) ;end > > > > Hi, > > > > Does anyone have a LISP or Script that will clean up intersections? Both linear and > radius intersections. I have been constantly trimming and after a few hundred > thousand clicks, I figure there has to be an easier way. I've also have tried using > BPOLY command but it creates polylines on top of existing lines, which I then have to > delete. I am just learning LISP so I'm not sure how to conquer this problem. > > > > I have attached a .BMP file which shows exactly what I'm looking for. > > > > I run Vanilla ACAD 2002 > > > > Any help will be greatly appreciated > > > > Gary > >
*Joe Burke
Message 16 of 21 (113 Views)

Re: LISP for intersection clean up

07-15-2004 05:30 AM in reply to: zorroxxxx
GaryDF, I think if you want discrete intersection clean-up, consider some of the other code posted here which requires selecting objects. I wrote a function which does tee intersections. It extends or trims the first two lines selected to a third line which is broken in the process to create the desired effect. I doubt this sort of thing can be done with one click since there are many possibilities involved. Of course I might be wrong. Luis Esquivel has posted some functions which deal with these issues. Sorry, I don't recall what they were called. Maybe Luis will read this and let us know. Joe Burke > Good this got ride of the AutoCAD error...which locked up the drawing sometimes. > On another note, how would you mode the code to do a tee intersction and a > corner intersection? > > Gary
*Joe Burke
Message 17 of 21 (113 Views)

Re: LISP for intersection clean up

07-15-2004 06:04 AM in reply to: zorroxxxx
Hi Doug, Checking for boundary pline created was at the top of my list of things to do. As I said, "needs more error checking." I didn't suspect the lack of such would cause a fatal error which crashes the application. Oh bother! I was only trying to demonstrate an alternate method... Thanks for the heads-up. Joe > Nice Joe, > > It did however crash autocad under certain situations, > specifically, when the intersection picked was not entirely > closed (boundary failure leads to activeX failure when entlast > is not a polyline). Crash occurs sometimes > after undoing the operation. > > Suggest adding a check to see if the last entity is a new > polyline entity. > > Regards, > Doug
*Luis Esquivel
Message 18 of 21 (113 Views)

Re: LISP for intersection clean up

07-15-2004 07:42 AM in reply to: zorroxxxx
Hi Joe! Sorry but don't remember too... :-( Your routine works great... just some touch-up's and rock & roll I have posted here a fas routine, that does the same but does not work for arc's... it is for cross, tee and corner clean up, user requires to select by window the crossing line that needs to be out... if i found the open code i will post that here... but is a very oooold lispy. Luis. > I think if you want discrete intersection clean-up, consider some of the other code > posted here which requires selecting objects. > > I wrote a function which does tee intersections. It extends or trims the first two > lines selected to a third line which is broken in the process to create the desired > effect. I doubt this sort of thing can be done with one click since there are many > possibilities involved. > > Of course I might be wrong. Luis Esquivel has posted some functions which deal with > these issues. Sorry, I don't recall what they were called. Maybe Luis will read this > and let us know. > > Joe Burke
*Joe Burke
Message 19 of 21 (113 Views)

Re: LISP for intersection clean up

07-16-2004 06:00 AM in reply to: zorroxxxx
Hi Luis, I searched two machines for your old wall intersection functions. I know I had them at some point, but I can't find them now. I'm pretty sure they were open code since I think I recall looking at how you did it. Oh well... Right, it was old stuff. Which at this point, maybe you'd rather not have dredged up anyway. ;-) Good to see you here again. Regards Joe Burke "Luis Esquivel" wrote in message news:40f697e1$1_3@newsprd01... > Hi Joe! > > Sorry but don't remember too... :-( > > Your routine works great... just some touch-up's and rock & roll > > I have posted here a fas routine, that does the same but does not work for > arc's... it is for cross, tee and corner clean up, user requires to select > by window the crossing line that needs to be out... if i found the open > code i will post that here... but is a very oooold lispy. > > Luis. > > > I think if you want discrete intersection clean-up, consider some of the > other code > > posted here which requires selecting objects. > > > > I wrote a function which does tee intersections. It extends or trims the > first two > > lines selected to a third line which is broken in the process to create > the desired > > effect. I doubt this sort of thing can be done with one click since there > are many > > possibilities involved. > > > > Of course I might be wrong. Luis Esquivel has posted some functions which > deal with > > these issues. Sorry, I don't recall what they were called. Maybe Luis will > read this > > and let us know. > > > > Joe Burke > >
Distinguished Contributor
kozmos
Posts: 143
Registered: ‎12-04-2003
Message 20 of 21 (113 Views)

Re: LISP for intersection clean up

07-16-2004 06:21 AM in reply to: zorroxxxx
as for processing crossed lines, you can try kozmos Cross2004, a very intellegent routine to trim the crossed corners.
download at http://www.ikozmos.com
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.