If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)
How to install ifcopenshell.api in python (3.9)
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:
- Using the ifcopenshell python module from http://ifcopenshell.org/python (but it does not have the api)
- Using github: https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/ifcopenshell-python/ifcopenshell (I copied the folder and put it in the site-packages).
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?
Tagged:
Comments
IfcOpenShell needs to be compiled, so the answer depends on what platform you are using, Windows, Linux?
@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:
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).
Thanks for your answers!
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.create_file.UseCase().execute() that's not working? ifcopenshell.api.run("project.create_file") ran without problems, so I'll use that in the future!
What's the lastest status update of ifcopenshell.api? And how to install it on Windows? :-)
I was wondering the same thing. @aothms will IfcOpenShell-python v0.7.0 be available on ifcopenshell.org/python?
For now, you can get latest build (incl. api) here https://github.com/IfcOpenBot/IfcOpenShell/commit/93c5906ad7f363fd1b1d9e49eb28d10212ce9173#comments
We're kind of holding off on touching the website until we get this https://community.osarch.org/discussion/comment/8299
Thanks! That's already a lot more convenient than downloading BlenderBIM & finding the package there :)