Skip to content

Commit

Permalink
Use separate OBJ import parameters for 2.92 and later (#125) (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
neverhood311 committed Mar 3, 2021
1 parent 7eec59d commit 4fd8bff
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/__init__.py
Expand Up @@ -25,7 +25,7 @@
"name": "Stop motion OBJ",
"description": "Import a sequence of OBJ (or STL or PLY) files and display them each as a single frame of animation. This add-on also supports the .STL and .PLY file formats.",
"author": "Justin Jensen",
"version": (2, 1, 0),
"version": (2, 1, 1),
"blender": (2, 80, 0),
"location": "File > Import > Mesh Sequence",
"warning": "",
Expand Down
4 changes: 2 additions & 2 deletions src/panels.py
Expand Up @@ -229,7 +229,7 @@ def copyImportSettings(self, source, dest):
dest.obj_use_groups_as_vgroups = source.obj_use_groups_as_vgroups
dest.obj_use_image_search = source.obj_use_image_search
dest.obj_split_mode = "OFF"
dest.obj_global_clight_size = source.obj_global_clight_size
dest.obj_global_clamp_size = source.obj_global_clamp_size
dest.stl_global_scale = source.stl_global_scale
dest.stl_use_scene_unit = source.stl_use_scene_unit
dest.stl_use_facet_normal = source.stl_use_facet_normal
Expand Down Expand Up @@ -268,7 +268,7 @@ def draw(self, context):
layout.prop(op.importSettings, 'obj_use_image_search')
layout.prop(op.importSettings, 'obj_use_smooth_groups')
layout.prop(op.importSettings, 'obj_use_edges')
layout.prop(op.importSettings, 'obj_global_clight_size')
layout.prop(op.importSettings, 'obj_global_clamp_size')

col = layout.column()
col.prop(op.importSettings, "obj_use_groups_as_vgroups")
Expand Down
44 changes: 30 additions & 14 deletions src/stop_motion_obj.py
@@ -1,7 +1,7 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# Stop motion OBJ: A Mesh sequence importer for Blender
# Copyright (C) 2016-2020 Justin Jensen
# Copyright (C) 2016-2021 Justin Jensen
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -195,7 +195,7 @@ class MeshImporter(bpy.types.PropertyGroup):
# ('OFF', "Keep Vert Order", "Keep vertex order from file")))
obj_use_groups_as_vgroups: bpy.props.BoolProperty(name="Poly Groups", description="Import OBJ groups as vertex groups", default=False)
obj_use_image_search: bpy.props.BoolProperty(name="Image Search", description="Search subdirs for any associated images (Warning: may be slow)", default=True)
obj_global_clight_size: bpy.props.FloatProperty(
obj_global_clamp_size: bpy.props.FloatProperty(
name="Clamp Size",
description="Clamp bounds under this value (zero to disable)",
min=0.0,
Expand Down Expand Up @@ -239,18 +239,34 @@ def load(self, fileType, filePath):

def loadOBJ(self, filePath):
# call the obj load function with all the correct parameters
bpy.ops.import_scene.obj(
filepath=filePath,
use_edges=self.obj_use_edges,
use_smooth_groups=self.obj_use_smooth_groups,
use_split_objects=False,
use_split_groups=False,
use_groups_as_vgroups=self.obj_use_groups_as_vgroups,
use_image_search=self.obj_use_image_search,
split_mode="OFF",
global_clight_size=self.obj_global_clight_size,
axis_forward=self.axis_forward,
axis_up=self.axis_up)
if bpy.app.version >= (2, 92, 0):
bpy.ops.import_scene.obj(
filepath=filePath,
use_edges=self.obj_use_edges,
use_smooth_groups=self.obj_use_smooth_groups,
use_split_objects=False,
use_split_groups=False,
use_groups_as_vgroups=self.obj_use_groups_as_vgroups,
use_image_search=self.obj_use_image_search,
split_mode="OFF",
global_clamp_size=self.obj_global_clamp_size,
axis_forward=self.axis_forward,
axis_up=self.axis_up)
else:
# Note the parameter called "global_clight_size", which is probably a typo
# It was corrected to "global_clamp_size" in Blender 2.92
bpy.ops.import_scene.obj(
filepath=filePath,
use_edges=self.obj_use_edges,
use_smooth_groups=self.obj_use_smooth_groups,
use_split_objects=False,
use_split_groups=False,
use_groups_as_vgroups=self.obj_use_groups_as_vgroups,
use_image_search=self.obj_use_image_search,
split_mode="OFF",
global_clight_size=self.obj_global_clamp_size,
axis_forward=self.axis_forward,
axis_up=self.axis_up)

def loadSTL(self, filePath):
# call the stl load function with all the correct parameters
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Expand Up @@ -2,5 +2,5 @@
# (major, minor, revision, development)
# example dev version: (1, 2, 3, "beta.4")
# example release version: (2, 3, 4)
currentScriptVersion = (2, 1, 0)
currentScriptVersion = (2, 1, 1)
legacyScriptVersion = (2, 0, 2, "legacy")

0 comments on commit 4fd8bff

Please sign in to comment.