cadb1 Posted December 14, 2011 Posted December 14, 2011 Hi All, I want to test the function successful running or not, any method to test it. Please give some suggestion. I saw some information from here, it record the entities before running the function and then compare the result after running the function. (defun c:tt () (setq ss (ssget ":L:E")) (setq c 0) (repeat (sslength ss) (setq i ( ssname ss c)) (setq aaa (entlast) (function) (setq bbb (entlast) (if (not (equal aaa bbb) (alert "this function successful apply to object) (alert "not successful") ) ) (setq c (1+ c)) );defun But I found that, if this function successful apply on first the object, it can't get second object. Anything wrong or my concept not correct ? Forgive my poor English. Quote
Tharwat Posted December 14, 2011 Posted December 14, 2011 Simple example ... (defun c:TesT (/ line) (if (and (setq line (car (entsel "\n Select line please : "))) (eq (cdr (assoc 0 (entget line))) "LINE") ) (alert "Congratulations you selected a line ") (alert "Failed !! your selection is not a line ") ) (princ) ) Quote
cadb1 Posted December 14, 2011 Author Posted December 14, 2011 Thank you ! In this case, would you use reactor to test the function sucessful apply on the objects or not ? Quote
Tharwat Posted December 14, 2011 Posted December 14, 2011 I am sorry , I do not know how to use reactor or its functions . But certainly , lots of gentlemen here could help you with reactor . Quote
Lee Mac Posted December 15, 2011 Posted December 15, 2011 It would depend upon the operation of the function you are evaluating. For example, if the function is performing various command calls to create objects, you can check the last entity added to the database before the command call (using entlast), then check this again after the command call to see whether the new entities have been successfully added. This check may be different depending on the function you are evaluating, for example, various AutoLISP functions will return different values depending upon whether they have been successful or not. Most functions return nil if unsuccessful (for example entmake[x]). Lee Quote
cadb1 Posted December 16, 2011 Author Posted December 16, 2011 Thank you Lee, I found in frist looping, when i use entlast to compare the new entities have been added or not is fine. But in second looping. the entlast will compare the first looping created entity. Any method to avoid it to compare the first round's entites. I try to reset the aaa and bbb to nil, but unsuccessful. It would depend upon the operation of the function you are evaluating. For example, if the function is performing various command calls to create objects, you can check the last entity added to the database before the command call (using entlast), then check this again after the command call to see whether the new entities have been successfully added. This check may be different depending on the function you are evaluating, for example, various AutoLISP functions will return different values depending upon whether they have been successful or not. Most functions return nil if unsuccessful (for example entmake[x]). Lee 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.