Collections: The Revenge

Discussion in 'AutoCAD' started by James Wedding, Jul 21, 2004.

  1. OK, so, thanks to you smart guys, I have my collection items in the
    combo/list boxes. Now, when I pick these items, I want to hit a button and
    compare the properties.

    Logically, here's what I'm thinking. Code wise this obviously isn't
    perfect, but I'm going for process here.

    for each property of me.list1
    if property(me.list1)<>property(me.list2) then
    put me.list1.property.name in textbox1 with value and
    put me.list2.property.name in textbox2 with value
    end if
    next property.

    So I'd wind up with two boxes next to each other with a list of properties
    that are different between the objects. Then I will build a thumbbar that
    scrolls both text boxes so the user can compare line by line easily.

    The problem is that each collection that I've put into the lists has
    different properties, some more than others. Is there a way to scroll
    through the properties of an object without knowing what kind of object it
    is until scrolling time?

    Thank you in advance!

    --
    James Wedding, P.E.
    IT Manager
    Jones & Boyd, Inc.
    Dallas, TX
    XP/1 on P4-3.4/1G
    LDT2004&5+C3D

    Troll :a slang term for a person who posts messages without contributory
    content, simply intended to incite conflict. http://wikipedia.com
     
    James Wedding, Jul 21, 2004
    #1
  2. James Wedding

    Ken Hutson Guest

    James,
    how about;

    for each property1 in list1
    for each property2 in list2
    if property1.name = property2.name then
    if property1.value <> property2.value then
    put property1.name & " " & property1.value in textbox1
    put property2.name & " " & property2.value in textbox2
    end if
    end if
    next property2
    next property1

    Cheers,
    Ken Hutson
    San Antonio, TX
     
    Ken Hutson, Jul 22, 2004
    #2
  3. Hi James,

    You probably need to create a dictionary of Objects and the properties which
    each one can have.

    I've done it by creating a key - say Line
    Then for a value a set of comma separated items
    eg Line,Layer,LineType,LTScale,Color,etc.
    You can then return the value from the dictionary and use the Split command
    to put it in an array
    Get the array for a second object and split it, then compare the array
    components in a dual loop

    Hence the program flow would be:
    For each object in my collection
    Get value from dictionary
    Get value from dictionary for each other object n the collection with which
    you wish to compare
    Split both values
    Loop through first list
    Loop through second list
    Do what you want and exit loop if match found
    End second list loop
    End first list loop
    Get another object


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Jul 22, 2004
    #3
  4. That's fine, but how do I cycle through all the properties of an object? I
    don't know what they are because the object picked in list1&2 is of varying
    types.

    Does that make sense?

    --
    James Wedding, P.E.
    IT Manager
    Jones & Boyd, Inc.
    Dallas, TX
    XP/SP2 on 3.4/1Gig
    Radeon 9700 Video
    Alpha2
     
    James Wedding, Jul 22, 2004
    #4
  5. That just got interesting then....I'll have to learn dictionaries. Geesh.
    :-|

    --
    James Wedding, P.E.
    IT Manager
    Jones & Boyd, Inc.
    Dallas, TX
    XP/1 on P4-3.4/1G
    LDT2004&5+C3D

    Troll :a slang term for a person who posts messages without contributory
    content, simply intended to incite conflict. http://wikipedia.com
     
    James Wedding, Jul 22, 2004
    #5
  6. James Wedding

    MP Guest

    I don't know of a Properties collection on an object that would list all the
    properties available,
    so you may have to manually build a mega selectcase statement to provide a
    property list depending on the object

    or get a list of all properties of all objects and use an 'on error goto
    errhandler' to 'try'/'catch' calling each property in turn
    (i don't know off hand if vb has a equivalent of property-available-p like
    in vlax)

    just a thought

    Mark
     
    MP, Jul 22, 2004
    #6
  7. Depending upon what you're storing and how you use it, you might be better
    creating a class and having your own object. Its some times easier than
    concat/split - ing everything

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Jul 22, 2004
    #7
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.