For each nested

Discussion in 'AutoCAD' started by Ursus Uziemblo, Feb 10, 2005.

  1. Hi,
    I try (without luck) search thru all entities in all layouts

    For each obj in ThisDrawing.Layouts
    do whatever
    next
    works OK, but

    For each obj in ThisDrawing.Layouts
    for each obj1 in obj
    do whatevet
    next
    next

    returns error
    How to do this trick - I hope it is possible :)
    Ursus Uziemblo
     
    Ursus Uziemblo, Feb 10, 2005
    #1
  2. That's to be expected. For Each iteration only works with things like
    collections, dictionaries and arrays. Not every object you encounter is
    going to support iteration so the code will not work.
     
    Frank Oquendo, Feb 10, 2005
    #2
  3. Ursus Uziemblo

    fantum Guest

    The AcadLayout objects have a .Block property which returns an AcadBlock which you can iterate:

    For each obj in ThisDrawing.Layouts
    for each obj1 in obj.Block '<---
    do whatevet
    next
    next
     
    fantum, Feb 10, 2005
    #3
  4. thanks Fantum,
    this works OK, I forgot obj.BLOCK
    now I'm on wright truck
    thanks again
    Ursus Uziemblo
     
    Ursus Uziemblo, Feb 10, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.