ajithkumar.t Posted February 29 Posted February 29 (defun c:deleteCirclesByDiameter () (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (if ss (progn (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (if ent (progn (setq diameter (cdr (assoc 40 (entget ent)))) (setq dia (* diameter 2)) (prompt (strcat "\nCircle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (if (and (> x f) (< dia x) (not (= dia 0.6875 x 0.75)) (not (= dia 0.6880 x 0.75))) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) ) ) ) (setq index (1+ index)) ) ) ) (prompt "\nCircles with diameter less than x have been deleted.") ) (prompt "\nNo circles found in the drawing.") ) (princ) ) In this code, help me to fix my mistakes in if conditions.. Quote
EnM4st3r Posted February 29 Posted February 29 (edited) 2 hours ago, ajithkumar.t said: (if (and (> x f) you do not assign x a value within your defun. also these last functions are not within your defun, some brackets are set wrong. Edited February 29 by EnM4st3r Quote
EnM4st3r Posted February 29 Posted February 29 2 hours ago, ajithkumar.t said: (not (= dia 0.6875 x 0.75)) (not (= dia 0.6880 x 0.75)) these are useless since the output is t no matter what Quote
EnM4st3r Posted February 29 Posted February 29 (edited) i would try using less progn functions. and whats the use of that if function? its the same 'then' and 'else' expression (if (and (> x f) (< dia x) (not (= dia 0.6875 x 0.75)) (not (= dia 0.6880 x 0.75)) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) ) also you are using entdel rigth after the if function again wich would instead of delete restore that object again. Edited February 29 by EnM4st3r Quote
EnM4st3r Posted February 29 Posted February 29 (edited) this is basically the same function as yours but with most of the progns removed. but the other problems i said are still here: double entdel -> does nothing if 'then' and 'else' expression are the same using 'x' within the if function but that gets set nowhere (defun c:deleteCirclesByDiameter (/ ss) (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles found in the drawing.") (exit))) (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (setq dia (* 2 (cdr (assoc 40 (entget ent))))) (prompt (strcat "\nCircle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (entdel ent) (if (and (> x f) (< dia x)) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (setq index (1+ index)) ) (prompt "\nCircles with diameter less than x have been deleted.") (princ) ) Edited February 29 by EnM4st3r 1 Quote
ajithkumar.t Posted February 29 Author Posted February 29 Hi mate, what i want is if diameter will be 0.6875 or 0.6880 and x=0.75.. circles should not be deleted. otherwise delete all circles Quote
EnM4st3r Posted February 29 Posted February 29 6 minutes ago, ajithkumar.t said: Hi mate, what i want is if diameter will be 0.6875 or 0.6880 and x=0.75.. circles should not be deleted. otherwise delete all circles so i guess that would be the if condition. (if (and (> x f) (< dia x) (not (member dia '(0.6875 0.6880))) (not (= x 0.75)) ) ;.... ) Quote
ajithkumar.t Posted February 29 Author Posted February 29 x would be thickness of plate which i ll get from another function. Quote
EnM4st3r Posted February 29 Posted February 29 alright, see if that works (defun c:deleteCirclesByDiameter (/ ss) (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (if (not ss) (progn (prompt "\nNo circles found in the drawing.") (exit))) (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (setq dia (* 2 (cdr (assoc 40 (entget ent))))) (prompt (strcat "\nCircle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4))) (if (and (> x f) (> x dia) (not (member dia '(0.6875 0.6880))) (not (= x 0.75)) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (prompt (strcat "\nSkipped Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (setq index (1+ index)) ) (prompt "\nCircles with diameter less than x have been deleted.") ) Quote
ajithkumar.t Posted February 29 Author Posted February 29 this code does not deleted any circles... Quote
EnM4st3r Posted February 29 Posted February 29 you mean its skipping every circle? what about these conditions? you need those? (> x f) (> x dia) Quote
ajithkumar.t Posted February 29 Author Posted February 29 (edited) yes. this is first condition (> x f) it it false there is no deletion process needed. Edited February 29 by ajithkumar.t Quote
EnM4st3r Posted February 29 Posted February 29 so its skipping every cirlce because of the conditions.. what example circle do you want to be deleted and what example x value would you have? Quote
EnM4st3r Posted February 29 Posted February 29 5 minutes ago, ajithkumar.t said: this is first condition (> x f) it it false there is no deletion process needed. yes, it does that Quote
ajithkumar.t Posted February 29 Author Posted February 29 second one is (> dia x) after these conditions true then deletion will start if any circle has dia=0.6875 or 0.6880 when thickness x=0.75, no need to delete those..there is any circles with other values it should be deleted. Quote
EnM4st3r Posted February 29 Posted February 29 1 minute ago, ajithkumar.t said: second one is (> dia x) after these conditions true then deletion will start if any circle has dia=0.6875 or 0.6880 when thickness x=0.75, no need to delete those..there is any circles with other values it should be deleted. it should do exactly that.. can you give example file? Quote
EnM4st3r Posted February 29 Posted February 29 (edited) 7 minutes ago, ajithkumar.t said: if any circle has dia=0.6875 or 0.6880 when thickness x=0.75, ah i thought always if thickness 0.75 dont delete. Try this: (defun c:deleteCirclesByDiameter (/ ss diaexception) (setq f 0.5000) (setq ss (ssget "_X" '((0 . "CIRCLE")))) (setq diaexception '(0.6875 0.6880)) (if (not ss) (progn (prompt "\nNo circles found in the drawing.") (exit))) (setq index 0) (repeat (sslength ss) (setq ent (ssname ss index)) (setq dia (* 2 (cdr (assoc 40 (entget ent))))) (if (and (> x f) (> x dia) (not (and (member dia diaexception) (= x 0.75))) ) (progn (entdel ent) (prompt (strcat "\nDeleted Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (prompt (strcat "\nSkipped Circle: " (itoa (1+ index)) ", Diameter: " (rtos dia 2 4) ", Thickness: " (rtos x 2 4))) ) (setq index (1+ index)) ) (prompt "\nCircles with diameter less than x have been deleted.") ) Edited February 29 by EnM4st3r 1 Quote
ajithkumar.t Posted February 29 Author Posted February 29 its working man..thanks much for your help. 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.