S
by smr02 on 4 Sep 2024, edited 6 Sep 2024
#
I have a script that creates IfcElements using IfcOpenShell. I'm running the script inside Blender.
I would like to display the new elements inside Bonsai without having to reload the whole Ifc file since this takes quite some time.
import bonsai.tool as tool
model = tool.Ifc.get()
new_members = ... # adding new element to (e.g.a wall)
tool.Ifc.set(model)
T
by theoryshaw on 4 Sep 2024
#
might be the latest, not sure
pulled from: https://github.com/C-Claus/BlenderScripts/commit/8afe7bf5c3ecd54e1c940d589f5d845adbef8fdb
def load_ifc_automatically():
if (bool(ifc_file)) == True:
project = ifc_file.by_type('IfcProject')
if project is not None:
for i in project:
collection_name = 'IfcProject/' + i.Name
collection = bpy.data.collections.get(str(collection_name))
if collection is not None:
for obj in collection.objects:
bpy.data.objects.remove(obj, do_unlink=True)
bpy.data.collections.remove(collection)
for material in bpy.data.materials:
material.user_clear()
bpy.data.materials.remove(material)
bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True)
bpy.ops.bim.load_project(filepath=file_path)
T
by theoryshaw on 4 Sep 2024
#
Would it be good, to bake this function into Bonsai somehow? Quite a few have asked for it in the past.
S
by smr02 on 4 Sep 2024
#
Thank you, but this reloads the whole Project.
Isn't there a way to only reload the changed elements?
I guess if I create a element with Bonsai, It's not reloading the whole Project?
A
by Ace on 5 Sep 2024
#
+1 votes
It's probably a rabbit hole, but IfcGit selectively reloads parts of the model that have been edited when you load the commit, it's hooked to the whole Git setup aswell though and is done through the UI, but maybe that is a start?
B
by brunopostle on 5 Sep 2024
#
+2 votes
No, IfcGit reloads the entire model, it just uses a custom function that keeps the current view in the viewport so it looks like a partial update
A
by Ace on 5 Sep 2024
#
@brunopostle said:
No, IfcGit reloads the entire model, it just uses a custom function that keeps the current view in the viewport so it looks like a partial update
TIL, it's quite efficient at doing that, thankyou Bruno
A
by Andrej730 on 5 Sep 2024
#
+1 votes
@theoryshaw said:
Would it be good, to bake this function into Bonsai somehow? Quite a few have asked for it in the past.
Sounds like a rabbit hole of bugs, who knows what else could have changed in the file 😁
S
by smr02 on 6 Sep 2024
#
i've had a look how the file is reloaded in IfcGit.
bonsai.tool.IfcGit.load_project('path/to/file.ifc')
works realy well