Jump to content

harilalmn

Recommended Posts

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,

  1. What is the condition the 'while' is checking here?
  2. What is that "SEQEND"?
  3. What is that "dxf" function after SEQEND with '0' (zero) as argument to it?

 

Could someone please help?

Link to comment
Share on other sites

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)))
             )

Link to comment
Share on other sites

 

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?

Link to comment
Share on other sites

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....!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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....!! :D

Link to comment
Share on other sites

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....!! :D

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...