Open Derek-K opened 3 years ago
It is similar to #473 but I was able to import all buildings as a single object if "separate objects" is not selected.
Blender is not very good to handle thousands of unique objects, the more objects there are, the slower it will be to add new objects. I'm not sure there is a way to solve this. Maybe importing as single object and split it by loose parts afterward could succeed.
I have tried to import as a single object, then go to edit mode, separate objects by loose parts. Same results.
However, I was able to select 2 vertex groups (i.e. 2 buildings) for example and they can be separated in no time, the step is then repeated manually a dozen times, there is no delay. I can't imagine doing that in a loop, say a thousand times, will take forever...
I am just curious when GIS getting OSM data for buildings, what format are they coming in? Does the py script just combine them as a single object then do separate by loose part after? I am trying to see if the code can be modified to create each building as an individual object as it parses the OSM data.
or it is done with https://github.com/domlysz/BlenderGIS/blob/master/operators/io_import_osm.py#L314
if so, perhaps some kind of progress (building Object X of XXXX) would be nice... (Or maybe I will try to add some debug message to test it out later to see where it gets stuck.)
Here is an update...
On a previous failed OSM import as separate objects area, eventually I was able to separate them by using the following steps.
Step 1: Import OSM building as a single object
Step 2: Execute the follow script while the "building" object is selected
# coding=utf8
import bpy
def main():
origin_name = bpy.context.active_object.name
keys = bpy.context.object.vertex_groups.keys()
real_keys = []
for gr in keys:
if gr.find("Name:") != -1:
bpy.ops.object.mode_set(mode="EDIT")
# Set the vertex group as active
bpy.ops.object.vertex_group_set_active(group=gr)
# Deselect all verts and select only current VG
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.vertex_group_select()
# bpy.ops.mesh.select_all(action='INVERT')
try:
bpy.ops.mesh.separate(type="SELECTED")
real_keys.append(gr)
except:
pass
for i in range(1, len(real_keys) + 1):
bpy.data.objects['{}.{:03d}'.format(origin_name, i)].name = '{}.{}'.format(
origin_name, real_keys[i - 1])
if __name__ == '__main__':
main()
At this point, some buildings are now separated, but not all.
Step 3: Select the building object (where lots of buildings were included) again, go to edit mode, select all, separate -> by loose parts.
And it works quickly without problems.
So I suspect maybe the naming (after parsing the OSM data) maybe causing issue. I haven't able to pin point exactly the cause yet.
p.s. I modified the source code initially posted by https://blenderartists.org/u/Kail_Nethunter on https://blenderartists.org/t/split-a-mesh-by-vertex-groups/438990/11 after studying the vertex group generated by BlenderGIS.
Blender and OS versions
Blender 2.92 Windows 10 & Ubuntu 20.04
Describe the bug
When "separate objects" is selected in Get OSM, blender becomes no responsive.
How to Reproduce
As per workflow demo, import basemap (select a city), import SRTM data. Go to "Get OSM", Select "Ways", and checked "separate objects". No need to select anything else (but optionally, just select buildings for the test) Blender will become non-responsive.
Windows: Let it run, and eventually will crash Windows and reboot. While blender is non-responsive, CPU usage is low, didn't observe any growth in memory usage. Linux: One CPU core at 100%, from the terminal window it shows "INFO:BlenderGIS-225.operators.io_import_osm:Overpass query successful" and blender becomes non-responsive
Error message
No error message or crash report. Windows: OS will eventually crash and reboot itself after a few hours. Nothing special logged in System Event Log Linux: Just keeps running until blender process is killed.