ajjackson / ascii-phonons

Blender extensions for illustrations of phonons
GNU General Public License v3.0
60 stars 22 forks source link

TypeError: Converting py args to operator properties: enum "SUBSURF" not found in () #29

Open fcannini opened 6 years ago

fcannini commented 6 years ago

Hello there.

I'm trying to run ascii-phonons 1.0 on the following scenario: OS = centos 6.5 x86_64 CC = gcc 5.3.0 Python = 3.5.5 Numpy = 1.14.2 Requests = 2.18.4 Blender = 2.79b compiled with the following options: (output from cmake -L)

CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
WITH_ALEMBIC:BOOL=OFF
WITH_ALEMBIC_HDF5:BOOL=OFF
WITH_BOOST:BOOL=OFF
WITH_BUILDINFO:BOOL=ON
WITH_BULLET:BOOL=ON
WITH_CODEC_AVI:BOOL=ON
WITH_CODEC_FFMPEG:BOOL=OFF
WITH_CODEC_SNDFILE:BOOL=OFF
WITH_COMPOSITOR:BOOL=ON
WITH_CYCLES:BOOL=OFF
WITH_CYCLES_CUDA_BINARIES:BOOL=OFF
WITH_CYCLES_OPENSUBDIV:BOOL=OFF
WITH_CYCLES_OSL:BOOL=OFF
WITH_CYCLES_STANDALONE:BOOL=OFF
WITH_CYCLES_STANDALONE_GUI:BOOL=OFF
WITH_DOC_MANPAGE:BOOL=OFF
WITH_FFTW3:BOOL=OFF
WITH_FREESTYLE:BOOL=ON
WITH_GAMEENGINE:BOOL=ON
WITH_GAMEENGINE_DECKLINK:BOOL=ON
WITH_GHOST_XDND:BOOL=ON
WITH_GTESTS:BOOL=OFF
WITH_IK_ITASC:BOOL=ON
WITH_IK_SOLVER:BOOL=ON
WITH_IMAGE_CINEON:BOOL=ON
WITH_IMAGE_DDS:BOOL=ON
WITH_IMAGE_FRAMESERVER:BOOL=ON
WITH_IMAGE_HDR:BOOL=ON
WITH_IMAGE_OPENEXR:BOOL=OFF
WITH_IMAGE_OPENJPEG:BOOL=ON
WITH_IMAGE_TIFF:BOOL=ON
WITH_INPUT_NDOF:BOOL=ON
WITH_INSTALL_PORTABLE:BOOL=ON
WITH_INTERNATIONAL:BOOL=ON
WITH_JACK:BOOL=OFF
WITH_JACK_DYNLOAD:BOOL=OFF
WITH_LIBMV:BOOL=ON
WITH_LLVM:BOOL=OFF
WITH_LZMA:BOOL=ON
WITH_LZO:BOOL=ON
WITH_MOD_FLUID:BOOL=ON
WITH_MOD_OCEANSIM:BOOL=OFF
WITH_MOD_REMESH:BOOL=ON
WITH_MOD_SMOKE:BOOL=ON
WITH_OPENAL:BOOL=ON
WITH_OPENCOLLADA:BOOL=OFF
WITH_OPENCOLORIO:BOOL=OFF
WITH_OPENGL_DRAW_TESTS:BOOL=OFF
WITH_OPENGL_RENDER_TESTS:BOOL=OFF
WITH_OPENIMAGEIO:BOOL=ON
WITH_OPENMP:BOOL=ON
WITH_OPENSUBDIV:BOOL=OFF
WITH_OPENVDB:BOOL=OFF
WITH_OPENVDB_BLOSC:BOOL=OFF
WITH_PLAYER:BOOL=OFF
WITH_PYTHON_INSTALL:BOOL=ON
WITH_PYTHON_INSTALL_NUMPY:BOOL=ON
WITH_PYTHON_INSTALL_REQUESTS:BOOL=ON
WITH_PYTHON_MODULE:BOOL=OFF
WITH_RAYOPTIMIZATION:BOOL=ON
WITH_SDL:BOOL=OFF
WITH_SDL_DYNLOAD:BOOL=OFF
WITH_STATIC_LIBS:BOOL=OFF
WITH_SYSTEM_EIGEN3:BOOL=OFF
WITH_SYSTEM_GLES:BOOL=OFF
WITH_SYSTEM_GLEW:BOOL=OFF
WITH_SYSTEM_LZO:BOOL=OFF
WITH_SYSTEM_OPENJPEG:BOOL=OFF
WITH_X11_ALPHA:BOOL=ON
WITH_X11_XF86VMODE:BOOL=ON
WITH_X11_XFIXES:BOOL=ON
WITH_X11_XINPUT:BOOL=ON

The blender executable is found by *which blender, but when trying to execute both ascii-phonons or ascii-phonons-gui it barfs the same error message:

