Closed cehberlin closed 5 years ago
Thanks. I woul like to test that before it is merged, as I have had bad experience with Blender not necessarily putting newly created stuff at the end of a list (see PR #760 )
@nicolaje Did you check this? For me this is still an issue with some environment without my fix.
how about :
def create_new_material():
all_materials = get_materials().keys()
new_material()
material_name = [name for name in get_materials().keys() \
if name not in all_materials]
if material_name:
return get_material(material_name[0])
else: # see #787
return get_materials()[-1]
@pierriko Good idea! I just tested it with a problematic blender environment and it works fine! Would be awesome if this could be merged!
What about:
def create_new_material():
all_materials_before = set(get_materials())
new_material()
return (all_materials_before ^ set(get_materials())).pop()
Hi guys, would be nice if after this was solved could also be merged to master! Thanks, Chris
Merged!
Fixed a problem that occured with some blender environments, the actual reason is unclear.
However, the included simplification of the create_new_material() method solved the problem.
The original problem stack trace was the following:
Exception ignored in: <bound method Environment.del of <morse.builder.environment.Environment object at 0x7f94cce4a908>> Traceback (most recent call last): File "/usr/local/lib/python3/dist-packages/morse/builder/environment.py", line 831, in del self.create() File "/usr/local/lib/python3/dist-packages/morse/builder/environment.py", line 300, in create component.after_renaming() File "/usr/local/lib/python3/dist-packages/morse/builder/sensors.py", line 290, in after_renaming self.create_laser_arc() File "/usr/local/lib/python3/dist-packages/morse/builder/sensors.py", line 283, in create_laser_arc arc.active_material = self.get_ray_material() File "/usr/local/lib/python3/dist-packages/morse/builder/sensors.py", line 186, in get_ray_material ray_material = bpymorse.create_new_material() File "/usr/local/lib/python3/dist-packages/morse/builder/bpymorse.py", line 96, in create_new_material material_name = [name for name in get_materials().keys() \ IndexError: pop from empty list