Skip to content
Snippets Groups Projects
Commit b0502cd8 authored by Robert Meerman's avatar Robert Meerman Committed by Aaron Keith
Browse files

Preserve smoothing options when changing a bolt

Patch D10037

Prior to this patch the effect of applying the "Shade Smooth" object operator and the value of "Vertex > Auto Smooth" were lost when changing an existing bolt (via context-menu's "Change Bolt").

This patch preserves both.

A simple heuristic is used to detect if "Shade Smooth" has been used: the value of use_smooth of the first polygon in the mesh (prior to activating "Change Bolt"). Experiment has shown that "Shade Smooth" / "Shade Flat" are equivalent to setting use_smooth to True/False (respectively) on every polygon in the mesh.

(No heuristic is needed for Auto Smooth, as it is a top-level property of mesh data blocks)
parent 2fab0283
No related branches found
No related tags found
No related merge requests found
......@@ -416,6 +416,9 @@ class add_mesh_bolt(Operator, AddObjectHelper):
(context.active_object.data is not None) and ('Bolt' in context.active_object.data.keys()) and \
(self.change == True):
obj = context.active_object
use_auto_smooth = bool(obj.data.use_auto_smooth) # Copy value, do not take a reference
use_smooth = bool(obj.data.polygons[0].use_smooth) # Copy value, do not take a reference
mesh = createMesh.Create_New_Mesh(self, context)
# Modify existing mesh data object by replacing geometry (but leaving materials etc)
......@@ -424,6 +427,11 @@ class add_mesh_bolt(Operator, AddObjectHelper):
bm.to_mesh(obj.data)
bm.free()
# Preserve flat/smooth choice. New mesh is flat by default
obj.data.use_auto_smooth = use_auto_smooth
if use_smooth:
bpy.ops.object.shade_smooth()
bpy.data.meshes.remove(mesh)
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment