* OBJ exporter almost converted

* added MeshEdge.loose property
* changed mask used in Object.create_*_mesh to CD_MASK_MESH.
This commit is contained in:
Arystanbek Dyussenov 2009-06-26 12:33:07 +00:00
parent 18e7ec8463
commit acb590e4b0
3 changed files with 135 additions and 363 deletions

@ -47,7 +47,7 @@ will be exported as mesh data.
import bpy
import BPySys
# import BPySys
# import Blender
# from Blender import Mesh, Scene, Window, sys, Image, Draw
@ -75,16 +75,20 @@ def fixName(name):
# (material.name, image.name):matname_imagename # matname_imagename has gaps removed.
MTL_DICT = {}
def write_mtl(filename):
world = Blender.World.GetCurrent()
if world:
worldAmb = world.getAmb()
else:
worldAmb = (0,0,0) # Default value
def write_mtl(scene, filename):
world = bpy.data.worlds[0]
worldAmb = world.ambient_color
# world = Blender.World.GetCurrent()
# if world:
# worldAmb = world.getAmb()
# else:
# worldAmb = (0,0,0) # Default value
file = open(filename, "w")
file.write('# Blender3D MTL File: %s\n' % Blender.Get('filename').split('\\')[-1].split('/')[-1])
# XXX
# file.write('# Blender3D MTL File: %s\n' % Blender.Get('filename').split('\\')[-1].split('/')[-1])
file.write('# Material Count: %i\n' % len(MTL_DICT))
# Write material/image combinations we have used.
for key, (mtl_mat_name, mat, img) in MTL_DICT.iteritems():
@ -261,7 +265,7 @@ def write_nurb(file, ob, ob_mat):
return tot_verts
def write(filename, objects,\
def write(filename, objects, scene, \
EXPORT_TRI=False, EXPORT_EDGES=False, EXPORT_NORMALS=False, EXPORT_NORMALS_HQ=False,\
EXPORT_UV=True, EXPORT_MTL=True, EXPORT_COPY_IMAGES=False,\
EXPORT_APPLY_MODIFIERS=True, EXPORT_ROTX90=True, EXPORT_BLEN_OBS=True,\
@ -290,8 +294,10 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
of vertices is the face's group
"""
weightDict = {}
for vert in face:
vWeights = vWeightMap[vert.index]
for vert_index in face.verts:
# for vert in face:
vWeights = vWeightMap[vert_index]
# vWeights = vWeightMap[vert]
for vGroupName, weight in vWeights:
weightDict[vGroupName] = weightDict.get(vGroupName, 0) + weight
@ -302,6 +308,17 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
else:
return '(null)'
# TODO: implement this in C? dunno how it should be called...
def getVertsFromGroup(me, group_index):
ret = []
for i, v in enumerate(me.verts):
for g in v.groups:
if g.group == group.index:
ret.append((i, g.weight))
return ret
print 'OBJ Export path: "%s"' % filename
temp_mesh_name = '~tmp-mesh'
@ -349,6 +366,7 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
globalNormals = {}
# Get all meshes
for ob_main in objects:
if ob_main.dupli_type != 'NONE':
@ -375,22 +393,25 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
# continue
# end nurbs
if ob.type != 'MESH':
continue
# XXX EXPORT_APPLY_MODIFIERS is not used (always true)
# we also need influences to be copied... for EXPORT_POLYGROUPS to work
# which create_preview_mesh presumably does (CD_MASK_MDEFORMVERT flag)
me = ob.create_preview_mesh()
# # Will work for non meshes now! :)
# me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, EXPORT_POLYGROUPS, scn)
# if not me:
# continue
if ob.type != 'MESH':
continue
if EXPORT_UV:
faceuv = len(me.uv_layers) > 0
else:
faceuv = False
me = ob.create_render_mesh()
# We have a valid mesh
if EXPORT_TRI and me.faces:
# Add a dummy object to it.
@ -598,19 +619,21 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
# XXX
if EXPORT_POLYGROUPS:
# Retrieve the list of vertex groups
vertGroupNames = [g.name for g in ob.vertex_groups]
# vertGroupNames = me.getVertGroupNames()
currentVGroup = ''
# Create a dictionary keyed by face id and listing, for each vertex, the vertex groups it belongs to
vgroupsMap = [[] for _i in range(len(me.verts))]
# vgroupsMap = [[] for _i in xrange(len(me.verts))]
for vertexGroupName in vertGroupNames:
for vIdx, vWeight in me.getVertsFromGroup(vertexGroupName, 1):
vgroupsMap[vIdx].append((vertexGroupName, vWeight))
for g in ob.vertex_groups:
# for vertexGroupName in vertGroupNames:
for vIdx, vWeight in getVertsFromGroup(me, g.index)
# for vIdx, vWeight in me.getVertsFromGroup(vertexGroupName, 1):
vgroupsMap[vIdx].append((g.name, vWeight))
for f_index, f in enumerate(faces):
f_v= f.v
f_v = [{"index": index, "vertex": me.verts[index]} for index in f.verts]
# f_v= f.v
f_smooth= f.smooth
f_mat = min(f.material_index, len(materialNames)-1)
# f_mat = min(f.mat, len(materialNames)-1)
@ -632,6 +655,14 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
key = materialNames[f_mat], None # No image, use None instead.
# XXX
# Write the vertex group
if EXPORT_POLYGROUPS:
if len(ob.vertex_groups):
# find what vertext group the face belongs to
theVGroup = findVertexGroupName(f,vgroupsMap)
if theVGroup != currentVGroup:
currentVGroup = theVGroup
file.write('g %s\n' % theVGroup)
# # Write the vertex group
# if EXPORT_POLYGROUPS:
# if vertGroupNames:
@ -648,7 +679,9 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
if key[0] == None and key[1] == None:
# Write a null material, since we know the context has changed.
if EXPORT_GROUP_BY_MAT:
file.write('g %s_%s\n' % (fixName(ob.name), fixName(ob.getData(1))) ) # can be mat_image or (null)
# can be mat_image or (null)
file.write('g %s_%s\n' % (fixName(ob.name), fixName(ob.data.name)) )
# file.write('g %s_%s\n' % (fixName(ob.name), fixName(ob.getData(1))) ) # can be mat_image or (null)
file.write('usemtl (null)\n') # mat, image
else:
@ -667,7 +700,8 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
mat_data = MTL_DICT[key] = ('%s_%s' % (fixName(key[0]), fixName(key[1]))), materialItems[f_mat], f_image
if EXPORT_GROUP_BY_MAT:
file.write('g %s_%s_%s\n' % (fixName(ob.name), fixName(ob.getData(1)), mat_data[0]) ) # can be mat_image or (null)
file.write('g %s_%s_%s\n' % (fixName(ob.name), fixName(ob.data.name), mat_data[0]) ) # can be mat_image or (null)
# file.write('g %s_%s_%s\n' % (fixName(ob.name), fixName(ob.getData(1)), mat_data[0]) ) # can be mat_image or (null)
file.write('usemtl %s\n' % mat_data[0]) # can be mat_image or (null)
@ -685,24 +719,36 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
if EXPORT_NORMALS:
if f_smooth: # Smoothed, use vertex normals
for vi, v in enumerate(f_v):
file.write( ' %d/%d/%d' % (\
v.index+totverts,\
totuvco + uv_face_mapping[f_index][vi],\
globalNormals[ veckey3d(v.no) ])) # vert, uv, normal
file.write( ' %d/%d/%d' % \
(v["index"] + totverts,
totuvco + uv_face_mapping[f_index][vi],
globalNormals[ veckey3d(v["vertex"].normal) ]) ) # vert, uv, normal
# file.write( ' %d/%d/%d' % (\
# v.index+totverts,\
# totuvco + uv_face_mapping[f_index][vi],\
# globalNormals[ veckey3d(v.no) ])) # vert, uv, normal
else: # No smoothing, face normals
no = globalNormals[ veckey3d(f.no) ]
no = globalNormals[ veckey3d(f.normal) ]
# no = globalNormals[ veckey3d(f.no) ]
for vi, v in enumerate(f_v):
file.write( ' %d/%d/%d' % (\
v.index+totverts,\
totuvco + uv_face_mapping[f_index][vi],\
no)) # vert, uv, normal
file.write( ' %d/%d/%d' % \
(v["index"] + totverts,
totuvco + uv_face_mapping[f_index][vi],
no) ) # vert, uv, normal
# file.write( ' %d/%d/%d' % (\
# v.index+totverts,\
# totuvco + uv_face_mapping[f_index][vi],\
# no)) # vert, uv, normal
else: # No Normals
for vi, v in enumerate(f_v):
file.write( ' %d/%d' % (\
v.index+totverts,\
v["index"] + totverts,\
totuvco + uv_face_mapping[f_index][vi])) # vert, uv
# file.write( ' %d/%d' % (\
# v.index+totverts,\
# totuvco + uv_face_mapping[f_index][vi])) # vert, uv
face_vert_index += len(f_v)
@ -710,344 +756,56 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
if EXPORT_NORMALS:
if f_smooth: # Smoothed, use vertex normals
for v in f_v:
file.write( ' %d//%d' % (\
v.index+totverts,\
globalNormals[ veckey3d(v.no) ]))
file.write( ' %d//%d' %
(v["index"] + totverts, globalNormals[ veckey3d(v["vertex"].normal) ]) )
# file.write( ' %d//%d' % (\
# v.index+totverts,\
# globalNormals[ veckey3d(v.no) ]))
else: # No smoothing, face normals
no = globalNormals[ veckey3d(f.no) ]
no = globalNormals[ veckey3d(f.normal) ]
# no = globalNormals[ veckey3d(f.no) ]
for v in f_v:
file.write( ' %d//%d' % (\
v.index+totverts,\
no))
file.write( ' %d//%d' % (v["index"] + totverts, no) )
# file.write( ' %d//%d' % (\
# v.index+totverts,\
# no))
else: # No Normals
for v in f_v:
file.write( ' %d' % (\
v.index+totverts))
file.write( ' %d' % (v["index"] + totverts) )
# file.write( ' %d' % (\
# v.index+totverts))
file.write('\n')
# Write edges.
if EXPORT_EDGES:
LOOSE= Mesh.EdgeFlags.LOOSE
for ed in edges:
if ed.flag & LOOSE:
file.write('f %d %d\n' % (ed.v1.index+totverts, ed.v2.index+totverts))
if ed.loose:
file.write('f %d %d\n' % (ed.verts[0] + totverts, ed.verts[1] + totverts))
# LOOSE= Mesh.EdgeFlags.LOOSE
# for ed in edges:
# if ed.flag & LOOSE:
# file.write('f %d %d\n' % (ed.v1.index+totverts, ed.v2.index+totverts))
# Make the indicies global rather then per mesh
totverts += len(me.verts)
if faceuv:
totuvco += uv_unique_count
me.verts= None
# clean up
bpy.data.remove_mesh(me)
# me.verts= None
if ob_main.dupli_type != 'NONE':
ob_main.free_dupli_list()
# Get all meshes
for ob_main in objects:
for ob, ob_mat in BPyObject.getDerivedObjects(ob_main):
# Nurbs curve support
if EXPORT_CURVE_AS_NURBS and test_nurbs_compat(ob):
if EXPORT_ROTX90:
ob_mat = ob_mat * mat_xrot90
totverts += write_nurb(file, ob, ob_mat)
continue
# end nurbs
# Will work for non meshes now! :)
# getMeshFromObject(ob, container_mesh=None, apply_modifiers=True, vgroups=True, scn=None)
me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, EXPORT_POLYGROUPS, scn)
if not me:
continue
if EXPORT_UV:
faceuv= me.faceUV
else:
faceuv = False
# We have a valid mesh
if EXPORT_TRI and me.faces:
# Add a dummy object to it.
has_quads = False
for f in me.faces:
if len(f) == 4:
has_quads = True
break
if has_quads:
oldmode = Mesh.Mode()
Mesh.Mode(Mesh.SelectModes['FACE'])
me.sel = True
tempob = scn.objects.new(me)
me.quadToTriangle(0) # more=0 shortest length
oldmode = Mesh.Mode(oldmode)
scn.objects.unlink(tempob)
Mesh.Mode(oldmode)
# Make our own list so it can be sorted to reduce context switching
faces = [ f for f in me.faces ]
if EXPORT_EDGES:
edges = me.edges
else:
edges = []
if not (len(faces)+len(edges)+len(me.verts)): # Make sure there is somthing to write
continue # dont bother with this mesh.
if EXPORT_ROTX90:
me.transform(ob_mat*mat_xrot90)
else:
me.transform(ob_mat)
# High Quality Normals
if EXPORT_NORMALS and faces:
if EXPORT_NORMALS_HQ:
BPyMesh.meshCalcNormals(me)
else:
# transforming normals is incorrect
# when the matrix is scaled,
# better to recalculate them
me.calcNormals()
# # Crash Blender
#materials = me.getMaterials(1) # 1 == will return None in the list.
materials = me.materials
materialNames = []
materialItems = materials[:]
if materials:
for mat in materials:
if mat: # !=None
materialNames.append(mat.name)
else:
materialNames.append(None)
# Cant use LC because some materials are None.
# materialNames = map(lambda mat: mat.name, materials) # Bug Blender, dosent account for null materials, still broken.
# Possible there null materials, will mess up indicies
# but at least it will export, wait until Blender gets fixed.
materialNames.extend((16-len(materialNames)) * [None])
materialItems.extend((16-len(materialItems)) * [None])
# Sort by Material, then images
# so we dont over context switch in the obj file.
if EXPORT_KEEP_VERT_ORDER:
pass
elif faceuv:
try: faces.sort(key = lambda a: (a.mat, a.image, a.smooth))
except: faces.sort(lambda a,b: cmp((a.mat, a.image, a.smooth), (b.mat, b.image, b.smooth)))
elif len(materials) > 1:
try: faces.sort(key = lambda a: (a.mat, a.smooth))
except: faces.sort(lambda a,b: cmp((a.mat, a.smooth), (b.mat, b.smooth)))
else:
# no materials
try: faces.sort(key = lambda a: a.smooth)
except: faces.sort(lambda a,b: cmp(a.smooth, b.smooth))
# Set the default mat to no material and no image.
contextMat = (0, 0) # Can never be this, so we will label a new material teh first chance we get.
contextSmooth = None # Will either be true or false, set bad to force initialization switch.
if EXPORT_BLEN_OBS or EXPORT_GROUP_BY_OB:
name1 = ob.name
name2 = ob.getData(1)
if name1 == name2:
obnamestring = fixName(name1)
else:
obnamestring = '%s_%s' % (fixName(name1), fixName(name2))
if EXPORT_BLEN_OBS:
file.write('o %s\n' % obnamestring) # Write Object name
else: # if EXPORT_GROUP_BY_OB:
file.write('g %s\n' % obnamestring)
# Vert
for v in me.verts:
file.write('v %.6f %.6f %.6f\n' % tuple(v.co))
# UV
if faceuv:
uv_face_mapping = [[0,0,0,0] for f in faces] # a bit of a waste for tri's :/
uv_dict = {} # could use a set() here
for f_index, f in enumerate(faces):
for uv_index, uv in enumerate(f.uv):
uvkey = veckey2d(uv)
try:
uv_face_mapping[f_index][uv_index] = uv_dict[uvkey]
except:
uv_face_mapping[f_index][uv_index] = uv_dict[uvkey] = len(uv_dict)
file.write('vt %.6f %.6f\n' % tuple(uv))
uv_unique_count = len(uv_dict)
del uv, uvkey, uv_dict, f_index, uv_index
# Only need uv_unique_count and uv_face_mapping
# NORMAL, Smooth/Non smoothed.
if EXPORT_NORMALS:
for f in faces:
if f.smooth:
for v in f:
noKey = veckey3d(v.no)
if not globalNormals.has_key( noKey ):
globalNormals[noKey] = totno
totno +=1
file.write('vn %.6f %.6f %.6f\n' % noKey)
else:
# Hard, 1 normal from the face.
noKey = veckey3d(f.no)
if not globalNormals.has_key( noKey ):
globalNormals[noKey] = totno
totno +=1
file.write('vn %.6f %.6f %.6f\n' % noKey)
if not faceuv:
f_image = None
if EXPORT_POLYGROUPS:
# Retrieve the list of vertex groups
vertGroupNames = me.getVertGroupNames()
currentVGroup = ''
# Create a dictionary keyed by face id and listing, for each vertex, the vertex groups it belongs to
vgroupsMap = [[] for _i in xrange(len(me.verts))]
for vertexGroupName in vertGroupNames:
for vIdx, vWeight in me.getVertsFromGroup(vertexGroupName, 1):
vgroupsMap[vIdx].append((vertexGroupName, vWeight))
for f_index, f in enumerate(faces):
f_v= f.v
f_smooth= f.smooth
f_mat = min(f.mat, len(materialNames)-1)
if faceuv:
f_image = f.image
f_uv= f.uv
# MAKE KEY
if faceuv and f_image: # Object is always true.
key = materialNames[f_mat], f_image.name
else:
key = materialNames[f_mat], None # No image, use None instead.
# Write the vertex group
if EXPORT_POLYGROUPS:
if vertGroupNames:
# find what vertext group the face belongs to
theVGroup = findVertexGroupName(f,vgroupsMap)
if theVGroup != currentVGroup:
currentVGroup = theVGroup
file.write('g %s\n' % theVGroup)
# CHECK FOR CONTEXT SWITCH
if key == contextMat:
pass # Context alredy switched, dont do anything
else:
if key[0] == None and key[1] == None:
# Write a null material, since we know the context has changed.
if EXPORT_GROUP_BY_MAT:
file.write('g %s_%s\n' % (fixName(ob.name), fixName(ob.getData(1))) ) # can be mat_image or (null)
file.write('usemtl (null)\n') # mat, image
else:
mat_data= MTL_DICT.get(key)
if not mat_data:
# First add to global dict so we can export to mtl
# Then write mtl
# Make a new names from the mat and image name,
# converting any spaces to underscores with fixName.
# If none image dont bother adding it to the name
if key[1] == None:
mat_data = MTL_DICT[key] = ('%s'%fixName(key[0])), materialItems[f_mat], f_image
else:
mat_data = MTL_DICT[key] = ('%s_%s' % (fixName(key[0]), fixName(key[1]))), materialItems[f_mat], f_image
if EXPORT_GROUP_BY_MAT:
file.write('g %s_%s_%s\n' % (fixName(ob.name), fixName(ob.getData(1)), mat_data[0]) ) # can be mat_image or (null)
file.write('usemtl %s\n' % mat_data[0]) # can be mat_image or (null)
contextMat = key
if f_smooth != contextSmooth:
if f_smooth: # on now off
file.write('s 1\n')
contextSmooth = f_smooth
else: # was off now on
file.write('s off\n')
contextSmooth = f_smooth
file.write('f')
if faceuv:
if EXPORT_NORMALS:
if f_smooth: # Smoothed, use vertex normals
for vi, v in enumerate(f_v):
file.write( ' %d/%d/%d' % (\
v.index+totverts,\
totuvco + uv_face_mapping[f_index][vi],\
globalNormals[ veckey3d(v.no) ])) # vert, uv, normal
else: # No smoothing, face normals
no = globalNormals[ veckey3d(f.no) ]
for vi, v in enumerate(f_v):
file.write( ' %d/%d/%d' % (\
v.index+totverts,\
totuvco + uv_face_mapping[f_index][vi],\
no)) # vert, uv, normal
else: # No Normals
for vi, v in enumerate(f_v):
file.write( ' %d/%d' % (\
v.index+totverts,\
totuvco + uv_face_mapping[f_index][vi])) # vert, uv
face_vert_index += len(f_v)
else: # No UV's
if EXPORT_NORMALS:
if f_smooth: # Smoothed, use vertex normals
for v in f_v:
file.write( ' %d//%d' % (\
v.index+totverts,\
globalNormals[ veckey3d(v.no) ]))
else: # No smoothing, face normals
no = globalNormals[ veckey3d(f.no) ]
for v in f_v:
file.write( ' %d//%d' % (\
v.index+totverts,\
no))
else: # No Normals
for v in f_v:
file.write( ' %d' % (\
v.index+totverts))
file.write('\n')
# Write edges.
if EXPORT_EDGES:
LOOSE= Mesh.EdgeFlags.LOOSE
for ed in edges:
if ed.flag & LOOSE:
file.write('f %d %d\n' % (ed.v1.index+totverts, ed.v2.index+totverts))
# Make the indicies global rather then per mesh
totverts += len(me.verts)
if faceuv:
totuvco += uv_unique_count
me.verts= None
file.close()
# Now we have all our materials, save them
if EXPORT_MTL:
write_mtl(mtlfilename)
write_mtl(scene, mtlfilename)
if EXPORT_COPY_IMAGES:
dest_dir = filename
# Remove chars until we are just the path.
@ -1332,8 +1090,8 @@ def write_ui(filename):
def do_export(filename, context):
# Window.EditMode(0)
# Window.WaitCursor(1)
# Window.EditMode(0)
# Window.WaitCursor(1)
EXPORT_APPLY_MODIFIERS = True
EXPORT_ROTX90 = True
@ -1351,6 +1109,8 @@ def do_export(filename, context):
EXPORT_GROUP_BY_OB = False
EXPORT_GROUP_BY_MAT = False
EXPORT_KEEP_VERT_ORDER = False
EXPORT_POLYGROUPS = False
EXPORT_CURVE_AS_NURBS = True
base_name, ext = splitExt(filename)
context_name = [base_name, '', '', ext] # Base name, scene name, frame number, extension
@ -1370,8 +1130,8 @@ def do_export(filename, context):
# Export all scenes.
for scn in export_scenes:
# scn.makeCurrent() # If already current, this is not slow.
# context = scn.getRenderingContext()
# scn.makeCurrent() # If already current, this is not slow.
# context = scn.getRenderingContext()
orig_frame = scn.current_frame
if EXPORT_ALL_SCENES: # Add scene name into the context_name
@ -1398,12 +1158,14 @@ def do_export(filename, context):
# erm... bit of a problem here, this can overwrite files when exporting frames. not too bad.
# EXPORT THE FILE.
# write(full_path, export_objects,
# EXPORT_TRI, EXPORT_EDGES, EXPORT_NORMALS,
# EXPORT_NORMALS_HQ, EXPORT_UV, EXPORT_MTL,
# EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,
# EXPORT_ROTX90, EXPORT_BLEN_OBS,
# EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER)
write(full_path, export_objects, scn,
EXPORT_TRI, EXPORT_EDGES, EXPORT_NORMALS,
EXPORT_NORMALS_HQ, EXPORT_UV, EXPORT_MTL,
EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,
EXPORT_ROTX90, EXPORT_BLEN_OBS,
EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,
EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS)
scn.current_frame = orig_frame
@ -1412,11 +1174,14 @@ def do_export(filename, context):
# Window.WaitCursor(0)
class SCRIPT_OT_export_obj(bpy.types.Operator):
class EXPORT_OT_obj(bpy.types.Operator):
'''
Operator documentatuon text, will be used for the operator tooltip and python docs.
Currently the exporter lacks these features:
* nurbs
* multiple scene export (only active scene is written)
* particles
'''
__label__ = 'My Operator'
__label__ = 'Export OBJ'
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.

@ -736,6 +736,11 @@ static void rna_def_medge(BlenderRNA *brna)
prop= RNA_def_property(srna, "sharp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SHARP);
RNA_def_property_ui_text(prop, "Sharp", "Sharp edge for the EdgeSplit modifier");
prop= RNA_def_property(srna, "loose", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_LOOSEEDGE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Loose", "Loose edge");
}
static void rna_def_mface(BlenderRNA *brna)

@ -57,7 +57,9 @@
/* copied from init_render_mesh (render code) */
static Mesh *create_mesh(Object *ob, bContext *C, ReportList *reports, int render_mesh)
{
CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL;
/* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
for example, needs CD_MASK_MDEFORMVERT */
DerivedMesh *dm;
Mesh *me;
Scene *sce;