TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: daron on March 14, 2008, 12:41:55 PM

Title: Why does this happen? foreach foreach
Post by: daron on March 14, 2008, 12:41:55 PM
First off, I have this:
Code: [Select]
(setq *acad   (vlax-get-acad-object)
   doc    (vla-get-activedocument *acad)
   layers  (vla-get-layers doc)
   alist   (list "a-panel" "a-furn")
     )
Then I create a list of layernames like so:
Code: [Select]
(vlax-for i layers
  (if (or (wcmatch (strcase (vla-get-name i) t) "rcp-*")
  (= (strcase (vla-get-name i) t) "a-head")
  )
      (setq rcplist (append rcplist (list i)))
      (setq layernames (append layernames (list (vla-get-name i))))
  )
     )
This allows me to have one list for freezing and while the other thaws the layers.
What I'm having trouble with is how the next piece handles putting the list together.
Code: [Select]
(foreach i alist
  (foreach j layernames
       (if (= i (strcase j t))
    (setq below
      (append below (list (vla-item layers j)))
    )
       )
  )
     )
What I'm thinking this should do is take one item from alist (i), compare it with all the items in layernames (j) and if it finds a match append it to list "below". What's it's doing is checking (i) twice. Why?
Title: Re: Why does this happen? foreach foreach
Post by: daron on March 14, 2008, 02:04:54 PM
Well, that's strange. I just rewrote that part from the inside out and it worked just fine. Uh??? Nevermind, I guess.
Title: Re: Why does this happen? foreach foreach
Post by: daron on March 14, 2008, 02:14:54 PM
Then again, maybe not.
Title: Re: Why does this happen? foreach foreach
Post by: daron on March 14, 2008, 02:54:20 PM
Well, since I'm having a conversation with myself, I'll just answer. It's works as it should. There was a variable that apparently had double information that was causing the problem.
Title: Re: Why does this happen? foreach foreach
Post by: CAB on March 14, 2008, 04:24:37 PM
Glad ya'll figured it out. 8-)
Title: Re: Why does this happen? foreach foreach
Post by: daron on March 14, 2008, 04:26:58 PM
Thanks, from all of us.