Solved

Generate IfcGlobalUniqueId

  • 11 February 2019
  • 2 replies
  • 11 views

Badge +10

I used the Ifc-Writer to writeout an IFC-file succesfully. However, I need to add some elements that are not supported by FME yet (IfcZone and IfcPresentationLayerAssignment. The latter is quite easy to do, if you take the relevant ID's from the IFC-file.

For the first however, I need to add an IfcGlobalUniqueId. This is not a regular GUID, but some sort of encoded uuid, see documentation here.

Now FME already writes those IfcGlobalUniqueId's and I am not that much of a developer. So I am hoping someone can help by either passing me a bit of Python-code or maybe Safe can create a Custum Transformer like IfcGlobalUniqueIdCreator? Any other solutions are welcome as well off course!

In this case it is about IFC2X3 or higher.

Best regards, Lars

@DaveAtSafe, @takashi

icon

Best answer by joeldepooter 11 February 2019, 23:24

View original

2 replies

An IFC global id is just a UUID which has been base64 encoded, with the following modifications:

- There are no padding characters at the end. A UUID will always have two padding characters when base64 encoded, so they must be removed

- The base64 encoding uses non-standard characters for the 62nd and 63rd characters: "_$" instead of "+/"

This is quite easy to do using python:

import base64
import uuid

def processFeature(feature):
    id = base64.b64encode(uuid.uuid4().bytes,b"_$").decode("utf-8")[:-2]
    feature.setAttribute("global_id",id)

 

Badge +10

An IFC global id is just a UUID which has been base64 encoded, with the following modifications:

- There are no padding characters at the end. A UUID will always have two padding characters when base64 encoded, so they must be removed

- The base64 encoding uses non-standard characters for the 62nd and 63rd characters: "_$" instead of "+/"

This is quite easy to do using python:

import base64
import uuid

def processFeature(feature):
    id = base64.b64encode(uuid.uuid4().bytes,b"_$").decode("utf-8")[:-2]
    feature.setAttribute("global_id",id)

 

Thanks @joeldepooter138, this helps me out!

Reply