I'm working up to building a small script which will allow me to import and render 2D views of several OBJ models, but I'm struggling at the moment with the very basic first step, which is importing a model from a folder on my computer. I attempted to follow the code in the script in a somewhat related question, but even if I directly copy-paste the code and just change the directory path to where my model is located, when I press Run Script, nothing happens. I don't see any errors, I don't see anything happen, just nothing. I'm fairly new to both Blender and Blender scripting, so I'm not very sure what's going on and any help would be appreciated!
This is my code at the moment (copied and pasted from the link above, but modified to have a Linux file path):
import bpy import os import glob # Model directory model_dir = '/home/yuerno/Downloads/test' # Specify OBJ files model_files = glob.glob(model_dir + "*.obj") for f in model_files: head, tail = os.path.split(f) collection_name = tail.replace('.obj', '') bpy.ops.import_scene.obj(filepath=f) myCol = bpy.data.collections.new(collection_name) bpy.context.scene.collection.children.link(myCol) for ob in bpy.context.selected_objects: myCol.objects.link(ob)