I deleted a number of objects in an IFC by selecting them and press delete but it took a very long time and I wonder if there is a faster way to delete objects in BlenderBIM?
I deleted a number of objects in an IFC by selecting them and press delete but it took a very long time and I wonder if there is a faster way to delete objects in BlenderBIM?
Not that I know of unfortunately.
It should be very performative but at the moment that is how it's done
Blender itself is very slow to delete objects but using BlenderBIM is painful.
@Max You can try a small script combining blender api with blenderbim and ifcopenshell
import blenderbim.tool as tool
sel_objs = bpy.context.selected_objects
for s in sel_objs:
ele_guid = tool.Ifc.get_entity(s).GlobalId
ifcopenshell.api.run('root.remove_product', f, product=f.by_guid(ele_guid))
f.write(path)
Thanks, I get an error that I need to define f. Does ifcopenshell needs to be installed separatetly?
You don't need to install ifcopenshell separately, comes along with blenderbim, but you need to import ifcopenshell and you need define your ifc file as well
import ifcopenshell
path = 'path to your ifcfile'
f = ifcopenshell.open(path)
Thanks, now it runs. Still an error,
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
but I guess that is a problem with the IFC.
@Max Hi! It usually takes so long because deletion creates large amount of changes that need to be done in IFC structure in memory, so ifcopenshell.api.run('root.remove_product')
usually won't help.
We have batch deletion method (you can select elements to remove and call it with bpy.ops.bim.override_object_delete(is_batch=True)
). It's taking different approach - instead of removing elements from memory structure, it first lists all elements to delete and then simply removes their lines from .ifc file and then reloads .ifc to the memory. Currently it's hardcoded that batch will occur automatically if removed elements has more than 2000 polygons but you can force batch deletion with the command above, maybe this will help.
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Hard to tell what this error could mean, would need the full error traceback and some .ifc example to figure it out.
Login or Register to reply.