From b4a92f139628b421c711d64e7f2f31b6687c3017 Mon Sep 17 00:00:00 2001
From: Dalai Felinto <dfelinto@gmail.com>
Date: Fri, 19 Jan 2018 10:53:31 -0200
Subject: [PATCH] Fix object importer in blender 2.8

---
 io_scene_obj/__init__.py   |  2 +-
 io_scene_obj/import_obj.py | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index d15a6cc7a..e5165c3b8 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -139,7 +139,7 @@ class ImportOBJ(bpy.types.Operator, ImportHelper, IOOBJOrientationHelper):
                                         from_up=self.axis_up,
                                         ).to_4x4()
         keywords["global_matrix"] = global_matrix
-        keywords["use_cycles"] = (context.scene.render.engine == 'CYCLES')
+        keywords["use_cycles"] = (context.scene.view_render.engine == 'CYCLES')
 
         if bpy.data.is_saved and context.user_preferences.filepaths.use_relative_paths:
             import os
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index c120e540a..7ca221608 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -1294,10 +1294,17 @@ def load(context,
         for context_nurbs in nurbs:
             create_nurbs(context_nurbs, verts_loc, new_objects)
 
+        view_layer = context.view_layer
+        if view_layer.collections.active:
+            collection = view_layer.collections.active.collection
+        else:
+            collection = scene.master_collection.new()
+            view_layer.collections.link(collection)
+
         # Create new obj
         for obj in new_objects:
-            base = scene.objects.link(obj)
-            base.select = True
+            collection.objects.link(obj)
+            obj.select_set('SELECT')
 
             # we could apply this anywhere before scaling.
             obj.matrix_world = global_matrix
-- 
GitLab