There are actually 2 questions here...
I'm just starting to learn Python and I'm try to write a script to dissect a group of models and pull possible modeling problems in attributes of the Blender bpy.data.objects API that the model might might have. (unassigned bones, unweighted vertices, mesh objects that have too many vertices/bones)
My programming background (what little I have) is VBA for Office and I'm use to throwing stuff I want to grab into a temporary spreadsheet or a database Table and search those via SQL. I destroy them after I get what I need.
I'm finding the concept of lists, dictionaries, and sets difficult to comprehend (this one can have duplicates, this one can't, you can change stuff that one but not this one and I don't even want to get into list comprehension, I'm not there yet.) I have not had any luck with 2/3 dimensional arrays (which I think would solve my problem completely.), everything I've tried ends up in either a syntax or indentation error. Also, because I want to do total model summaries as well as print individual elements for each mesh, I'm finding that I have to repeat steps over and over again. (I'm not at the defining Classes and Functions stage yet.)
Situation: To mimic the environment I'm use to working in, I generating lists on the fly from strings to separate things I want to call against with a commands like:
mdlMesh =  for msh in object: if msh.type == 'MESH": mdlMesh.append(msh.name) # get the meshname if hasattrib(msh.vertex_groups): mdlVGrps.append(msh.vertex_groups) ... #'BSBound' # is returned as mdlMesh and it does have Vertex Groups ... # I want to dump the contexts mdlVGrps into a mesh specific list so I can ... # build the Model ... ... # Summary Report after getting all the data before I dig into Mesh specific reporting ...
if I manually type the command into the editor (I'll add this to code to the script later, I'm still experimenting with it):
>>>exec(str(mdlMesh) + "_VGrps = ") # I can create a list called BSBound_VGrps from the string >>>BSBound_VGrps # I type directly into the editor to check creation and existence  # and find the New blank list was created, it is declared and waiting to be populated
as these are going to be created on the fly throughout the script, I'll never know if a list is actually created or not or what name I have to access (without using a string) for the information I need.
Is there a way to create a list of (or print) the list names created by the script?
Is there a way to access\call the string generated lists and populate them using a string or will I have to use the exec command to rebuild the list name again with a try statement with and argument for the elements I want to add to the lists?
Problems: The generated lists are not named consistently or may not be created at all:
I'm looping through all the mesh objects in a model and creating a msh object, so the msh.name[x] in the msh.name attribute changes in each loop. I want to create a list for based each mesh object name to gather information so I'm creating them on the fly in each pass with the exe command based on the msh.name_attribute_being_pulled and adding the element of that attribute I need to the generated list name (ie "VGrps for msh.name[x].vertex_groups. = mshName_VGrps
However, the new list may not be created because there may not be data for the object attribute I'm trying to pull.
the mshName object may be exist but it doesn't a .vertex_groups attribute, so the exec(str(mshName[x]) + "_VGrps = ") command is skipped over in the code and the list for that attribute is not created.
check to see if they were actually created, populate if they exist and call on them for information with a string?
The list myMsh1_VGrps =  (and a bunch of others) have been created exec command. They are empty but I have no idea if any of them exists. How can I check for existents, populate and call information from them using strings in the code?
I can't hard code direct naming like:
if myMsh1_VGrps: # because this name is different in each pass of mesh objects for i in myMsh1_VGrps: ... else: ....
or use something like
myMsh1_VGrps = ["something", "or_something_else", "BECAUSE", "I_don't_know_if_this_REALLY_Exists"]
Any help would be appreciated. Thanks For reading!