【问题标题】:Blender render " location: <unknown location> and " UnboundLocalError " with Pov Ray addonBlender 使用 Pov Ray 插件渲染“位置:<未知位置>”和“UnboundLocalError”
【发布时间】:2019-12-12 01:41:41
【问题描述】:

我不确定这是最好的地方,但我来了...

我正在尝试使用 Blender 2.79b 的 Pov 射线插件渲染图像。当我这样做时,它只会向我展示一个丑陋的棋盘。

在闲逛之后,我点击了信息选项卡,它向我显示了这条小消息:

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\render.py", line 4147, in render
    self._export(scene, povPath, renderImagePath)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\render.py", line 3837, in _export
    write_pov(self._temp_file_in, scene, info_callback)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\render.py", line 3648, in write_pov
    shading.writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments, uniqueName, materialNames, material)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\shading.py", line 251, in writeMaterial
    if(t and t.use and validPath and
UnboundLocalError: local variable 'validPath' referenced before assignment

location: <unknown location>:-1

不幸的是,我并不真正了解 Python(或一般的编码),所以在我更好地理解它之前我不想接触任何东西。

【问题讨论】:

  • 看起来像是插件中的一个错误。
  • 好的,我该如何解决?

标签: python rendering blender povray


【解决方案1】:

打开文件C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\shading.py并替换行

if material:
    special_texture_found = False
    for t in material.texture_slots:
        if t and t.use and t.texture is not None:
            if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE':
                validPath=True
        else:
            validPath=False
        if(t and t.use and validPath and
           (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha)):
            special_texture_found = True
            continue  # Some texture found

    if special_texture_found or colored_specular_found:
        # Level=1 Means No specular nor Mirror reflection
        povHasnoSpecularMaps(Level=1)

        # Level=3 Means Maximum Spec and Mirror
        povHasnoSpecularMaps(Level=3)

使用来自 Blender 2.8 更新插件的以下代码。确保标识级别与原始文件中的相同。

if material:
    special_texture_found = False
    for t in material.texture_slots:
        if t and t.use and t.texture is not None:
            if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE':
                #validPath
                if(t and t.use and
                   (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha)):
                    special_texture_found = True
                    continue  # Some texture found

    if special_texture_found or colored_specular_found:
        # Level=1 Means No specular nor Mirror reflection
        povHasnoSpecularMaps(Level=1)

        # Level=3 Means Maximum Spec and Mirror
        povHasnoSpecularMaps(Level=3)

代码中的问题是 if-case if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE': 没有设置 validPath 的 else 情况。如果发生这种情况,则 validPath 未初始化,这会导致您遇到错误。

【讨论】:

  • 嗯,谢谢,我想我会试试的。缩进是多少行之间的空间?
  • @Tyler 行前有多少空间。您需要与以下屏幕截图中每行前面的点一样多的空格/空格:i.stack.imgur.com/1z1Dv.jpg
  • 没问题。如果它解决了您的问题,请使用复选标记将答案标记为已接受。
猜你喜欢
  • 1970-01-01
  • 2010-09-27
  • 2014-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多