Documentation on blenderbim python library
Hopefully I'm not being blind/stupid, but I can't find any reference on how to use the blenderbim python methods (or however you would call them). For example, this code:
import blenderbim.tool as tool
obj = context.active_object
element = tool.Ifc.get_entity(obj) # get ifc element from blender object
obj = tool.Ifc.get_object(element) # get blender object from ifc element
There is a lot of info hidden in threads here - but searching for what you're looking for can be tough. I know ifcopenshell can be used - but since my script is running in Blender, and the model is loaded already in the Scene - using the blenderbim methods feels like it makes sense to me.
The only place I am aware of with (I think old) documentation, is here: https://wiki.osarch.org/index.php?title=BlenderBIM_Add-on/BlenderBIM_Add-on_code_examples
This may well just be a case of "it doesn't exist", which is fine, just wanted to check I wasn't missing anything. Thanks
Tagged:
Comments
You can find useful informations also here
https://docs.blenderbim.org/
https://docs.ifcopenshell.org/ expecially under "code examples" if you want to code https://docs.ifcopenshell.org/ifcopenshell-python/code_examples.html
Thanks @Massimo. I know about those pages - but if I'm not wrong they don't include any examples on using the type of methods I'm after?
Basically when we are inside Blender and use 'import blenderbim' - what can I do then?
I know there are methods, and cool stuff like IfcStore where I can reference straight to the IFC I already have loaded in Blender. But I don't really know what I'm doing. I can use dir() to see what options I have, but then it's guesswork. I could probably look at the actual code too but ¯\_(ツ)_/¯
@CSN i usually use the API methods in order to perfom what i want to archieve...
There are also useful scripts in this folder
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.7.0/src/blenderbim/scripts
if you want, for example, to create automatically types and libraries ...
@Massimo The ifcopenshell API methods are probably what I should do. Out of interest, say you had an IFC pre-loaded in your Blender session, how would you return (random example) the names of the Property Sets in the model?
Unless you know about using IfcStore - I feel like you need to do:
which to me seems silly as I've already 'opened' the IFC by loading it via BlenderBIM.
@CSN with
model = tool.Ifc.get()
you get the current working model
@Massimo I think we might be crossing wires because to use 'tool' in this way you would need to import blenderbim.tool, right?
Is your suggestion that once you have the model defined this way I can start doing ifcopenshell things to it?
... as a side-note, you can also use:
which gets exactly the same result. The question I have is how am I meant to know this if I don't ask on the forums? But perhaps the answer is either ask here or properly understand the code - at which point you know your methods anyway.
The short answer is that IfcOpenShell is a library meant to be used by developers, and so it's corresponsingly designed and documented as such.
The BlenderBIM Add-on is a graphical interface meant to be used by users, and so its internal functions are not documented and no semblance of stability is guaranteed. If you do want to go ahead and use BBIM functions anyway, you can:
import blenderbim.tool
thenmodel = tool.Ifc.get()
if you really want the working session's model, then revert to ifcopenshell calls. This is recommended for anything more powerful.core/tool.py
to see what "tools" are available to you and functions you can call, or source dive for more. Don't use IfcStore, it's superseeded bytool.Ifc
(and there is a comment in the code explaining this).Avoid option 3 if at all possible.
Thanks Moult - for simple scripts I'm running within Blender's session, I quite like the option of using BBIM functions. This is an entirely illogical feeling, I realise.