Can't retrieve IFC properties and attributes

I have uploaded an IFC file to Ion, considering the new update about IFC metadata.
news
news 2

in the sandcastle automatic example using my Ion Asset, I can see that some of properties are retrieved automatically on click (not every property, but ok, I would start with the attributes), even if there are no code lines which show how it is reading these properties.
my sandcastle example now, I tried to copy and paste that code in my application, but even trying to read the features, I don’t see any of the properties got from IFC. nothing about it.

here the code I tried in order to read the properties of the selection:

cesiumViewer.current.screenSpaceEventHandler.setInputAction(function (movement: any) {
        const pickedFeature = cesiumViewer.current?.scene.pick(movement.position);
        if (pickedFeature) {
          console.log("Picked feature properties:", pickedFeature);
        }
      }, CesiumJs.ScreenSpaceEventType.LEFT_CLICK);

so I have a couple of doubts now… what is doing the sandcastle more, which is not shown in the code? how do I retrieve Ifc Properties?

could you please give me an hint about it?
probably I am missing something very simple..

thank you in advance.

If the goal for now is to just print the properties to the console, then you can

  • Check if the picked object is a Cesium3DTileFeature
  • If it is, iterate the properties with getPropertyIds() (and look up their value)

For example, by inserting this in your sandcastle:

viewer.screenSpaceEventHandler.setInputAction(function (movement) {
  const pickedFeature = viewer.scene.pick(movement.position);
  console.log("Picked feature:", pickedFeature);
  if (!(pickedFeature instanceof Cesium.Cesium3DTileFeature)) {
    return;
  }
  const propertyKeys = pickedFeature.getPropertyIds();
  for (let i = 0; i < propertyKeys.length; i++) {
    const propertyKey = propertyKeys[i];
    const propertyValue = pickedFeature.getProperty(propertyKey);
    console.log(propertyKey+": "+propertyValue);
  }
  
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1 Like

Hello Marco!

thank you for pointing that out, it actually works.
Thank you so much.

I am still a bit confused on how property sets should be managed as the ‘propertyKey’ of properties in psets are <propertysetname + propertyname> without a separator symbol.

but I guess that from here I can start filtering and coloring objects

That may be an aspect that is very specific for IFC, so I might not know the best answer here.

I see that there are two properties that are called psetWallCommonReference and psetWallCommonIsExternal in that sandcastle. Based on your question, I assume that there is a concept called “property sets” that allows for some sort of “grouping”, and that these are in fact two properties Reference and IsExternal that both belong to that group psetWallCommon.

If this is right, then … I see that it might be difficult to figure out what that “goup name” is (unless there is a known, predefined set of group names - but even then, parsing the property name to check whether it starts with one of the group names could be clumsy). (I’ll ask about that internally, maybe there is more information)

It turns out that the original name, including the group name, is preserved in the schema.classes[c].properties[p].name.

Here is a sandcastle where I inserted the function

function printMetadataInfo(tileset) {
  const schema = tileset.schema;
  if (!schema) {
    return;
  }
  const classes = schema.classes;
  for (const className of Object.keys(classes)) {
    console.log("Class: ", className);
    const c = classes[className];
    const properties = c.properties;
    for (const propertyName of Object.keys(properties)) {
      console.log("  Property: ", propertyName);
      const property = properties[propertyName];
      const originalName = property.name;
      console.log("    Original name: ", originalName);
    }
  }
}

and called it after loading the tileset:

It prints the original names like this:

Property:  psetWallCommonIsExternal
  Original name:  Pset_WallCommon : IsExternal
Property:  psetWallCommonReference
  Original name:  Pset_WallCommon : Reference
...

which should be sufficient for identifying the available groups.

1 Like

Thank you very much Marco, this is perfect for what I need.

I appreciate your willingness to help and your prompt responses.
for sure this post will help also other people.

have a great day!