inverse attributes
inverse attributes
...
You know, something I've been thinking... This big series of if ... if ...if ... if at the beginning of IFC import, that builds many lists and dictionaries. I had done that at the very beginnings of IfcOpenShell. Now, IfcOpenShell has the "reverse" attributes specified in IFC docs implemented too. So we would be able to simplify this block a lot, no more need to build all these tables, you can, from an object get quite easily to its properties, attributes, materials, etc...
Thoughts for later!
You know, something I've been thinking... This big series of if ... if ...if ... if at the beginning of IFC import, that builds many lists and dictionaries. I had done that at the very beginnings of IfcOpenShell. Now, IfcOpenShell has the "reverse" attributes specified in IFC docs implemented too. So we would be able to simplify this block a lot, no more need to build all these tables, you can, from an object get quite easily to its properties, attributes, materials, etc...
Thoughts for later!
Re: inverse attributes
great! Do you have some example code?
Re: inverse attributes
Not really but if you look for ex. at the bottom of http://www.buildingsmart-tech.org/ifc/I ... fcwall.htm
you can now use all the inverse attributes too. So for ex:
you can now use all the inverse attributes too. So for ex:
Code: Select all
f = ifcopenshell.open("somefile.ifc")
wall = f[54] # let's say this is a wall
print(wall.OwnerHistory) # this worked before already
print(wall.HasOpenings) # this now works too
Re: inverse attributes
got the point!
Re: inverse attributes
https://standards.buildingsmart.org/IFC ... fcwall.htmyorik wrote: ↑Wed Mar 06, 2019 5:40 pm Not really but if you look for ex. at the bottom of http://www.buildingsmart-tech.org/ifc/I ... fcwall.htm
you can now use all the inverse attributes too. So for ex:Code: Select all
f = ifcopenshell.open("somefile.ifc") wall = f[54] # let's say this is a wall print(wall.OwnerHistory) # this worked before already print(wall.HasOpenings) # this now works too
Re: inverse attributes
https://forum.freecadweb.org/viewtopic. ... 22#p321124
Basically at the moment we have many for...in... loops that scan the whole IFC file contents to extract relationships. However, IFC object can inform themselves of their relationships, thanks to inverse attributes. So the idea would be to, for example, for each of the relationships dictionaries created at file opening, find each place where they are used in the code, and replace with the appropriate relationship attribute.
Re: inverse attributes
seams the property sets are not listed in the inverse attributes. Means there is no inverse attribute in ifcslab or ifcwall which gives the property sets of this object. Seams I took a bad example to start with ...
Re: inverse attributes
Indeed, there is the inverse attribute for property sets. Property Sets are related to Products via IfcRelDefines. So you can access the property sets via IfcProduct.IsDefinedBy.RelatingPropertyDefinition. In IFC2x3 You need a type check before accessing the property definition, because the relation can be of type IfcRelDefinesByProperties or IfcRelDefinesByType. In IFC4 the type check is not necessary anymore, because there is a new inverse IsTypedBy and thus IsDefinedBy is reserved exclusively for property definitions.
Re: inverse attributes
very cool
get file gruen_new.ifc from here https://forum.freecadweb.org/viewtopic. ... 60#p280947
will give
get file gruen_new.ifc from here https://forum.freecadweb.org/viewtopic. ... 60#p280947
Code: Select all
import ifcopenshell
myfile = '/home/hugo/Desktop/gruen_new.ifc'
ifcfile = ifcopenshell.open(myfile)
ifcfile.by_type("IfcColumn")[0].IsDefinedBy[0].RelatingPropertyDefinition
Code: Select all
>>>
>>> import ifcopenshell
>>> myfile = '/home/hugo/Desktop/gruen_new.ifc'
>>> ifcfile = ifcopenshell.open(myfile)
>>> ifcfile.by_type("IfcColumn")[0].IsDefinedBy[0].RelatingPropertyDefinition
#264=IfcPropertySet('0_dPGJz$zDLuqGzu62$ZMQ',#11,'Allplan Attributes',$,(#255,#256,#257,#258,#260,#261,#262,#263))
>>>
Re: inverse attributes
just found something very very cool ... same ifc file
AFAIK importIFC only uses ifcfile.by_id(xxx) but ifcfile[xxx] works too
Code: Select all
import ifcopenshell
myfile = '/home/hugo/Desktop/gruen_new.ifc'
ifcfile = ifcopenshell.open(myfile)
print(ifcfile[264] == ifcfile['0_dPGJz$zDLuqGzu62$ZMQ'] == ifcfile.by_id(264))
Code: Select all
>>>
>>> import ifcopenshell
>>> myfile = '/home/hugo/Desktop/gruen_new.ifc'
>>> ifcfile = ifcopenshell.open(myfile)
>>> print(ifcfile[264] == ifcfile['0_dPGJz$zDLuqGzu62$ZMQ'] == ifcfile.by_id(264))
True
>>>