harilalmn Posted August 8, 2011 Posted August 8, 2011 Hi All, I am really confused of what I have below. I got this code from somewhere on net. This iterates through the attributes and extract the attribute with tag "ROOM_NAME" (while (not (eq "SEQEND" (dxf 0 (setq ent (entnext ent)))) ) (if (= (dxf 2 ent) "ROOM_NAME") (setq RmName (dxf 1 ent)) );If );While Well... Now, What is the condition the 'while' is checking here? What is that "SEQEND"? What is that "dxf" function after SEQEND with '0' (zero) as argument to it? Could someone please help? Quote
pBe Posted August 8, 2011 Posted August 8, 2011 on the first run on an attribute block (dxf 0 (setq ent (entnext ent))) which also means (cdr (assoc 0 (entget (setq ent (entnext ent))))) the result will be "ATTRIB", wherein the conditon asked for result equal to "SEQEND", in this case is nil (NOT= not True) on the subsequent run eventually it will hit "SEQEND" making the statement True (NOT = Not True) = True which makes it Nil then terminates the condition SEQEND --> for attributes: the end of attribute entities (attrib type name) for an insert entity that has attributes for polylines:marks the end of vertex (vertex type name) for a polyline if im not mistaken (defun dxf (num ent) (cdr (assoc num (entget ent))) ) Quote
Lee Mac Posted August 8, 2011 Posted August 8, 2011 This might also help: http://www.cadtutor.net/forum/showthread.php?48577-Getting-a-value-for-a-specific-attribute&p=330778#post330778 Quote
harilalmn Posted August 8, 2011 Author Posted August 8, 2011 This might also help: http://www.cadtutor.net/forum/showthread.php?48577-Getting-a-value-for-a-specific-attribute&p=330778#post330778 I got this from the above link; (if (and (setq bEnt (car (entsel "\nSelect Block: "))) (eq "INSERT" (cdr (assoc 0 (entget bEnt)))) (= 1 (cdr (assoc 66 (entget bEnt)))) ) I am bit confused about that 'and'. Autocad help doesn't give a good explanation on it. Could you please tell me how the 'and' works? Quote
harilalmn Posted August 8, 2011 Author Posted August 8, 2011 And yeah... You have a wonderful resource out there at that link what you shared... Fantastic post with very comprehensive explanations step-by-step. Thnks for that Lee....!! Quote
Lee Mac Posted August 8, 2011 Posted August 8, 2011 The AND function will continue to evaluate the expressions passed to it until either: an expression returns nil, in which case AND returns nil; or there are no more expressions to evaluate, in which case AND returns T, since all the expressions evaluated have necessarily returned a non-nil value. In this way the AND function is returning the logical AND of the expressions being evaluated, i.e.: <expr1> AND <expr2> AND <expr3> ... AND ... <exprN> The AND function will only return T if all expressions ,..., have returned a non-nil value [note that the expressions needn't return explicitely T, but anything non-nil. Hence a return of 1.2 is non-nil, or a return of "ABC"]. Its use in conjunction with the IF statement can be read in the following way: IF <expr1> AND <expr2> AND <expr3> ... AND ... <exprN> THEN ELSE i.e. ALL of the expressions ,...,. must return a non-nil value for the AND function to return T and hence the 'THEN' expression of the IF statement to be evaluated. Quote
Lee Mac Posted August 8, 2011 Posted August 8, 2011 And yeah... You have a wonderful resource out there at that link what you shared... Fantastic post with very comprehensive explanations step-by-step. Thnks for that Lee....!! Thanks harilalmn, I'm glad you could understand my explanations Quote
harilalmn Posted August 8, 2011 Author Posted August 8, 2011 The AND function will continue to evaluate the expressions passed to it until either: an expression returns nil, in which case AND returns nil; or there are no more expressions to evaluate, in which case AND returns T, since all the expressions evaluated have necessarily returned a non-nil value. In this way the AND function is returning the logical AND of the expressions being evaluated, i.e.: <expr1> AND <expr2> AND <expr3> ... AND ... <exprN> The AND function will only return T if all expressions ,..., have returned a non-nil value [note that the expressions needn't return explicitely T, but anything non-nil. Hence a return of 1.2 is non-nil, or a return of "ABC"]. Its use in conjunction with the IF statement can be read in the following way: IF <expr1> AND <expr2> AND <expr3> ... AND ... <exprN> THEN ELSE i.e. ALL of the expressions ,...,. must return a non-nil value for the AND function to return T and hence the 'THEN' expression of the IF statement to be evaluated. Really Nice of you Lee...!! Now I have a good understanding of things... I started learning lisp by rat-picking on net, and just at the basic level. Now, infact, I feel greedy to learn more this way, from you. Your reply for each post seems to be very much understandable. Thanks a lot for your time and effort.. Feel like bugging you more my dear friend....!! Quote
Lee Mac Posted August 8, 2011 Posted August 8, 2011 Really Nice of you Lee...!! Now I have a good understanding of things... I started learning lisp by rat-picking on net, and just at the basic level. Now, infact, I feel greedy to learn more this way, from you. Your reply for each post seems to be very much understandable. Thanks a lot for your time and effort.. Feel like bugging you more my dear friend....!! Thanks harilalmn I try my best to structure my posts and explain things as clearly as I can (if I have time, that is), so I'm glad that my explanations can be beneficial to your learning. Lee Quote
pBe Posted August 8, 2011 Posted August 8, 2011 I try my best to structure my posts and explain things as clearly as I can (if I have time, that is),........ True that, and its highly appreciated by eveyone here on this forum Thanks and keep up the good work 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.