fix: bug in initialization of gltf serialiser fixed

This commit is contained in:
Jonas Frei
2025-02-20 23:45:32 +01:00
committed by Thomas Krijnen
parent c549dea943
commit d38f56e82d
@@ -306,39 +306,43 @@ In addition to geometry settings, serialisation has its own set of
.. code-block:: python .. code-block:: python
import ifcopenshell import multiprocessing
import ifcopenshell.geom
import multiprocessing
settings = ifcopenshell.geom.settings() import ifcopenshell
import ifcopenshell.geom
# Settings for glTF / glb ifc_file = ifcopenshell.open("model.ifc")
settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
# Note that applying default materials is required in glTF serialisation.
settings.set("apply-default-materials", True)
# Settings for obj settings = ifcopenshell.geom.settings()
# settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
# settings.set("apply-default-materials", True)
# settings.set("use-world-coords", True)
# Serialise to glTF / glb # Settings for glTF / glb
serialiser = ifcopenshell.geom.serializers.gltf("output.glb", settings) settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
self.serialiser_settings = ifcopenshell.geom.serializer_settings() # Note that applying default materials is required in glTF serialisation.
# Setting element GUIDs is optional, but useful to uniquely identify objects in non-semantic formats. settings.set("apply-default-materials", True)
serialiser_settings.set("use-element-guids", True)
# Serialise to obj # Settings for obj
# serialiser = ifcopenshell.geom.serializers.obj('output.obj', 'output.mtl', settings, serialiser_settings) # settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS)
# settings.set("apply-default-materials", True)
# settings.set("use-world-coords", True)
serialiser.setFile(self.file) serialiser_settings = ifcopenshell.geom.serializer_settings()
serialiser.setUnitNameAndMagnitude("METER", 1.0) # Setting element GUIDs is optional, but useful to uniquely identify objects in non-semantic formats.
serialiser.writeHeader() serialiser_settings.set("use-element-guids", True)
iterator = ifcopenshell.geom.iterator(settings, self.file, multiprocessing.cpu_count()) # Serialise to glTF / glb
if iterator.initialize(): serialiser = ifcopenshell.geom.serializers.gltf("output.glb", settings, serialiser_settings)
while True:
serialiser.write(iterator.get()) # Serialise to obj
if not iterator.next(): # serialiser = ifcopenshell.geom.serializers.obj('output.obj', 'output.mtl', settings, serialiser_settings)
break
serialiser.finalize() serialiser.setFile(ifc_file)
serialiser.setUnitNameAndMagnitude("METER", 1.0)
serialiser.writeHeader()
iterator = ifcopenshell.geom.iterator(settings, ifc_file, multiprocessing.cpu_count())
if iterator.initialize():
while True:
serialiser.write(iterator.get())
if not iterator.next():
break
serialiser.finalize()