I am a game design student and I’m currently learning how to script in Blender. I am writing a script that is supposed to filter objects based on name.
While doing research, I found out about select_pattern ().
When trying it out, it get an error I don’t fully understand. Since I am a beginner concerning scripting in Blender and programming in general, I lack the experience and knowledge to understand this error.
I started working on this in Blender 3.1.0 and now updated to Blender 3.1.2, it did not make a difference unfortunately.
I do not only get this error when I run the script, but also when I try it out via Blender’s own menu (Object mode → Select → Select Pattern)
Can someone help me understand what the problem is?
I think this might be outdated, I can’t find it in the most recent docs, and Blender python was completely re-done with the 3.0 release. Have you tried this in 2.8?
Indeed, it seems to work in 2.8.0. Does this mean that the reason for the error is that it is outdated and it cannot be used in newer versions of blender?
For my situation it would be best to use at least 3.0.0, so it’s quite an inconvenience in this case. Do you know if there are alternatives to select_pattern that work in the newer versions?
Hmmm ok… this new error makes me think the context for the operator is wrong, it’s expecting a string that defines an INVOKE or EXEC, which sounds like it doesn’t know how to execute the operator in the given context it’s odd, though, usually with that error it just tells you straight up “no context defined for operator”. Any chance you could DM me your full code? I’m not sure how to interpret this error without a bigger picture look
I just want to try out this function so this is the line I tried with just a cube. So next to the import bpy and the select pattern line, there is nothing
Hello! After some days of trying around I found a ‘solution’. When trying the select pattern function on itself, just like it is mentioned in the documentation, it ended up working fine.
I had tried to integrate the function into a UI panel, which was the point where the error was thrown. After some trying around it turned out to be a problem that I had named my class ‘SelectPattern’. Apparently this was a problem, because as soon as I had renamed the class and reinstalled Blender then, it worked fine. Unfortunately, it was necessary to reinstall Blender and delete all temp files for the error to go away. So in the end, it was a simple naming issue