Lee Mac Posted July 16, 2010 Share Posted July 16, 2010 Is it OK. You need an IF statement to allow for null input - see my post earlier. I agree with Alan here though - rewriting code and just changing the variables is not the best way to learn and it will irritate those whose code you are mutilating. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 16, 2010 Share Posted July 16, 2010 You need an IF statement to allow for null input - see my post earlier. Yes, you are right Lee, Thank you for helping me. I did remodified it and here it goes. (defun c:well (/ sel objs ents all) (if (/=(setq sel (ssget "_:L" '((0 . "TEXT,MTEXT"))))nil) (progn (setq objs -1) (setq ents (ssname sel (setq objs (1+ objs)))) (setq all (entget ents)) (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 all)))2 2)) (assoc 1 all) all)) ) ) (princ) ) Best regards Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 16, 2010 Share Posted July 16, 2010 No need for the /= nil, see the earlier codes... Quote Link to comment Share on other sites More sharing options...
Michaels Posted July 16, 2010 Share Posted July 16, 2010 You can try this, but it goes with one selection and I don't know why.. (defun c:try (/ sel objs ents all) (if (setq sel (ssget "_:L" '((0 . "TEXT,MTEXT")))) (progn (setq objs -1) (setq ents (ssname sel (setq objs (1+ objs)))) (setq all (entget ents)) (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 all)))2 2)) (assoc 1 all) all)) ) (princ)) ) Michaels Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 16, 2010 Share Posted July 16, 2010 Because you have no While loop. Seriously guys - there are working codes earlier in this thread before you guys mutilated them. Quote Link to comment Share on other sites More sharing options...
Michaels Posted July 16, 2010 Share Posted July 16, 2010 Because you have no While loop. Seriously guys - there are working codes earlier in this thread before you guys mutilated them. Mr Lee your codes are so hard for me and for lots of people to understand, would you please say what you are indicating to clearly ...? Michaels Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 16, 2010 Share Posted July 16, 2010 Mr Leeyour codes are so hard for me and for lots of people to understand, would you please say what you are indicating to clearly ...? Michaels Thank you Michaels. Here it goes right now you can share it with me. (defun c:try (/ sel objs ents all) (setq sel (ssget "_:L" '((0 . "TEXT,MTEXT")))) (setq objs -1) [color="Red"](while[/color] (setq ents (ssname sel (setq objs (1+ objs)))) (setq all (entget ents)) (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 all)))2 2)) (assoc 1 all) all)) ) (princ) ) Sincerly Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 16, 2010 Share Posted July 16, 2010 Replace the lambda expression with (setq i -1) (defun c:R2D2 (/ ss) (if (setq ss (ssget "_:L" '((0 . "TEXT")))) [color=Red][b]((lambda (i / e l)[/b][/color] (while (setq e (ssname ss (setq i (1+ i)))) (setq l (entget e)) (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 l))) (getvar 'lunits) 2)) (assoc 1 l) l)) ) ) [color=Red][b] -1 )[/b][/color] ) (princ) ) (defun c:R2D2 (/ ss [b][color=Red]i[/color][/b]) (if (setq ss (ssget "_:L" '((0 . "TEXT")))) [color=Red][b] (progn (setq i -1)[/b][/color] (while (setq e (ssname ss (setq i (1+ i)))) (setq l (entget e)) (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 l))) (getvar 'lunits) 2)) (assoc 1 l) l)) ) [color=Red][b] )[/b][/color] ) (princ) ) All I'm saying is that instead of complaining that something doesn't work, look at the working code and compare it. Quote Link to comment Share on other sites More sharing options...
jcap91163 Posted July 31, 2010 Share Posted July 31, 2010 the R2D2 routine works fine, many thanks Quote Link to comment Share on other sites More sharing options...
ridpath Posted September 24, 2010 Share Posted September 24, 2010 Just found this posting via Google, thanks for the lisp folks! Quote Link to comment Share on other sites More sharing options...
wing Posted October 10, 2014 Share Posted October 10, 2014 (edited) Not much different from Alan's code, keeping with the theme lol (defun c:C3PO ( / ss ) (if (setq ss (ssget "_:L" '((0 . "TEXT")))) ( (lambda ( i / e el ) (while (setq e (ssname ss (setq i (1+ i)))) (if (distof (cdr (assoc 1 (setq el (entget e))))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 el) ) ) (getvar 'LUNITS) 2 ) ) (assoc 1 el) el ) ) ) ) ) ) ) ) -1 ) ) (princ) ) That's brilliant. Now, how do I force it to 2 decimals the other way? like 21.5 to 21.50 or 21.501 to 21.50. It doesn't seem to work. In both cases, the result produces 21.5. Thanks Lee Mac. I love your align to curve routine. Update: Setting DIMZIN to 0 fixed it. Edited October 10, 2014 by wing Update Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 10, 2014 Share Posted October 10, 2014 You're welcome! As you've gathered, DIMZIN is the key 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.