How to run through a list, compare it to another list, and print out what's missing?

39 Views Asked by At

This is a little confusing so apologies if not explained well enough.

I'm trying to run through render elements in 3ds max, check what elements are there, see if all the ones in my list of elements appear, and add in the ones that are missing.

Below I have two lists, renderElements is the function needed to create a new Render Element. renderElementsName is the official name of the render element, and is what's outputted when printing it's name.

I'm attempting to gather all the render elements already there, find out which ones are missing when comparing it to the renderElementsName list, and then adding in the new elements from the renderElements list.

#Functions to create new render elements
renderElements = [rt.vrayalpha, rt.vraymtlid, rt.vrayobjectid, rt.vrayreflection, rt.vrayrefraction, rt.vrayspecular, rt.vraytotallighting, rt.vraywirecolor, rt.vrayzdepth]

#Outputted name from getting the render element and printing it.    
renderElementsName = ["VRayAlpha", "VRay MtlID", "VRay ObjectID", "VRayReflection", "VRayRefraction", "VRaySpecular", "VRayTotalLighting", "VRayWireColor", "VRayZDepth"]
    
#Needed to get the render elements
    manager = rt.maxOps.GetCurRenderElementMgr()
    
#Getting the amount of current render elements
    elementAmount = manager.numrenderelements()
    
    n = 0
    
    while n < elementAmount:
        s = manager.getrenderelement(n)
        l = s.elementName
        print(l)
#Running through each of the render elements already there and comparing it to the renderElementsName list. If its there, print match, otherwise print else.
        for i in renderElementsName:
            if l in renderElementsName:
                print("MATCH")
                n += 1
                break
            else:
                print("NO MATCH")
                #Adds in the missing render element.
                manager.addRenderElement(renderElements[i])
                n += 1
                break
0

There are 0 best solutions below