Skip to content

Instantly share code, notes, and snippets.

@lowteq
Last active February 20, 2020 03:22
Show Gist options
  • Save lowteq/012dbe45d2177bd99fb29626cf2de457 to your computer and use it in GitHub Desktop.
Save lowteq/012dbe45d2177bd99fb29626cf2de457 to your computer and use it in GitHub Desktop.
blender2.7x curveをmirror適用
import bpy
def axislist(axisbool):
r = []
for i in range(len(axisbool)):
l = [False,False,False]
if axisbool[i]:
l[i] = True
r.append(l)
return r
bpy.ops.object.mode_set(mode="OBJECT")
origobj = bpy.context.selected_objects[0]
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects[origobj.name].select = True
if bpy.context.object.modifiers["Mirror"] != None and origobj.type =="CURVE":
use_axis = [False,False,False]
use_axis[0] = bpy.context.object.modifiers["Mirror"].use_x
use_axis[1] = bpy.context.object.modifiers["Mirror"].use_y
use_axis[2] = bpy.context.object.modifiers["Mirror"].use_z
bpy.ops.object.modifier_remove(modifier="Mirror")
al = axislist(use_axis)
sobjname = set([])
sobjname.add(origobj.name)
for u in al:
for s in sobjname:
bpy.data.objects[s].select = True
bpy.ops.object.duplicate(linked=False, mode='TRANSLATION')
bpy.ops.transform.mirror(constraint_axis=(u[0], u[1], u[2]), constraint_orientation='LOCAL')
for v in bpy.context.selected_objects:
sobjname.add(v.name)
print("=====")
for s in sobjname:
bpy.data.objects[s].select = True
print(s)
bpy.ops.object.join()
bpy.ops.object.select_all(action='DESELECT')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment