[Bf-extensions-cvs] [a650e83e] blender2.8: blender 2.8 update
Kalle-Samuli Riihikoski
noreply at git.blender.org
Fri Jul 6 12:17:40 CEST 2018
Commit: a650e83e3e96ff629ce395f3f38ea2edff67abd8
Author: Kalle-Samuli Riihikoski
Date: Fri Jul 6 10:15:39 2018 +0300
Branches: blender2.8
https://developer.blender.org/rBAa650e83e3e96ff629ce395f3f38ea2edff67abd8
blender 2.8 update
===================================================================
M io_coat3D/__init__.py
M io_coat3D/coat.py
M io_coat3D/tex.py
===================================================================
diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index b5539ede..1b89dfa0 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -20,7 +20,7 @@ bl_info = {
"name": "3D-Coat Applink",
"author": "Kalle-Samuli Riihikoski (haikalle)",
"version": (3, 5, 22),
- "blender": (2, 59, 0),
+ "blender": (2, 8, 0),
"location": "Scene > 3D-Coat Applink",
"description": "Transfer data between 3D-Coat/Blender",
"warning": "",
@@ -59,9 +59,24 @@ def register():
objpath = StringProperty(
name="Object_Path"
)
+ applink_address = StringProperty(
+ name="Object_Applink_address"
+ )
applink_name = StringProperty(
- name="Object_Applink_name"
+ name="Applink object name"
)
+ applink_group = StringProperty(
+ name="Applink group"
+ )
+ applink_skip = StringProperty(
+ name="Object_Applink_Update",
+ default="False"
+ )
+ applink_firsttime = BoolProperty(
+ name="FirstTime",
+ description="FirstTime",
+ default=True
+ )
coatpath = StringProperty(
name="Coat_Path"
)
@@ -216,12 +231,7 @@ def register():
)
# copy location
- cursor = FloatVectorProperty(
- name="Cursor",
- description="Location",
- subtype="XYZ",
- default=(0.0, 0.0, 0.0)
- )
+
loca = FloatVectorProperty(
name="location",
description="Location",
diff --git a/io_coat3D/coat.py b/io_coat3D/coat.py
index fc3cb747..494181dc 100644
--- a/io_coat3D/coat.py
+++ b/io_coat3D/coat.py
@@ -21,6 +21,7 @@ import bpy
from bpy.props import *
from io_coat3D import tex
import os
+import ntpath
bpy.coat3D = dict()
@@ -133,9 +134,8 @@ class SCENE_PT_Main(ObjectButtonsPanel,bpy.types.Panel):
import_no = 0
coat = bpy.coat3D
coat3D = bpy.context.scene.coat3D
- if(bpy.context.scene.objects.active):
- coa = bpy.context.scene.objects.active.coat3D
-
+ if(bpy.context.active_object):
+ coa = bpy.context.active_object.coat3D
if(bpy.coat3D['status'] == 0 and not(os.path.isdir(coat3D.exchangedir))):
bpy.coat3D['active_coat'] = set_exchange_folder()
@@ -147,8 +147,6 @@ class SCENE_PT_Main(ObjectButtonsPanel,bpy.types.Panel):
row.prop(coat3D,"exchangedir",text="")
else:
-
-
#Here you add your GUI
row = layout.row()
row.prop(coat3D,"type",text = "")
@@ -157,18 +155,9 @@ class SCENE_PT_Main(ObjectButtonsPanel,bpy.types.Panel):
colR = row.column()
colR.operator("export_applink.pilgway_3d_coat", text="Transfer")
-
colL.operator("import_applink.pilgway_3d_coat", text="Update")
-
-
-
-
-
-
-
-
class SCENE_OT_export(bpy.types.Operator):
bl_idname = "export_applink.pilgway_3d_coat"
bl_label = "Export your custom property"
@@ -180,8 +169,7 @@ class SCENE_OT_export(bpy.types.Operator):
coat3D = bpy.context.scene.coat3D
scene = context.scene
activeobj = bpy.context.active_object.name
- obj = scene.objects[activeobj]
- coa = bpy.context.scene.objects.active.coat3D
+ coa = bpy.context.active_object.coat3D
coat3D.exchangedir = set_exchange_folder()
export_ok = False
@@ -206,44 +194,28 @@ class SCENE_OT_export(bpy.types.Operator):
looking = True
object_index = 0
- if(coa.applink_name and os.path.isfile(coa.applink_name)):
- checkname = coa.applink_name
+ if(coa.applink_address and os.path.isfile(coa.applink_address)):
+ checkname = coa.applink_address
else:
while(looking == True):
checkname = folder_objects + os.sep + activeobj
- checkname = ("%s%.2d.obj"%(checkname,object_index))
+ checkname = ("%s%.2d.dae"%(checkname,object_index))
if(os.path.isfile(checkname)):
object_index += 1
else:
looking = False
- coa.applink_name = checkname
-
-
- coat3D.cursor_loc = obj.location
- coat3D.cursor_orginal = bpy.context.scene.cursor_location
-
-
-
- coa.loc = obj.location
- coa.rot = obj.rotation_euler
- coa.sca = obj.scale
- coa.dime = obj.dimensions
-
- obj.location = (0,0,0)
- obj.rotation_euler = (0,0,0)
- bpy.ops.object.transform_apply(scale=True)
-
- bpy.ops.export_scene.obj(filepath=coa.applink_name,use_selection=True,
- use_mesh_modifiers=False,use_blen_objects=True, use_materials = True,
- keep_vertex_order = True,axis_forward='-Z',axis_up='Y')
+ coa.applink_name = ("%s%.2d"%(activeobj,object_index))
+ coa.applink_address = checkname
+ for objekti in bpy.context.selected_objects:
+ if(objekti.material_slots.keys() == []):
+ bpy.ops.material.new()
+ objekti.data.materials.append(bpy.data.materials[-1])
- obj.location = coa.loc
- obj.rotation_euler = coa.rot
+ bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
-
- bpy.context.scene.cursor_location = coat3D.cursor_loc
- bpy.context.scene.cursor_location = coat3D.cursor_orginal
+ bpy.ops.wm.collada_export(filepath=coa.applink_address, selected=True,
+ apply_modifiers=False, triangulate=False)
file = open(importfile, "w")
file.write("%s"%(checkname))
@@ -251,9 +223,15 @@ class SCENE_OT_export(bpy.types.Operator):
file.write("\n[%s]"%(coat3D.type))
file.write("\n[TexOutput:%s]"%(folder_textures))
file.close()
+ group_index = -1.0
- coa.objecttime = str(os.path.getmtime(coa.applink_name))
+ for objekti in bpy.context.selected_objects:
+ objekti.coat3D.applink_group = ''.join(str(bpy.context.selected_objects))
+ objekti.coat3D.applink_address = coa.applink_address
+ objekti.coat3D.applink_name = coa.applink_name
+ objekti.coat3D.applink_firsttime = True
+ #coa.objecttime = str(os.path.getmtime(coa.applink_address))
return {'FINISHED'}
@@ -265,12 +243,9 @@ class SCENE_OT_import(bpy.types.Operator):
bl_options = {'UNDO'}
def invoke(self, context, event):
- scene = context.scene
+
coat3D = bpy.context.scene.coat3D
coat = bpy.coat3D
- test = bpy.context.selected_objects
- act_first = bpy.context.scene.objects.active
- bpy.context.scene.game_settings.material_mode = 'GLSL'
coat3D.exchangedir = set_exchange_folder()
folder_objects,folder_textures = set_working_folders()
@@ -280,220 +255,206 @@ class SCENE_OT_import(bpy.types.Operator):
path3b_now = coat3D.exchangedir
path3b_now += ('last_saved_3b_file.txt')
Blender_export += ('%sexport.txt'%(os.sep))
- new_applink_name = 'False'
+ new_applink_address = 'False'
new_object = False
if(os.path.isfile(Blender_export)):
obj_pathh = open(Blender_export)
new_object = True
for line in obj_pathh:
- new_applink_name = line
+ new_applink_address = line
break
obj_pathh.close()
for scene_objects in bpy.context.scene.objects:
if(scene_objects.type == 'MESH'):
- if(scene_objects.coat3D.applink_name == new_applink_name):
+ if(scene_objects.coat3D.applink_address == new_applink_address):
new_object = False
- for act_name in test:
- coa = act_name.coat3D
- path_object = coa.applink_name
- if act_name.type == 'MESH' and os.path.isfile(path_object):
- multires_on = False
- activeobj = act_name.name
- mat_list = []
- scene.objects[activeobj].select = True
- objekti = scene.objects[activeobj]
- coat3D.loca = objekti.location
- coat3D.rota = objekti.rotation_euler
- coat3D.dime = objekti.scale
-
-
-
- #See if there is multres modifier.
- for modifiers in objekti.modifiers:
- if modifiers.type == 'MULTIRES' and (modifiers.total_levels > 0):
- if(not(coat3D.importlevel)):
- bpy.ops.object.multires_external_pack()
- multires = coat3D.exchangedir
- multires += ('%stemp.btx'%(os.sep))
- bpy.ops.object.multires_external_save(filepath=multires)
- #bpy.ops.object.multires_external_pack()
- multires_on = True
- multires_name = modifiers.name
- break
+ if(new_object == False):
+
+ #Blender -> 3DC -> Blender workflow
+
+ for objekti in bpy.context.scene.objects:
+ obj_coat = objekti.coat3D
+
+ if(obj_coat.applink_address != '' and os.path.isfile(obj_coat.applink_address) and obj_coat.applink_skip == 'False'):
+ obj_coat.applink_skip = 'True'
+ objekti.select_set('SELECT')
+ exportfile = coat3D.exchangedir
+ path3b_n = coat3D.exchangedir
+ path3b_n += ('last_saved_3b_file.txt')
+ exportfile += ('%sexport.txt'%(os.sep))
+ if(os.path.isfile(exportfile)):
+ export_file = open(exportfile)
+ for line in export_file:
+ if line.rfind('.3b'):
+ objekti.coat3D.coatpath = line
+ coat['active_coat'] = line
+ export_file.close()
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list