https://github.com/TeaCrab/0Tea_deCypher_Kit/tree/test
I’m working on this addon. I’m implementing a filter/search function for the menu generator.
If you try the addon and go to bpy.ops.mesh, the filter/search menu will show, and what I’m asking here is a part of the problem I’m having when implementing this feature.
Now, there were a different approach I used before that worked, but the order of the results are bad. If you look at the code, you will find a few global variable.
One called ‘subject’ and the other is called ‘subject_filtered’.
The subject is the pointer to any attribute that could be in any module.
The subject_filtered is a list that is used to contain any filtered pointers to all attributes that’s inside the subject.
The old method I used is to generate a menu from the subject_filtered. As I’ve said, it doesn’t give me a good ordered result, and I haven’t found a good way to sort it.
The new method I’m using is to generate a menu from the original subject, the loop looks like this:
for item in dir(subject):
if getattr(subject, item) in subject_filtered:
# generates menu
Which, the problem I described above happens, causing the menu to display nothing. Because none of this check returns true even though it gives me the same thing when I typed such command in the pyConsole in blender.
#Note:
Everything is doing what they are supposed to do exactly when I debugged. Except the identity check… That part is definitely doing something I don’t quite understand yet.
Forgive me if it’s something stupid… I’ve only started coding not long ago.
#Note2:
I walked around the issue by moving the condition check into the menu generation directly. Now instead of getting a list of filtered items, I don’t need the list at all. The menu generator now checks if there is any filter condition and show/hide the filtered items at the time of generation.