Author Topic: Why does this happen? foreach foreach  (Read 1867 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Why does this happen? foreach foreach
« 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?

daron

  • Guest
Re: Why does this happen? foreach foreach
« Reply #1 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.

daron

  • Guest
Re: Why does this happen? foreach foreach
« Reply #2 on: March 14, 2008, 02:14:54 PM »
Then again, maybe not.

daron

  • Guest
Re: Why does this happen? foreach foreach
« Reply #3 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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Why does this happen? foreach foreach
« Reply #4 on: March 14, 2008, 04:24:37 PM »
Glad ya'll figured it out. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
Re: Why does this happen? foreach foreach
« Reply #5 on: March 14, 2008, 04:26:58 PM »
Thanks, from all of us.