unique object id

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
vanuan
Posts: 465
Joined: Wed Oct 24, 2018 9:49 pm

Re: unique object id

Postby vanuan » Sat Aug 29, 2020 10:01 am

Here's some IFC GUID-related doc: https://technical.buildingsmart.org/res ... /ifc-guid/

What would go wrong if you generate GUID each time you export IFC instead of trying to keep the same id during the object lifetime?
User avatar
bernd
Posts: 10976
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: unique object id

Postby bernd » Sat Aug 29, 2020 10:24 am

vanuan wrote:
Sat Aug 29, 2020 10:01 am
What would go wrong if you generate GUID each time you export IFC instead of trying to keep the same id during the object lifetime?
in BIM work flow an object is identified with the uuid. Thus from the first project modells to the construction models the id of one object should not change, even if the project was exported to ifc a hundred times. Thats how it works ATM in BIM projects.

Thanks to all the answers. I will need to read them carefully and see what would fit best.

cheers bernd
aapo
Posts: 213
Joined: Mon Oct 29, 2018 6:41 pm

Re: unique object id

Postby aapo » Sat Aug 29, 2020 11:58 am

bernd wrote:
Sat Aug 29, 2020 10:24 am
in BIM work flow an object is identified with the uuid. Thus from the first project modells to the construction models the id of one object should not change, even if the project was exported to ifc a hundred times. Thats how it works ATM in BIM projects.
Hmm, in that case the export*.py files in Arch are highly suspect, I get


/freecad-code/src$ grep guid.new Mod/Arch/export*.py|wc
58 129 3977


with quite a few repetitions of ifcopenshell.guid.new() peppered around the export code, which I checked in the ifcopenshell sources, and it creates a random new uid when called. Thus, to me it seems that the exportIFC system already creates new uid:s for quite a few of the added IFC elements upon every export. Not sure, though.
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: unique object id

Postby realthunder » Sun Aug 30, 2020 10:21 pm

If App::Link is allowed in document used for IFC export, then it is not enough to use object.Name/FullName/ID or whatever alone. The uniqueness and persistent-ness can only be guaranteed using the whole object path.

I am curious as to how IFC handles hierarchies, like the same type of window used hundred times. What's IFC's way to identify this type vs. instance relationship? Is there any 'assembly' kind of concept in IFC?
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
vanuan
Posts: 465
Joined: Wed Oct 24, 2018 9:49 pm

Re: unique object id

Postby vanuan » Mon Aug 31, 2020 2:22 am

realthunder wrote:
Sun Aug 30, 2020 10:21 pm
I am curious as to how IFC handles hierarchies, like the same type of window used hundred times. What's IFC's way to identify this type vs. instance relationship? Is there any 'assembly' kind of concept in IFC?
IFC Object model consists of 4 levels (schemas) from low level to high level: resource definition, core, shared element data, domain specific

For example, IfcWindow is defined at the shared element data level. At the higher level (domain specific schema) IfcWindow can have architectural concepts like Panel (i.e. glass) and Lining (i.e. frame). At the lower level (core schema and fundamentals) IfcWindow is a IfcBuildingElement/IfcProduct which has a Spatial Containment / Product Placement and a Surface 3D Geometry / Product Geometric Representation.

At the more basic level, there are the following concepts: project, object and product. Project represents some common metadata like units, geospatial position, libraries and classifications. Object defines an occurrence (instance) of an object type and properties. Product defines an object which has a position (and may have a shape).

Between fundamental concepts and the core layer lies a resource definition data schema. Resource definition data structures don't have an "occurence" (GUID) but are rather artificial concepts that don't exist in reality.

So, to answer your question, a window used hundred times would be modeled as hundred occurrences of object of type IfcWindow with some "shared resource definition" structure which defines common properties.

Specifically, I think this example is relevant: https://standards.buildingsmart.org/IFC ... -items.htm
This is one IfcRepresentationMap used in 4 IfcMappedItem (same MappingSource, different MappingTarget).

So, the resource structure used are IfcRepresentationMap https://standards.buildingsmart.org/IFC ... ionmap.htm and IfcMappedItem https://standards.buildingsmart.org/IFC ... editem.htm
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: unique object id

Postby realthunder » Mon Aug 31, 2020 9:19 am

vanuan wrote:
Mon Aug 31, 2020 2:22 am
IFC Object model consists of 4 levels (schemas) from low level to high level: resource definition, core, shared element data, domain specific
Thanks for the references. I can see that IFC specification are somewhat similar to STEP.

I don't see any GlobalId used for IfcMappedItem, for example, in this file from one of your references. I can see almost direct translation from IfcMappedItem to an App::Link, which may link to a group containing other links, whereas, IfcMappedItem can map to other IfcRepresentationMap containing other IfcMappedItem.

The link eventually links to some concrete object which may require a GlobalId. A possible choice could be the (obj.Document.Uid xor obj.ID).
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
carlopav
Posts: 1570
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: unique object id

Postby carlopav » Mon Aug 31, 2020 10:28 am

really interesting discussion. I think we could lay down some solid foundations for arch objects based on App::Link adoption.
follow my experiments on BIM modelling for architecture design
User avatar
vanuan
Posts: 465
Joined: Wed Oct 24, 2018 9:49 pm

Re: unique object id

Postby vanuan » Mon Aug 31, 2020 10:41 am

realthunder wrote:
Mon Aug 31, 2020 9:19 am

I don't see any GlobalId used for IfcMappedItem, for example, in this file from one of your references. I can see almost direct translation from IfcMappedItem to an App::Link, which may link to a group containing other links, whereas, IfcMappedItem can map to other IfcRepresentationMap containing other IfcMappedItem.

The link eventually links to some concrete object which may require a GlobalId. A possible choice could be the (obj.Document.Uid xor obj.ID).
Yes, as I mentioned, resource data structures (section 8 of IFC reference) don't have "occurrences" and thus don't have GUID. They merely change the properties of object occurrences (such as IFC products, building elements).

Here are my thoughts

IfcMappedItem / IfrRepresentationMap is a resource that takes an object and "places" it multiple times. I think Link works differently: there's no reference from the linked object to the link.

Take my words with a grain of salt. Watch the tutorial yourself:
phpBB [video]
realthunder
Posts: 1810
Joined: Tue Jan 03, 2017 10:55 am

Re: unique object id

Postby realthunder » Mon Aug 31, 2020 11:05 am

vanuan wrote:
Mon Aug 31, 2020 10:41 am
IfcMappedItem / IfrRepresentationMap is a resource that takes an object and "places" it multiple times. I think Link works differently: there's no reference from the linked object to the link.
What do you mean? The IfcMappedItem has a property 'MapSource' that points to the the item to be mapped, just like a Link has LinkedObject. The video specifically says that IFC does not store inverse relationship, and the software has to read the whole file to derive those information. On the other hand, you can get link reference information using App.getLinksTo(), which is calculated dynamically through InList.
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
vanuan
Posts: 465
Joined: Wed Oct 24, 2018 9:49 pm

Re: unique object id

Postby vanuan » Mon Aug 31, 2020 11:16 am

Here's another video that explains that IFC files are not meant to be edited bat rather generated and analysed multiple times.
phpBB [video]