Menu

Converting IFC to GLB using IfcConvert on Linux

2023-06-21
2023-06-26
  • Vidyaranya Malladi

    While I am converting IFC to OBJ using c# pipeline it all works fine. but when I try to convert to GLB the file cannot be opened in any viewers, i ran GLB validator and it seems to always have issues like "GLB_CHUNK_LENGTH_UNALIGNED", "GLB_UNEXPECTED_FIRST_CHUNK" and others. When we do this conversion manually it works fine. I tried using additional options like --center-model-geometry. Still did not work. Any clues will be much appreciated.

     
    • Thomas Krijnen

      Thomas Krijnen - 2023-06-22

      Judging by the information you give us I'd be tempted to think it is related to binary vs text streams. If you open the outputs in text mode \r\n characters will get mapped to \n causing the chunks to no longer align. By random chance with binary floating pointing point numbers you're likely to have a couple of \r\n sequences.

       
  • Vidyaranya Malladi

    @aothms, Thank you for your reply, I checked as you suggesed, I noticed only \n characters in the file.

     
  • Vidyaranya Malladi

    Alternatively, I am trying to convert using ifcopenshell-python, but it seems to fail with errors. Here is the code.

    fn = ifcopenshell.open(ifc_file)
    
    ifcopenshell.ifcopenshell_wrapper.turn_off_detailed_logging()
    ifcopenshell.ifcopenshell_wrapper.set_log_format_json()
    
    settings = ifcopenshell.geom.settings(
        APPLY_DEFAULT_MATERIALS=True
    )
    settings.set(settings.USE_ELEMENT_GUIDS, True)
    sr = ifcopenshell.geom.serializers.gltf(glb_file_name, settings)
    sr.writeHeader()
    for elem in ifcopenshell.geom.iterate(
        settings,
        file_or_filename=fn,
        with_progress=True,
        exclude=("IfcSpace", "IfcOpeningElement"),
        num_threads=1
    ):
        a = sr.write(elem)
    sr.finalize()
    

    Error:

    NotImplementedError: Wrong number or type of arguments for overloaded function 'GltfSerializer_write'.
      Possible C/C++ prototypes are:
        GltfSerializer::write(IfcGeom::TriangulationElement const *)
        GltfSerializer::write(IfcGeom::BRepElement const *)
    

    Please not converting to obj seems to work fine but we are looking for glb for optimization.

     

    Last edit: Vidyaranya Malladi 2023-06-25
    • Thomas Krijnen

      Thomas Krijnen - 2023-06-26

      Because you've added:

      with_progress=True
      

      You get return a pair of progress as integer and the currently processed elem.

      So either change to

      with_progress=False
      

      or to

      for progress, elem in ifcopenshell.geom.iterate(
      
       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.