I was setting up a validation that checked if all the required material texture slots were used. I was getting lost in the sauce. I was collecting the object’s materials, then looping through the submaterial, then looping for the texture slots, then looping through the slot names, then loop again . After a while, I was just staring at my code, confused, lost, and afraid.

I thought to myself, there had to be a better way. I entered the old mind palace for a bit. I looked around for a bit, and uncovered an old dusty box that read classes. Classes are something that I learned in many online tutorials. I was told how important they were to organizing code and object oriented programming. I’ve only created simple helper python scripts ,so they never required something like classes. So I decided to change that.

I started by creating a Material class. Anything that was related to materials I stuffed in that class. There were still a lot of loops, don’t get me wrong. But they were manageable because instead of looping through endless lists, I could work with objects. I could create material objects from the nodes in the scene. Then I could  loop through the materials and get their properties to work with. Working with my own objects transformed confusion into clarity.

Going forward, I’m going to integrate classes more into my process. Off the bat, I’m creating a SceneObject class. I created a bunch of helper functions such as centering the pivot or getting its transforms. These helpers are floating around in my code. So I’m going to round them up and stuff them in the ScenObject class. Also, I learned something about an iterator called a chain. So I’m going to figure that out.

category =