OSArch Community

How to install ifcopenshell.api in python (3.9)

  1. L

    I saw this article about the IfcOpenShell api on the OSArch social media and thought I want that too!

    Somehow I can't make it work outside of Blender, but probably I'm doing something wrong. I only can't figure out what. I tried:

    Second method let me import ifcopenshell.api, but it's not really installed. Example of this code:

    
    import ifcopenshell
    
    import ifcopenshell.api
    
    f = ifcopenshell.api.project.create_file.UseCase().execute()
    

    I get an error AttributeError: module 'ifcopenshell.api' has no attribute 'project'

    Anybody knows what I'd be doing wrong?

  2. B

    IfcOpenShell needs to be compiled, so the answer depends on what platform you are using, Windows, Linux?

  3. M

    @LaurensJN you can use a mix of the two methods. Grab the latest IfcOpenShell python module from the IfcOpenShell site, and then simply copy paste all the Python code from here: https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifcopenshell-python/ifcopenshell - the API and utils are pure Python, so the files can just be copied.

    Alternatively, the daily builds from Github of the BlenderBIM Add-on include IfcOpenShell with the API already packaged.

    Also, can I recommend instead doing:

    
    f = ifcopenshell.api.run("project.create_file")
    

    The API is a bit of a moving beast, so the run function helps guard against some future changes that are expected to be made (client-server separation, multi-user support, conflict resolution, potentially running undo, and event listeners for parametric UIs).

  4. L

    Thanks for your answers!

    @brunopostle said:

    IfcOpenShell needs to be compiled, so the answer depends on what platform you are using, Windows, Linux?

    I understood that you didn't need to compile again if you only updated the python part.

    Method of @Moult worked. I think actually the api worked, but maybe it's the function _api.project.createfile.UseCase().execute() that's not working? ifcopenshell.api.run("project.create_file") ran without problems, so I'll use that in the future!

  5. C

    What's the lastest status update of ifcopenshell.api? And how to install it on Windows? :-)

  6. L
  7. A
  8. L

    Thanks! That's already a lot more convenient than downloading BlenderBIM & finding the package there :)

Login or Register to reply.