[user@machine examples]$ ascii-phonons -o kesterite kesterite.ascii
Color management: using fallback mode for management
found bundled python: /path/to/blender/2.79/2.79/python
addon not found: 'cycles'
Traceback (most recent call last):
  File "/home/user/ascii-phonons-1.0.0/examples/tmpzvyuxsz5.py", line 14, in <module>
    vsim2blender.plotter.setup_render_freestyle(**{'output_file': 'kesterite', 'input_file': '/home/user/ascii-phonons-1.0.0/examples/kesterite.ascii'})
  File "/path/to/blender/2.79/2.79/python/lib/python3.5/site-packages/vsim2blender/plotter.py", line 508, in setup_render_freestyle
    bpy.ops.object.modifier_add(type='SUBSURF')
  File "/path/to/blender/2.79/2.79/scripts/modules/bpy/ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties:  enum "SUBSURF" not found in ()
Blender quit

I had to compile blender because the binary release segfaults even when using 2.19 libc shared libraries via LD_PRELOAD.

Any clue where the error might be?

Thanks for any help, Fabricio

ajjackson commented 6 years ago

This is strange. I've just opened the binary release of 2.79b, opened the terminal and typed bpy.ops.object.modifier_add(type=-'SUBSURF'). The default cube turned into something rounder, as expected, so they haven't moved this operation. Can you try doing the same thing? Open the blender GUI; you can get the console by selecting "Scripting" from the screen layout dropdown just to the right of the "Help" menu.

fcannini commented 6 years ago

I've downloaded the binary release to my notebook to compare results. Both on my notebok and the compiled one the result is the same:

>>> bpy.ops.object.modifier_add(type=-'SUBSURF')
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bad operand type for unary -: 'str'
fcannini commented 6 years ago

Hello there.

Is there anything else I can do to help you?

ajjackson commented 6 years ago

Sorry, now that I look again I see a typo in what I asked you to try! There shouldn't be a minus sign -, it should be bpy.ops.object.modifier_add(type='SUBSURF')

fcannini commented 6 years ago

That worked, the cube changed to a kind of 8-sided sphere. What's next?

ajjackson commented 6 years ago

Well, we now know that your Blender can handle SUBSURF. In that case the problem with bpy.ops.object.modifier_add(type='SUBSURF') probably lies in the object that it is trying to add the modifier to, which is the unit cell box. What happens if you run ascii-phonons with the --no_box argument?

fcannini commented 6 years ago

Now with --no_box both examples worked! I see 30 kesterite####.png files and 30 angles####.png files each. YAY!

fcannini commented 6 years ago

While generating .gif through ascii-phonons --no_box --gif -o angles angles.ascii an odd thing happens. The file is created but ascii-phonons barfs out in the end:

convert: unable to open image `/home/user/ascii-phonons-1.0.0/examples/tmp7i14pyf90030.png': No such file or directory @ blob.c/OpenBlob/2480.
convert: unable to open file `/home/user/ascii-phonons-1.0.0/examples/tmp7i14pyf90030.png' @ png.c/ReadPNGImage/2889.
Traceback (most recent call last):
  File "/path/to/ascii-phonons/1.0/bin/ascii-phonons", line 91, in <module>
    ascii_phonons.call_blender(**options)
  File "/path/to/external/python/3.5-gnu-5.3/lib/python3.5/site-packages/ascii_phonons/__init__.py", line 194, in call_blender
    remove(f)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/ascii-phonons-1.0.0/examples/tmp7i14pyf90030.png'

/me scratches head.

ajjackson commented 6 years ago

I'm assuming your username is not user, and something is going wrong when it tries to put those paths together? (Or did you substitute your username for user in the output for privacy?)

ajjackson commented 6 years ago

Did it literally say File "/path/to/ascii-phonons/1.0/bin/ascii-phonons", line 91, in <module> in your output? /path/to/ascii-phonons looks like a placeholder rather than a real path

ajjackson commented 6 years ago

I'll have a think about ways of reproducing the box issue. ascii-phonons is a tricky package to maintain because of the odd way it boostraps itself into Blender. Perhaps there is a way of cleaning this up a bit.

fcannini commented 6 years ago

Yes, it's a placeholder. I've tried to change the path, remove any *ascii* or *phonons* from it and see if something happens, but the barf persists. (I've seen bugs in flexlm where the daemon would trip on its own feet if there was flexlm in the path)

arenasluo commented 5 years ago

Hello, I recently updated my blender version from 2.76 , and I met the same problem. The blender 2.76 can work with perfectly with the ascii-phonon code but the blender 2.79b and 2.80 cannot. I also checked the "bpy.ops.object.modifier_add(type='SUBSURF')" to make sure it was used correctly but the problem still exists for blender 2.79b.

ajjackson commented 5 years ago

Thanks for narrowing down the versions involved. It seems that I will need to rewrite the bounding box code in a way that works with newer versions of Blender.

ajjackson commented 5 years ago

I have pushed a version of ascii-phonons to Master that just eliminates the SUBSURF step on the bounding box. It's not really clear to me now why it was necessary in the first place. The problem was in the way objects are selected rather than in SUBSURF itself; "fixing" the code leads to a pretty strange-looking result so I'm just ripping it out for now.

Master should now work with 2.79, would be good to know if it works on some other people's setups. In particular, 2.79 seems to be required for recent versions of Mac OS! Older versions mysteriously freeze while rendering...

Apparently Blender 2.8 includes a big Python API overhaul, so some more maintenance is probably going to be needed for future compatibility.