Skip to content

Commit

Permalink
Fix T50453: Add option to OBJ export to apply render or preview modif…
Browse files Browse the repository at this point in the history
…iers.
  • Loading branch information
Bastien Montagne committed Jan 17, 2017
1 parent 18099be commit a746a84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions io_scene_obj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
"version": (2, 3, 1),
"version": (2, 3, 2),
"blender": (2, 77, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
Expand Down Expand Up @@ -201,9 +201,14 @@ class ExportOBJ(bpy.types.Operator, ExportHelper, IOOBJOrientationHelper):
# object group
use_mesh_modifiers = BoolProperty(
name="Apply Modifiers",
description="Apply modifiers (preview resolution)",
description="Apply modifiers",
default=True,
)
use_mesh_modifiers_render = BoolProperty(
name="Use Modifiers Render Settings",
description="Use render settings when applying modifiers to mesh objects",
default=False,
)

# extra data group
use_edges = BoolProperty(
Expand Down
8 changes: 7 additions & 1 deletion io_scene_obj/export_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def write_file(filepath, objects, scene,
EXPORT_UV=True,
EXPORT_MTL=True,
EXPORT_APPLY_MODIFIERS=True,
EXPORT_APPLY_MODIFIERS_RENDER=False,
EXPORT_BLEN_OBS=True,
EXPORT_GROUP_BY_OB=False,
EXPORT_GROUP_BY_MAT=False,
Expand Down Expand Up @@ -387,7 +388,8 @@ def findVertexGroupName(face, vWeightMap):
# END NURBS

try:
me = ob.to_mesh(scene, EXPORT_APPLY_MODIFIERS, 'PREVIEW', calc_tessface=False)
me = ob.to_mesh(scene, EXPORT_APPLY_MODIFIERS, calc_tessface=False,
settings='RENDER' if EXPORT_APPLY_MODIFIERS_RENDER else 'PREVIEW')
except RuntimeError:
me = None

Expand Down Expand Up @@ -720,6 +722,7 @@ def _write(context, filepath,
EXPORT_UV, # ok
EXPORT_MTL,
EXPORT_APPLY_MODIFIERS, # ok
EXPORT_APPLY_MODIFIERS_RENDER, # ok
EXPORT_BLEN_OBS,
EXPORT_GROUP_BY_OB,
EXPORT_GROUP_BY_MAT,
Expand Down Expand Up @@ -776,6 +779,7 @@ def _write(context, filepath,
EXPORT_UV,
EXPORT_MTL,
EXPORT_APPLY_MODIFIERS,
EXPORT_APPLY_MODIFIERS_RENDER,
EXPORT_BLEN_OBS,
EXPORT_GROUP_BY_OB,
EXPORT_GROUP_BY_MAT,
Expand Down Expand Up @@ -810,6 +814,7 @@ def save(context,
use_uvs=True,
use_materials=True,
use_mesh_modifiers=True,
use_mesh_modifiers_render=False,
use_blen_objects=True,
group_by_object=False,
group_by_material=False,
Expand All @@ -831,6 +836,7 @@ def save(context,
EXPORT_UV=use_uvs,
EXPORT_MTL=use_materials,
EXPORT_APPLY_MODIFIERS=use_mesh_modifiers,
EXPORT_APPLY_MODIFIERS_RENDER=use_mesh_modifiers_render,
EXPORT_BLEN_OBS=use_blen_objects,
EXPORT_GROUP_BY_OB=group_by_object,
EXPORT_GROUP_BY_MAT=group_by_material,
Expand Down

0 comments on commit a746a84

Please sign in to comment.