Integration of BlenderBIM Features : FreeCAD Arch/BIM - Native IFC

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by paullee »

bernd wrote: Fri Feb 17, 2023 3:26 pm BTW: If FEM_ClippingPlaneAdd is used there are really fast cutting planes available in FreeCAD too ...
@yorik This FEM Plane has handle for ease of manipulation, can add similar features to Arch Section Plane ?

@Roy_043 Any idea ?

Thanks :D
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by bernd »

bernd wrote: Fri Feb 17, 2023 6:01 pm
bernd wrote: Fri Feb 17, 2023 4:11 pm How can the ifcopenshell file object of a ifc opened with native IFC be accessed in FreeCAD Python console to interact with the opened IFC in Pythonconsole?
select the main native ifc object in tree ...

Code: Select all

 App.ActiveDocument.ActiveObject.Proxy.ifcfile

Code: Select all

>>> 
>>> App.ActiveDocument.ActiveObject.Proxy.ifcfile
<ifcopenshell.file.file object at 0x0000014896D73520>
>>> 
selekt main object and do:

Code: Select all

App.ActiveDocument.ActiveObject.Proxy.ifcfile.by_type("IfcProject")[0].Name = "test"
does not change it in tree even after recompute ... How do I interact with the loaded ifcopenshell object by Python and do show the results in PropertyView too like on normal objects.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by bernd »

Code: Select all

cmd = 'attribute.edit_attributes'
prod = App.ActiveDocument.ActiveObject.Proxy.ifcfile.by_type("IfcProject")[0]
attribs = {"Name": "Foo"}
ifcopenshell.api.run(cmd, ifcfile, product=prod, attributes=attribs)

Code: Select all

>>> 
>>> App.ActiveDocument.ActiveObject.Proxy.ifcfile.by_type("IfcProject")[0].Name
'Foo'
>>> 
but in PropertyView from TreeView there is still the old Label ...
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by paullee »

Any pointer to a tutorial on ifcopenshell API / functionalities? Thanks.

Code: Select all

>>> ifcfw=ifcf.by_type("ifcwall")
>>> len(ifcfw)
934
>>> ifcfw99=ifcfw[99]
>>> ifcfw99
#58585=IfcWall('1hPB35rErB1eLTnNNR9Txn',#25,'buitenblad',$,$,#58478,#58580,'6B64B0C5-D4ED-4B06-855D-C575DB25DEF1')

>>> dir(ifcfw99)
['ConnectedFrom', 'ConnectedTo', 'ContainedInStructure', 'Decomposes', 'Description', 'FillsVoids', 'GlobalId', 'HasAssignments', 'HasAssociations', 'HasCoverings', 'HasOpenings', 'HasPorts', 'HasProjections', 'HasStructuralMember', 'IsConnectionRealization', 'IsDecomposedBy', 'IsDefinedBy', 'Name', 'ObjectPlacement', 'ObjectType', 'OwnerHistory', 'ProvidesBoundaries', 'ReferencedBy', 'ReferencedInStructures', 'Representation', 'Tag', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'attribute_name', 'attribute_type', 'get_info', 'get_info_2', 'id', 'is_a', 'unwrap_value', 'walk', 'wrap_value']

