OSArch Community

[IfcOpenShell] How to work with file content instead of file path

  1. B

    I am trying to develop a Dash app for ifc files but I am stuck at the first step.

    The dash upload component gives acces to the content of the uploaded file but not the uploaded path so I am not really sure how to work with that.

    The ifc.open() method doesnt work without a path.

    I looked around in the ifcopenshell folder and found that the ifcopenshell_wrapper has an read() method so I tried the following code:

    import ifcopenshell as ifc

    from ifcopenshell import ifcopenshell_wrapper

    from ifcopenshell.ifcopenshell_wrapper import file

    f = ifcopenshell_wrapper.read(contents)

    ifc_file = file(f)

    But I get this error:

    Wrong number or type of arguments for overloaded function 'new_file'.

    Possible C/C++ prototypes are:

    IfcParse::IfcFile::IfcFile(std::string const &)
    
    IfcParse::IfcFile::IfcFile(std::istream &,int)
    
    IfcParse::IfcFile::IfcFile(void *,int)
    
    IfcParse::IfcFile::IfcFile(IfcParse::IfcSpfStream *)
    
    IfcParse::IfcFile::IfcFile(IfcParse::schema_definition const *)
    
    IfcParse::IfcFile::IfcFile()

    What did I do wrong? Or is there another way around?

  2. M

    @Borna_Molnar try this:

    
     f = ifcopenshell.file.from_string(open('/home/dion/tmp.ifc').read())
    
  3. K

    I'm getting a file doesn't exist error if I do this. (open('/home/USER/tmp.ifc'))Please let me know if you have found a solution.

Login or Register to reply.