cletero Posted May 19, 2014 Share Posted May 19, 2014 Hello to you all, I was wondering if this is possible (or maybe it's too basic and I'm not seeing it): I have some LISP code with a WHILE loop on it, during this loop, a number of objects are created in the drawing (lets say circles) one after the other. However, when I run the program step by step to check it, I have to wait until the program goes into the while loop again before the objects are displayed in the screen. Is there any way of displaying the objects one by one as soon as I go through the code line in which they are created? I hope I'm making sence Cheers Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 19, 2014 Share Posted May 19, 2014 You may need to post your codes to allow us to check that out for you Quote Link to comment Share on other sites More sharing options...
cletero Posted May 19, 2014 Author Share Posted May 19, 2014 Look at this example I was working on last weekend, it works fine now, but it would have helped a lot if when running the program step by step I could've seen each offset object as it was created during the FOREACH loop and not having to wait until it returned to the WHILE, as then suddenly a bunch of objects appear on screen and it was difficult to identify them. ;Alfredo Rodriguez, 18 May 2014 ;This will offset an object multiple times ;It will offset to the inside/outside, up/down, left/right depending on the drawing direction ;So it's better to always set a maximum number of offsets or else it could offset indefinitely ;For this reason, if use default is chosen, it will offset the object 20 times, or you can ;choose how many times to offset. If object is offset to the wrong side, enter a negative distance (ej: -3 instead of 3) ;I'm not a lisp professional, so I can't guaranty any results obtained with this code, so use with care. (defun c:cntoffset (/ ename dist vobj obj objlist objlist2 how_many count maxcount) (vl-load-com) (null (initget 7)) (while (setq ent (ssget)) (setq dist (getdist "\nEnter offset distance: ")) (setq how_many (sslength ent)) (setq count 0) (or (setq maxcount (getdist "\nEnter number of offsets (or press Enter to use default): ")) (setq maxcount 20) ) (while (/= count how_many) (setq ename (ssname ent count)) (setq obj (list (vlax-ename->vla-object ename))) (setq objlist (append obj objlist)) (setq count (+ count 1)) ) (setq count 0) (while (and (/= count maxcount) (/= objlist nil)) (setq count (+ count 1)) (foreach vobj objlist (if (vlax-method-applicable-p vobj "Offset") (if (vl-catch-all-error-p (setq objlist2 (vl-catch-all-apply 'vlax-invoke (list vobj 'Offset (- dist))))) (setq objlist2 nil) ) (prompt "\n*** Can not offset that object, try again. ***") ) (setq objlist (append (cdr objlist) objlist2)) ) ) (setq objlist nil) (setq objlist2 nil) ) (princ) ) Any help will be appreciated Quote Link to comment Share on other sites More sharing options...
hmsilva Posted May 19, 2014 Share Posted May 19, 2014 One way (defun c:demo (/ N PT R X) (setq n 5 pt '(0.0 0.0) r 5. ) (while (> n 0) (entmake (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 r) ) ) (setq pt (mapcar '(lambda (x) (+ x 3)) pt)) (alert "\nJust for testing!!!") (setq n (1- n)) ) (princ) ) HTH Henrique Quote Link to comment Share on other sites More sharing options...
cletero Posted May 20, 2014 Author Share Posted May 20, 2014 Hi, Thanks hmsilva, it does work on the code you provided, but I tried placing that line in different places of my code and wasn't able to make it work in the same way Any thoughts? I'm trying it in the code I posted just before your answer. Quote Link to comment Share on other sites More sharing options...
hmsilva Posted May 20, 2014 Share Posted May 20, 2014 Hi,Thanks hmsilva, it does work on the code you provided, but I tried placing that line in different places of my code and wasn't able to make it work in the same way Any thoughts? I'm trying it in the code I posted just before your answer. You're welcome, cletero! Try (untested) ;Alfredo Rodriguez, 18 May 2014 ;This will offset an object multiple times ;It will offset to the inside/outside, up/down, left/right depending on the drawing direction ;So it's better to always set a maximum number of offsets or else it could offset indefinitely ;For this reason, if use default is chosen, it will offset the object 20 times, or you can ;choose how many times to offset. If object is offset to the wrong side, enter a negative distance (ej: -3 instead of 3) ;I'm not a lisp professional, so I can't guaranty any results obtained with this code, so use with care. (defun c:cntoffset (/ ename dist vobj obj objlist objlist2 how_many count maxcount) (vl-load-com) (null (initget 7)) (while (setq ent (ssget)) (setq dist (getdist "\nEnter offset distance: ")) (setq how_many (sslength ent)) (setq count 0) (or (setq maxcount (getdist "\nEnter number of offsets (or press Enter to use default): ")) (setq maxcount 20) ) (while (/= count how_many) (setq ename (ssname ent count)) (setq obj (list (vlax-ename->vla-object ename))) (setq objlist (append obj objlist)) (setq count (+ count 1)) ) (setq count 0) (while (and (/= count maxcount) (/= objlist nil)) (setq count (+ count 1)) (foreach vobj objlist (if (vlax-method-applicable-p vobj "Offset") (progn (alert "\nJust for testing!!!") (if (vl-catch-all-error-p (setq objlist2 (vl-catch-all-apply 'vlax-invoke (list vobj 'Offset (- dist))))) (setq objlist2 nil) ) (prompt "\n*** Can not offset that object, try again. ***") ) ) (setq objlist (append (cdr objlist) objlist2)) ) ) (setq objlist nil) (setq objlist2 nil) ) (princ) ) HTH Henrique Quote Link to comment Share on other sites More sharing options...
cletero Posted May 21, 2014 Author Share Posted May 21, 2014 That did the trick!! Not sure how this works, but it does. Thank you very much for your help!!:thumbsup: Have a nice day Quote Link to comment Share on other sites More sharing options...
hmsilva Posted May 21, 2014 Share Posted May 21, 2014 You're welcome, cletero Glad I could help Henrique Quote Link to comment Share on other sites More sharing options...
cletero Posted September 8, 2014 Author Share Posted September 8, 2014 Just an update, in case it helps anyone, inserting this line after an object was created seems to work too: (vla-update (vlax-ename->vla-object (entlast))) 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.