>>> ifcfw99.get_info()
{'id': 58585, 'type': 'IfcWall', 'GlobalId': '1hPB35rErB1eLTnNNR9Txn', 'OwnerHistory': #25=IfcOwnerHistory(#20,#24,$,.ADDED.,$,$,$,1440679749), 'Name': 'buitenblad', 'Description': None, 'ObjectType': None, 'ObjectPlacement': #58478=IfcLocalPlacement(#23568,#58477), 'Representation': #58580=IfcProductDefinitionShape($,$,(#58563,#58569,#58577)), 'Tag': '6B64B0C5-D4ED-4B06-855D-C575DB25DEF1'}

User avatar
Moult
Posts: 321
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by Moult »

There is a hello world crash course on low level core functionality here: https://blenderbim.org/docs-python/ifco ... world.html

There are code examples here for frequent usecases: https://blenderbim.org/docs-python/ifco ... mples.html

There is extensive documentation available here, in particular check out the api module and the util module: https://blenderbim.org/docs-python/auto ... index.html
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by paullee »

Thanks @Moult

Code: Select all

>>> ifcopenshell.util.element.get_type(ifcfw99)
#33176=IfcWallType('3CB5XsV6M0O9Wi$OySPEkT',#25,'IFC_baksteen_roodbruin_100mm_liggend 100',$,$,$,$,'CC2C5876-7C65-8060-982C-FD8F1C64EB9D',$,.NOTDEFINED.)
>>> 
>>> ifcopenshell.util.element.get_psets(ifcfw99)
{'eigenschappen': {'druksterkte': '15', 'steenspecificatie': 'Wienerberger, producttype 41N46-wildverband', 'id': 58594}, 'ArchiCADProperties': {'ID': 'buitenblad', 'Home Story': '00 begane grond', 'Zone Name': '', 'Zone Number': '', 'Layer': '2110_buitenwanden - niet constructief', 'Type': 'Wall', 'Locked': False, 'Building Material / Composite / Profile / Fill': 'IFC_baksteen_roodbruin_100mm_liggend', 'Label Text': '', 'Unique ID': '6B64B0C5-D4ED-4B06-855D-C575DB25DEF1', 'Linked Changes': '', 'Structural Function': 'Non-Load-Bearing Element', 'Position': 'Exterior', 'Element Classification': 'Wall', 'Renovation Status': 'New', 'Show On Renovation Filter': 'All Relevant Filters', 'Structure Type': 'Composite', 'Building Material / Composite / Profile': 'IFC_baksteen_roodbruin_100mm_liggend', 'Outside Face Surface': 'Baksteen - bruin liggend', 'Inside Face Surface': 'Baksteen - bruin liggend', 'Outside Slant Angle': 90.0, 'Inside Slant Angle': 90.0, 'Wall Slant Type': 'Straight', 'Reference Line Location': 'Center', 'Top Link Story': 'Home + 1 (1. 01 eerste verdieping)', 'Geometry method': 'Uniform', 'id': 58626}, 'AC_Pset_RenovationAndPhasing': {'Renovation Status': 'New', 'id': 58632}, 'Pset_WallCommon': {'LoadBearing': False, 'IsExternal': True, 'id': 58639}, 'BaseQuantities': {'Length': 577.772326722, 'Height': 2640.0, 'Width': 100.0, 'GrossFootprintArea': 0.0577772326722, 'NetFootprintArea': 0.0577772326722, 'GrossSideArea': 1.70298692834, 'NetSideArea': 1.70298692834, 'GrossVolume': 0.170306705852, 'NetVolume': 0.170306705852, 'id': 58653}, 'ArchiCADQuantities': {'Elevation to Project Zero': 360.0, 'Elevation to Story': 360.0, 'Height': 2640.0, 'Surface Area': 1.58400036633, 'Net Volume': 0.170306705852, 'Area': 0.0577772326722, 'Thickness': 100.0, 'Length of the Wall on the Outside Face': 600.00013876, 'Length of the Wall on the Inside Face': 555.544514683, 'Net Surface Area on the Outside Face': 1.58400036633, 'Net Surface Area on the Inside Face': 1.82197349036, 'Net Surface Area of the Edges': 0.129024417415, 'Conditional Volume': 0.170306705852, 'Number of Doors': 0.0, 'Number of Windows': 0.0, 'Number of Holes (Number of Empty Openings)': 0.0, 'Number of Columns': 0.0, 'Combined Width of Doors': 0.0, 'Combined Width of Windows': 0.0, 'End Thickness of the Wall': 100.0, 'Minimum Height of the Wall': 0.0, 'Maximum Height of the Wall': 2640.0, 'Length of the Wall at the Center': 577.772326722, 'Area of the Wall': 0.0577772326722, 'Perimeter of the Wall': 1364.98094775, 'Gross Surface Area of the Wall on the Inside Face': 2.08624425343, 'Gross Surface Area of the Wall on the Outside Face': 1.84800036633, 'Gross Volume of the Wall': 0.196712230988, 'Analytic Surface Area of Openings on the Inside Face': 0.0, 'Analytic Surface Area of Openings on the Outside Face': 0.0, 'Analytic Volume of Openings in the Wall': 0.0, 'Wall Skin Thickness on the Outside Face': 100.0, 'Wall Skin Thickness on the Inside Face': 100.0, 'Insulation Skin Thickness': 0.0, 'Air Skin Thickness': 0.0, 'Minimum Height of the Wall Skin on the Outside Face': 0.0, 'Maximum Height of the Wall Skin on the Outside Face': 2640.0, 'Minimum Height of the Wall Skin on the Inside Face': 0.0, 'Maximum Height of the Wall Skin on the Inside Face': 2640.0, 'Conditional Length on the Outside Face': 600.00013876, 'Conditional Length on the Inside Face': 555.544514683, 'Conditional Surface Area on the Outside Face': 1.58400036633, 'Conditional Surface Area on the Inside Face': 1.82197349036, 'Wall Skin Volume on the Outside Face': 0.170306705852, 'Wall Skin Volume on the Inside Face': 0.170306705852, 'Conditional Wall Skin Volume on the Outside Face': 0.170306705852, 'Conditional Wall Skin Volume on the Inside Face': 0.170306705852, 'Length of Reference Line': 627.772187195, 'Home Offset': 360.0, 'Top Offset': 0.0, 'Average Length': 577.772326722, 'Surface Area of Windows in the Wall': 0.0, 'Surface Area of Doors in the Wall': 0.0, 'Surface Area of Empty Openings in the Wall': 0.0, 'Volume of Columns': 0.0, 'id': 58713}}
>>> 
BTW, it is IFC Schependomlaan.ifc that I am opening :)
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by bernd »

