python - get parameters that are not in specific folders

   706   1   1
User Avatar
Member
387 posts
Joined: July 2018
Offline


# check if the parameter is inside a specific folder.

#this code doesnt work
tmp = ['info','Image Settings','Color Settings']
for folder in tmp:
 if folder in parm.containingFolders():
  print("excluded : " + str(parm.name()))
  continue

# this code works
if 'Export Presets' in parm.containingFolders():
 continue

for some reason as soon as i loop through a list of folder names this doesnt work. Any ideas?


User Avatar
Member
387 posts
Joined: July 2018
Offline
this worked! where exclude_folders is just a string parm with a list of folder names, comma separated.
Like tmp list on the previous post.

for parm in parms:
    
        skip_parameter = False

        # Check if the parameter is inside a specific folder. This is in case I want the parms of the HDA itself
        for folder in exclude_folders:
            containing_folders = parm.containingFolders()
            if folder in containing_folders:
                # Exclude parameter
                skip_parameter = True

        if skip_parameter:
            continue

I dont know why the previous didnt work though. The parm to be excluded was correctly caught in the if statement and printed out but the continue statement was not skipping those parms.
  • Quick Links