[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2014] trunk/py/scripts/addons/ io_coat3D/tex.py: Creates material indexs correctly when there is no material in object.

Campbell Barton ideasman42 at gmail.com
Wed Jun 8 02:34:14 CEST 2011


before calling tex_slot.texture.image.reload() you need to check if
image is None too

image = tex_slot.texture.image
if image is not None:
   ,,,,

On Tue, Jun 7, 2011 at 8:42 PM, Kalle-Samuli Riihikoski
<haikalle at gmail.com> wrote:
> Revision: 2014
>          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2014
> Author:   haikalle
> Date:     2011-06-07 20:42:15 +0000 (Tue, 07 Jun 2011)
> Log Message:
> -----------
> Creates material indexs correctly when there is no material in object.
>
> Modified Paths:
> --------------
>    trunk/py/scripts/addons/io_coat3D/tex.py
>
> Modified: trunk/py/scripts/addons/io_coat3D/tex.py
> ===================================================================
> --- trunk/py/scripts/addons/io_coat3D/tex.py    2011-06-07 17:44:25 UTC (rev 2013)
> +++ trunk/py/scripts/addons/io_coat3D/tex.py    2011-06-07 20:42:15 UTC (rev 2014)
> @@ -2,13 +2,11 @@
>  import os
>  import filecmp
>
> -
>  def objname(path):
>
>     path2 = os.path.dirname(path) + os.sep
>     pituus = len(path2)
>     nimi = path[pituus:]
> -
>     return nimi
>
>  def justname(name):
> @@ -30,8 +28,6 @@
>                 if(not(hasattr(tex,'texture'))):
>                         break
>                 luku = luku +1
> -
> -
>         return luku
>
>  def gettex(mat_list, objekti, scene,export):
> @@ -44,8 +40,6 @@
>     else:
>         vray = False
>
> -
> -
>     take_color = 0;
>     take_spec = 0;
>     take_normal = 0;
> @@ -71,7 +65,7 @@
>             for tex_slot in mate.material.texture_slots:
>                 if(hasattr(tex_slot,'texture')):
>                     if(tex_slot.texture.type == 'IMAGE'):
> -                                                tex_slot.texture.image.reload()
> +                        tex_slot.texture.image.reload()
>     else:
>         coa = bpy.context.scene.objects.active.coat3D
>         nimi = objname(coa.objectdir)
> @@ -83,7 +77,6 @@
>     just_nimi += '_'
>     just_nimi_len = len(just_nimi)
>
> -
>     if(len(objekti.material_slots) != 0):
>         for obj_tex in objekti.active_material.texture_slots:
>             if(hasattr(obj_tex,'texture')):
> @@ -114,13 +107,24 @@
>         #date = os.path.getmtime(texcoat[tex_name][0])
>
>     if((texcoat['color'] or texcoat['nmap'] or texcoat['disp'] or texcoat['specular']) and (len(objekti.material_slots)) == 0):
> -        new_mat = ("%s_Material"%(objekti.name))
> +        index = 0
> +        tuli = False
> +        lasku = False
> +        while(lasku == False):
> +            tuli = False
> +            new_mat = ("Material.%03d"%(index))
> +            for i in bpy.data.materials:
> +                if(i.name == new_mat):
> +                    tuli = True
> +                    break
> +            if(tuli):
> +                index += 1
> +            else:
> +                lasku = True
>         bpy.data.materials.new(new_mat)
>         ki = bpy.data.materials[new_mat]
>         objekti.data.materials.append(ki)
>
> -
> -
>     if(bring_color == 1 and texcoat['color']):
>         name_tex ='Color_'
>         num = []
> @@ -178,8 +182,6 @@
>         num = []
>
>         index = find_index(objekti)
> -
> -
>         tex = bpy.ops.Texture
>         objekti.active_material.texture_slots.create(index)
>         total_mat = len(objekti.active_material.texture_slots.items())
> @@ -189,8 +191,6 @@
>             if((seekco.name[:7] == 'Normal_') and (seekco.users_material == ())):
>                 useold = seekco
>
> -
> -
>         if(useold == ''):
>
>             tex_name = setgallery()
>
> _______________________________________________
> Bf-extensions-cvs mailing list
> Bf-extensions-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-extensions-cvs
>



-- 
- Campbell


More information about the Bf-extensions-cvs mailing list