I am having trouble with a script I’m working on. It is a menu script. I have an “if” statement that checks whether or not the active objects shade is flat, if it is, it will give the user the option to change it to smooth.
when I run the script, it gives me the error saying that “object has no attribute shade_flat”. I am pretty new to python, though I know some c++ and some c#.
Thanks for replying so quick. I attempted to change my code to match what you put, but I could not get it to work. The first part you put is hard for me to understand, but I tried putting it in. I used that line of code, and told it to check if it was false.; but I got an error message. If I remove the false check, the script will run with no errors or warning, but no smooth option will appear.
if bpy.context.object.data.polygons[0].use_smooth = False:
self.operator("object.shade_smooth")
I will keep digging around and see if I can figure it out, if I do, I will post back.
With if you should use ==, not = (thats only for assigning variables). In python if you dont put a == it takes it as True, 0, empty array etc.
So just change that and it will work.