gvgbabu Posted June 8, 2011 Posted June 8, 2011 Hi all can any body help me to write a lisp program in which i have to replace all circles in a drawing with same sizes of donuts (filled circles). thanks in advance ganesh Quote
BIGAL Posted June 8, 2011 Posted June 8, 2011 Check out http://www.cadtutor.net/forum/showthread.php?59935-Help-with-LISP-assignment looks like a lot of students have been given assignments. I would start with (ssget "x" '((0 . "CIRCLE"))) Quote
Organic Posted June 8, 2011 Posted June 8, 2011 If it is the same circle repeated over and over then it should have been made into a block at the start and then it would be easy to modify the block to be a filled circle instead. Quote
Tharwat Posted June 8, 2011 Posted June 8, 2011 This ...... (defun c:Test (/ ss in out) (if (and (setq in (getdist "\n Specify Inside Diameter :")) (setq out (getdist "\n Specify Outside Diameter :")) (setq ss (ssget "_x" '((0 . "CIRCLE")))) ) ( (lambda (j / sset) (while (setq sset (ssname ss (setq j (1+ j)))) (command "_.donut" in out (cdr (assoc 10 (entget sset))) "") (entdel sset) ) ) -1 ) (princ "\n Sorry !! Not even a Circle found ") ) (princ) ) Tharwat Quote
gvgbabu Posted June 8, 2011 Author Posted June 8, 2011 thanks tharwat Dink & Begal its working very well and u made me my work easier thanks a lot ganesh Quote
Tharwat Posted June 8, 2011 Posted June 8, 2011 thanks tharwat Dink & Begal its working very well and u made me my work easier thanks a lot ganesh Happy to hear that . ganesh Enjoy . Quote
Lee Mac Posted June 8, 2011 Posted June 8, 2011 Another method would be to create the Donut without using the DONUT command. The following code will work on circles of any radius, drawn in any plane, and will furthermore retain all properties of the original circle: (defun c:Circle2Donut ( / c i l r s ) (vl-load-com) ;; © Lee Mac 2011 (if (setq s (ssget "_:L" '((0 . "CIRCLE")))) (repeat (setq i (sslength s)) (setq l (entget (ssname s (setq i (1- i)))) r (cdr (assoc 40 l)) c (cdr (assoc 10 l)) ) (if (entmakex (append '( (0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (90 . 2) (70 . 1) ) (vl-remove-if '(lambda ( x ) (member (car x) '(-1 0 5 10 40 100 330))) l) (list (cons 43 r) (cons 10 (polar c pi (/ r 2.))) (cons 42 1) (cons 10 (polar c 0. (/ r 2.))) (cons 42 1) (assoc 210 l) ) ) ) (entdel (cdr (assoc -1 l))) ) ) ) (princ) ) Quote
Tharwat Posted June 8, 2011 Posted June 8, 2011 Lee , I guess there must be inside and outside inputs to avoid converting circles as a matter of hatch solid option . Regards Quote
Lee Mac Posted June 8, 2011 Posted June 8, 2011 I guess there must be inside and outside inputs to avoid converting circles as a matter of hatch solid option . I understood that the OP required 'filled circles', however Donuts of arbitrary inside/outside radius may be created if necessary. Quote
David Bethel Posted June 8, 2011 Posted June 8, 2011 Or maybe: [b][color=BLACK]([/color][/b]defun c:cir2dont [b][color=FUCHSIA]([/color][/b]/ ss en ed ce ev ra la lt tk cl[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"CIRCLE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss 0[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b] ce [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 10 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] ev [b][color=GREEN]([/color][/b]caddr ce[b][color=GREEN])[/color][/b] ra [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 40 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] la [b][color=GREEN]([/color][/b]assoc 8 ed[b][color=GREEN])[/color][/b] lt [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]assoc 6 ed[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 6 ed[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]6 . [color=#2f4f4f]"BYLAYER"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] tk [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]assoc 39 ed[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 39 ed[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]39 . 0[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] cl [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]assoc 62 ed[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 62 ed[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]62 . 256[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"POLYLINE"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 66 1[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]list 10 0 0 ev[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 40 ra[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 41 ra[b][color=BLUE])[/color][/b] la lt tk cl [b][color=BLUE]([/color][/b]cons 70 1[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 210 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]list 10 [b][color=RED]([/color][/b]+ [b][color=PURPLE]([/color][/b]car ce[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]* ra 0.5[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cadr ce[b][color=RED])[/color][/b] ev[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 40 ra[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 41 ra[b][color=BLUE])[/color][/b] la lt tk cl [b][color=BLUE]([/color][/b]cons 42 1[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]list 10 [b][color=RED]([/color][/b]- [b][color=PURPLE]([/color][/b]car ce[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]* ra 0.5[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]cadr ce[b][color=RED])[/color][/b] ev[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 40 ra[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 41 ra[b][color=BLUE])[/color][/b] la lt tk cl [b][color=BLUE]([/color][/b]cons 42 1[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"SEQEND"[/color][b][color=BLUE])[/color][/b] la lt tk cl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entdel en[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]ssdel en ss[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]redraw[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote
gvgbabu Posted June 8, 2011 Author Posted June 8, 2011 yours also working well with out specifying the inner and outer diameters thanks ganesh Quote
gvgbabu Posted June 8, 2011 Author Posted June 8, 2011 hi Lee & David yours also working well with out specifying the inner and outer diameters thanks ganesh Quote
David Bethel Posted June 9, 2011 Posted June 9, 2011 Another method would be to create the Donut without using the DONUT command. The following code will work on circles of any radius, drawn in any plane, and will furthermore retain all properties of the original circle: (defun c:Circle2Donut ( / c i l r s ) (vl-load-com) ;; © Lee Mac 2011 (append '( (0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (90 . 2) (70 . 1) ) (vl-remove-if '(lambda ( x ) (member (car x) '(-1 0 5 10 40 100 330))) l) (list (cons 43 r) (cons 10 (polar c pi (/ r 2.))) (cons 42 1) (cons 10 (polar c 0. (/ r 2.))) (cons 42 1) (assoc 210 l) ) ) ) Lee, Just a nit pick : While the remove does retain the essential data, it doesn't take into consideration the missing DXF groups. What if the circle has no thickness ( 39 ) but the sysvar THICKNESS is set t o say 2? -David Quote
Lee Mac Posted June 9, 2011 Posted June 9, 2011 Just a nit pick : While the remove does retain the essential data, it doesn't take into consideration the missing DXF groups. What if the circle has no thickness ( 39 ) but the sysvar THICKNESS is set t o say 2? That's a good point David, and that would of course apply to 62/CECOLOR and others too. I overlook the fact that entmake uses the current settings and not default settings. 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.