bernd wrote: Fri Feb 17, 2023 6:01 pm
bernd wrote: Fri Feb 17, 2023 4:11 pm How can the ifcopenshell file object of a ifc opened with native IFC be accessed in FreeCAD Python console to interact with the opened IFC in Pythonconsole?
select the main native ifc object in tree ...

Code: Select all

 App.ActiveDocument.ActiveObject.Proxy.ifcfile

Code: Select all

>>> 
>>> App.ActiveDocument.ActiveObject.Proxy.ifcfile
<ifcopenshell.file.file object at 0x0000014896D73520>
>>> 
since the first created object on import which is named "IfcObject" is the main project object, thus this works on import in new document ...

Code: Select all

App.ActiveDocument.IfcObject.Proxy.ifcfile

Code: Select all

>>> 
>>> App.ActiveDocument.IfcObject.Proxy.ifcfile
<ifcopenshell.file.file object at 0x000001F170D9F0A0>
>>> 
but still ... changeing this IfcOS ifc file object by IfcOS Python commands does not change it in FreeCAD object properties.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by yorik »

There is a wrapper tool too, to get the ifc file of a FreeCAD object:

Code: Select all

ifc_tools.get_ifcfile(obj)
where obj is a FreeCAD object. Internally it finds the project this object belongs to, and gets its ifcopenshell file object.

Indeed manipulating the ifcopenshell file object does not recalculate the FreeCAD object. We need to address that. I see two paths (and I think we need both):

1. We offer python methods, ex. ifc_tools.set_property(obj, property, new_value) that would do everything that needs to be done. Similar to the edit_attribute method at https://github.com/yorikvanhavre/FreeCA ... cts.py#L95

2. We decide that if audacious users decide to modify the ifcopenshell file object directly, they are also responsible to recompute the necessary FreeCAD objects. We should make sure either that recomputing also updates all attributes from the ifcopenshell file (preferred way, I think), or we provide another method for that
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by bernd »

yorik wrote: Thu Feb 23, 2023 10:36 am There is a wrapper tool too, to get the ifc file of a FreeCAD object:

Code: Select all

ifc_tools.get_ifcfile(obj)
where obj is a FreeCAD object. Internally it finds the project this object belongs to, and gets its ifcopenshell file object.
It would be cool to have something faster with less typing. I have done some opener for myself which just pares the ifc to ifcopenshell, there I use ...

Code: Select all

import FreeCAD
if FreeCAD.GuiUp:
    import FreeCADGui

if open.__module__ == '__builtin__':
    pyopen = open  # because we'll redefine open below

def open(filename):
    print("The file {} will be opened with ifcopenshell. Access it with the identifier 'ifcfile'")
    FreeCADGui.addModule("ifcopenshell")
    FreeCADGui.doCommand('ifcfile = ifcopenshell.open("{}")'.format(filename))
    FreeCADGui.doCommand('print(ifc.by_type("IfcProject")[0])')
    return True
afterwards the ifcfile objct is in "ifcfile". Would be cool to have something similiar in the native importer too. Which has just as less as possible typing to get the ifcfileobject. I nearly need this on any IFC I open in FreeCAD.

may be something similar like selecting object and right mouse click to python console but for the project object of the ifc and for ifcfileobject.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Integration of BlenderBIM Feaures : FreeCAD Arch/BIM - Native IFC

Post by paullee »

Cross-post test result of latest import mode - No Representation :D
BIM/Arch development news articles from Yorik's blog

It is really fast ! On my 10 years old i3, it loads IFC Schependomlaan.ifc in 5 s :lol:

0:05 - No Representation (a cube appear :roll: )
0:27 - Coin Representation
1:09 - Full Shape

...
Post Reply