sparami Posted May 20, 2009 Share Posted May 20, 2009 Hi Friends, i need a pgm that 1. prompts for Radius of circle 2. when Radius is given, all the cirlces of similar diameter ( tolerance of +/- .05 , precision two decimal places) in the dwg should be grip selected 3. so that i can change the selected (Grip highlited) circles to different layer with layer name being their diameter. i am almost done, Below is the lisp code, except that, each time i have to alter the radius value in the code, here it is 4.0( this pgm can select all circles with radius 4.0), (defun c:SIMRAD () (setq rad (cdr (assoc 40 (entget (car (entsel)))))) (alert (strcat "Radius = " (rtos rad 2))) (princ) (cadr(sssetfirst nil(setq ss_grip (ssget "_X"'((0 . "CIRCLE")(-4 . "=")(40 . 4.0 )))))) ) ; can somebody suggest a solution:unsure: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 20, 2009 Share Posted May 20, 2009 Perhaps: (defun c:SIMRAD (/ cEnt rad) (if (setq cEnt (car (entsel "\nSelect Circle: "))) (progn (sssetfirst nil (ssget "_X" (list '(0 . "CIRCLE") '(-4 . "=") (setq rad (assoc 40 (entget cEnt)))))) (alert (strcat "Radius = " (rtos (cdr rad) 2 2)))) (princ "\n<!> Nothing Selected <!>")) (princ)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 20, 2009 Share Posted May 20, 2009 Or, with Tolerance: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:SIMRAD [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt ssgrip[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tol [b][color=#009999]0.05[/color][/b][b][color=RED])[/color][/b] [i][color=#990099]; <<-- Tolerance[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Circle: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] rad [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]40[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]sssetfirst[/color][/b] [b][color=BLUE]nil[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#ff00ff]"_X"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#ff00ff]"CIRCLE"[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]-4[/color][/b] . [b][color=#ff00ff]">="[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] rad tol[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]-4[/color][/b] . [b][color=#ff00ff]"<="[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]10[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] rad tol[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]alert[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"Radius = "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] rad [b][color=#009900]2[/color][/b] [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Nothing Selected <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote Link to comment Share on other sites More sharing options...
sparami Posted May 21, 2009 Author Share Posted May 21, 2009 Hi Lee, Thanks for your immediate response, you will not understand the joy i had when i checked the lisp (01 without tolerance code) and it WORKED, splendid work to save my time. THANKS LEE. also the one without tolereance code is working fine, just the way i had requested, the other one (02 with tolerance code) gives error as Select Circle: ; error: bad SSGET list value ofcourse i selected only circle, to be specific selected the same one for which the first lisp worked fine. anyway, Thanks for sparing your time and effort, once again my sincere thanks to you for the job done:D. Paramanathan Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 21, 2009 Share Posted May 21, 2009 My apologies, it was a stupid mistake - I used the DXF code 10, for some weird reason... (defun c:SIMRAD (/ cEnt ssgrip) (setq tol 0.05) ; <<-- Tolerance (if (setq cEnt (car (entsel "\nSelect Circle: "))) (progn (setq rad (cdr (assoc 40 (entget cEnt)))) (sssetfirst nil (ssget "_X" (list '(0 . "CIRCLE") '(-4 . ">=") (cons 40 (- rad tol)) '(-4 . "<=") (cons 40 (+ rad tol))))) (alert (strcat "Radius = " (rtos rad 2 2)))) (princ "\n<!> Nothing Selected <!>")) (princ)) Quote Link to comment Share on other sites More sharing options...
sparami Posted May 22, 2009 Author Share Posted May 22, 2009 Hi Lee, Splendid Work again, didn't notice that mistake. My Sincere Thanks for all your efforts. got solutions from others too, but as the code from you were so prompt, i am using those, just tried these,thought i could share them with you, just ignore if not interested. Have a nice time. Parami SR3.lsp SR4.lsp Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2009 Share Posted May 22, 2009 Thanks Parami, I'm glad you got it sorted Quote Link to comment Share on other sites More sharing options...
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.