Results 1 to 8 of 8
Like Tree4Likes
  • 3 Post By johnp
  • 1 Post By josephpeel

Thread: Find matching values in unequal lists and replace

  1. #1
    jmk
    jmk is offline
    Forum Addict jmk's Avatar
    Join Date
    December 31, 2012
    Location
    NM, USA
    Posts
    1,361
    Current Local Time
    11:44 PM

    Find matching values in unequal lists and replace

    I am trying to create a dynamo script that can update information (primarily cost) in furniture families. While I sort of have a working concept for how to get the existing furniture data and how to write revised data back to the families I am stumped at how to match the data between lists using the furniture id number. The lists won't be the same length, even if they are sorted by the furniture id number, and I don't know how to pair up the data dynamically because of that.

    What I think I need is some way to communicate an if condition of "if a value from 'list import id' is equal to a value from 'list existing id' use the the cost data corresponding to the import id from 'list import' and replace the cost data in 'list existing' that corresponds to the existing id"

    A visual draft of what I'm thinking. So far I can only figure out how to get it to work if the id's match directly.

    Find matching values in unequal lists  and replace-match-unequal.png

  2. #2
    Member johnp's Avatar
    Join Date
    March 24, 2015
    Posts
    138
    Current Local Time
    11:44 PM
    I rebuilt your data with simple lists, but lacing and an IF statement should get you what you want.
    Find matching values in unequal lists  and replace-2016-06-23-11_45_49-dynamo.png

  3. #3
    Member johnp's Avatar
    Join Date
    March 24, 2015
    Posts
    138
    Current Local Time
    11:44 PM
    And the graph

    commitActionIf.dyn

  4. #4
    Member johnp's Avatar
    Join Date
    March 24, 2015
    Posts
    138
    Current Local Time
    11:44 PM
    Or one big codeblock
    Find matching values in unequal lists  and replace-2016-06-23-12_09_11-dynamo.png

  5. #5
    jmk
    jmk is offline
    Forum Addict jmk's Avatar
    Join Date
    December 31, 2012
    Location
    NM, USA
    Posts
    1,361
    Current Local Time
    11:44 PM
    Thanks! It looks like it is getting a lot closer. I have two questions:

    1. How do you change the lacing of a node? I see where it indicates it on the node, but can't figure out how to change them back and forth
    2. How do I get it to cycle through, so that in the final result index 1 has the value 60.2 in sublist index 4 and index 2 has the value 40.11 in sublist index 4?

  6. #6
    Member johnp's Avatar
    Join Date
    March 24, 2015
    Posts
    138
    Current Local Time
    11:44 PM
    The lacing should do it. You right click on the node and toggle to longest.

  7. #7
    jmk
    jmk is offline
    Forum Addict jmk's Avatar
    Join Date
    December 31, 2012
    Location
    NM, USA
    Posts
    1,361
    Current Local Time
    11:44 PM
    Thanks, found the lacing.
    I think there will need to be a nested if statement sort code (if that's doable in dynamo) to say
    if a==b, replace value
    if a/=b, cycle through list until a==b
    if no pairs in the list equal each other, use the original value

    Otherwise the code looks and and sees a/=b and uses the original value, instead of looking for the where the same value might be in the list.

  8. #8
    Forum Addict josephpeel's Avatar
    Join Date
    May 3, 2012
    Posts
    1,369
    Current Local Time
    07:44 AM
    Ah! Thank you JMK! I have been wondering what the syntax for List.GetItemAtIndex(List<LSublist>,Index) is in design script for a while. I have been using List.Map and GetItemAtIndex nodes everywhere to do the same thing :P

    The reason I find this important is because when doing anything with families in revit I think it is a good idea to first get all the useful data, then make a list of lists where each sublist includes the family instance itself and the relevant data. That way nothing can go wrong with lists of unequal length or sorting, the correct data is always located with the family it comes from. But that requires always sorting and filtering by sublist data..
    amoursol likes this.

Similar Threads

  1. Rendering Colour not matching selection.
    By Kannis in forum Architecture and General Revit Questions
    Replies: 2
    Last Post: June 1st, 2016, 03:09 PM
  2. Curtain Wall Pair Doors - Panels Changing to Unequal Lengths When Inserted?
    By blusurfer in forum Architecture - Family Creation
    Replies: 4
    Last Post: October 1st, 2014, 04:08 PM
  3. Framing top plates not matching
    By Cambraceres in forum Architecture and General Revit Questions
    Replies: 0
    Last Post: May 27th, 2013, 04:14 AM
  4. Find and replace
    By andyhoman1 in forum Architecture and General Revit Questions
    Replies: 1
    Last Post: May 9th, 2012, 06:04 PM
  5. Autodesk Find and Replace
    By gdoherty0102 in forum Architecture and General Revit Questions
    Replies: 3
    Last Post: July 12th, 2011, 03:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •