addam / Export-Paper-Model-from-Blender

Python addon for creating paper models in Blender (development version)
https://blenderartists.org/t/export-paper-model/476597
405 stars 53 forks source link

Error: Circular reference in texture stack #54

Closed MayeoinBread closed 6 years ago

MayeoinBread commented 7 years ago

Hi, I'm starting to get issues when trying to export a model with a painted texture. I have everything set up as described on the wiki page (and as I have done many times before), but every time I try export the model with the texture (using Blender Internal), I get a "Circular reference in texture stack" error. image

When I try export using Cycles, I get the below error. image

I have also tried with older meshes (from at least a year or two ago) where it used to work, and I get the same issues. Part of me is hoping I've just forgotten something really obvious!

-Eoin

addam commented 7 years ago

These errors are evil. I remember I spent a few days debugging them, and that I had finally figured out what they are trying to say, but I no longer remember that.

The method save_image used to begin like this:

    def save_image(self, tex, page_size_pixels: M.Vector, filename):
        texfaces = tex.data
        # omitting this causes a "Circular reference in texture stack" error
        for island in self.islands:
            for uvface in island.faces:
                texfaces[uvface.face.index].image = None

A while ago I realized that the code works without this hack and I removed it -- but perhaps things have once again changed for the worse. The last version that includes this workaround is e4d373, you can try it for now.

The Cycles error is something different and should be easy to fix, I'll look into it tomorrow.

MayeoinBread commented 7 years ago

Ah great! Thanks, that works.

comac2k commented 7 years ago

I resumed some of my models this week just to stumble upon this problem myself. Here's what I've found:

Does this give any clues?

Tymski commented 6 years ago

On 2.79 addon doesn't work either.

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_export_paper_model.py", line 2194, in execute
    self.unfolder.save(self.properties)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_export_paper_model.py", line 315, in save
    self.mesh.save_separate_images(tex, ppm, filepath, embed=Exporter.encode_image)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_export_paper_model.py", line 668, in save_separate_images
    bake([uvface.face.index for uvface in island.faces], tex, image)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\io_export_paper_model.py", line 212, in bake
    bpy.ops.object.bake_image()
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Circular reference in texture stack

location: <unknown location>:-1
addam commented 6 years ago

I've put back that magic piece of code, and I believe Blender Internal baking works again. @Tymski, can you please check the current master with your scene?

While investigating Cycles baking I realised it never might have worked. I'll read the documentation but all the options of baking an image in Cycles seem awfully complicated.

Tymski commented 6 years ago

Tried it with a cube and a uv grid. Works fine.

gatobarbado commented 6 years ago

Hello, I am having trouble with the Paper Model add-on, currently I am using version 2.79, I have tried a lot of different stuff but nothing seems to work, my model exports fine without a texture but all crashes when I try to export it with a custom drawing. I will appreciate any help. Thanks

comac2k commented 6 years ago

@gatobarbado are you using the version of the plugin bundled with blender? You might want to download the latest version from the repo and make sure you're using that one (remove bundled version). Failure to export with textures was a known issue that was fixed in the repo but not included (yet) in the official blender distribution. Also, if you're exporting to separate images, make sure there's no folder with the same name as the destination file (minus extension).

addam commented 6 years ago

@gatobarbado, it should be enough to download blender 2.79b, I hope I have fixed this issue. Or not?