[Bf-extensions-cvs] [b3125c1] master: Update: new tool import export vertex colors
Eugenio Pignataro
noreply at git.blender.org
Wed Feb 5 15:19:21 CET 2014
Commit: b3125c17f9a61d22cedce9fda6d162f9ac8241b6
Author: Eugenio Pignataro
Date: Wed Feb 5 11:18:57 2014 -0300
https://developer.blender.org/rBACb3125c17f9a61d22cedce9fda6d162f9ac8241b6
Update: new tool import export vertex colors
===================================================================
M oscurart_tools/__init__.py
M oscurart_tools/oscurart_meshes.py
===================================================================
diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py
index abd1223..1eb11e6 100644
--- a/oscurart_tools/__init__.py
+++ b/oscurart_tools/__init__.py
@@ -184,6 +184,9 @@ class OscPanelMesh(OscPollMesh, bpy.types.Panel):
colrow=col.row(align=1)
colrow.operator("file.export_groups_osc", icon='GROUP_VCOL')
colrow.operator("file.import_groups_osc", icon='GROUP_VCOL')
+ colrow=col.row(align=1)
+ colrow.operator("mesh.export_vertex_colors", icon='COLOR')
+ colrow.operator("mesh.import_vertex_colors", icon='COLOR')
class OscPanelShapes(OscPollShapes, bpy.types.Panel):
bl_idname = "Oscurart Shapes Tools"
diff --git a/oscurart_tools/oscurart_meshes.py b/oscurart_tools/oscurart_meshes.py
index c52bc1f..2cd87cc 100644
--- a/oscurart_tools/oscurart_meshes.py
+++ b/oscurart_tools/oscurart_meshes.py
@@ -331,3 +331,35 @@ class OscOverlapUv(bpy.types.Operator):
def execute(self, context):
DefOscOverlapUv(self.precision)
return {'FINISHED'}
+
+## ------------------------------- IO VERTEX COLORS --------------------
+
+def DefOscExportVC():
+ with open("%s/%s.vc" % (os.path.dirname(bpy.data.filepath),bpy.context.object.name), mode="w") as file:
+ ob = bpy.context.object
+ di = { loopind : ob.data.vertex_colors.active.data[loopind].color[:] for face in ob.data.polygons for loopind in face.loop_indices[:] }
+ file.write(str(di))
+
+def DefOscImportVC():
+ with open("%s/%s.vc" % (os.path.dirname(bpy.data.filepath),bpy.context.object.name), mode="r") as file:
+ di = eval(file.read())
+ for loopind in di:
+ bpy.context.object.data.vertex_colors.active.data[loopind].color = di[loopind]
+
+class OscExportVC (bpy.types.Operator):
+ bl_idname = "mesh.export_vertex_colors"
+ bl_label = "Export Vertex Colors"
+ bl_options = {"REGISTER", "UNDO"}
+
+ def execute(self, context):
+ DefOscExportVC()
+ return {'FINISHED'}
+
+class OscImportVC (bpy.types.Operator):
+ bl_idname = "mesh.import_vertex_colors"
+ bl_label = "Import Vertex Colors"
+ bl_options = {"REGISTER", "UNDO"}
+
+ def execute(self, context):
+ DefOscImportVC()
+ return {'FINISHED'}
\ No newline at end of file
More information about the Bf-extensions-cvs
mailing list