cityjson / Up3date

A Blender add-on to import, edit and export 3D city models encoded in CityJSON v.1.0 format preserving geometries, attributes and semantics
MIT License
66 stars 12 forks source link

"Clean scene" option breaks in Blender 3.x #19

Open Sigmoidas opened 2 years ago

Sigmoidas commented 2 years ago

I have Blender 3.1.2 and the "Up3date-main" add-on is not able to import CityJSON files from 3D BAG

I keep getting the following error:

Python: Traceback (most recent call last):
  File "C:\Users\HP ZBook 15 G2\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\Up3date-main\__init__.py", line 72, in execute
    return parser.execute()
  File "C:\Users\HP ZBook 15 G2\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\Up3date-main\core\objects.py", line 138, in execute
    remove_scene_objects()
  File "C:\Users\HP ZBook 15 G2\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\Up3date-main\core\utils.py", line 21, in remove_scene_objects
    bpy.ops.object.delete()
  File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\scripts\modules\bpy\ops.py", line 132, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.delete.poll() failed, context is incorrectD

location: <unknown location>:-1
liberostelios commented 2 years ago

Hi @Sigmoidas,

I am unable to replicate the issue with the given 3D BAG tile. I use Blender 3.2.1 on Linux. I'd suggest you upgrade as well to 3.2.1, if this isn't a problem.

Oddly enough, this is also just related to trying to delete all objects from the scene. I am wondering if you have any particular objects in the scene. In any case, you can just disable the Clean scene option when selecting the file to import to avoid this error altogether. Just make sure to delete any objects you don't need in the scene before that.

Sigmoidas commented 2 years ago

@liberostelios yes, leaving a new blender file scene default (not deleting any of the default objects) resolves the issue on Blender 3.1.2.

When importing 3D BAG CityJSON files I used to create a new Blender file, hit A and Delete all the contents in the scene. That used to work fine in Blender 3.0.1

As you mentioned disabling Clean scene in the import options also resolves this issue.

liberostelios commented 2 years ago

Alright. I think I can replicate it, indeed, if I try to load a new CityJSON file without removing the previous one. Probably something is wrong in the part that clean the scene.

I'll mark this as a bug, then. Hopefully we can fix it in the future.

Thanks a lot for reporting this!