L
by LaurensJN on 12 May 2021, edited 2 Nov 2021
#
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?
B
by brunopostle on 12 May 2021
#
+1 votes
IfcOpenShell needs to be compiled, so the answer depends on what platform you are using, Windows, Linux?
M
by Moult on 12 May 2021
#
+1 votes
@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).
L
by LaurensJN on 13 May 2021
#
+1 votes
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!
C
by Coen on 2 Nov 2021
#
What's the lastest status update of ifcopenshell.api? And how to install it on Windows? :-)
L
by LaurensJN on 2 Nov 2021
#
I was wondering the same thing. @aothms will IfcOpenShell-python v0.7.0 be available on ifcopenshell.org/python?
A
by aothms on 2 Nov 2021
#
+2 votes
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
L
by LaurensJN on 2 Nov 2021
#
+3 votes
Thanks! That's already a lot more convenient than downloading BlenderBIM & finding the package there :)