OSArch Community

Change GUID of element?

  1. B

    Hi,

    I would like to convert from a rhino .3dm file to an .ifc file. In the .3dm file, each element has a Guid, which I want to "transfer" to the .ifc file in order for each "export" to be identical. By assigning the guid directly to the element, ie.

    <code>

    product = ifcopenshell.api.run('root.create_entity', self.file, ifc_class = 'IfcReinforcingBar')

    product.GlobalId = rhinoGUID

    </code>

    this will break the guid stored for that element by the currently open ifcfile, ie ifcFIle.by_id(product.GlobalId) doesnt work anymore. This basically breaks almost the entire ifcopenshell.api, as no elements I have changed are recognized by the api anymore.

    Any tips on how I can change the element GUID but also change the guid registered by ifcopenshell.api?

    BR Sondre

  2. B

    I guess I can store a dictionary that maps old->new guids, and then as a final step before writing the .ifc I can update all guids...

    Any opinins on whether this is extremely stupid or not? I know the new guids are unique, but do I perhaps break something else "further down the line" I havent though about?

  3. C

    Can't you store the guids of the .3dm file in a custom IFC propertyset?

  4. B

    The idea is that every ifc export of the same .3dm should become identical. Only changed elements should get a different guid. Otherwise it would be very difficult to know which elements that are actually changed for the current revision of the model. At least that what I think..

  5. M

    What does the rhinoGUID variable look like? Is it a string? An object? Is it an actual GUID (e.g. 128-bit number) or just some other number like "123456"? Are you 100% sure that it's a 1:1 mapping from Rhino object to IFC element?

    If it is a true GUID and it's a 1:1 mapping, you can use ifcopenshell.guid.compress:

    
    >>> print(x)
    
    81b96203-fcdd-4046-921a-4f407ed029b7
    
    >>> y = ifcopenshell.guid.compress(x.replace("-", ""))
    
    >>> print(y)
    
    21kM83$Dr0Hf8QJq1_q2ct
    
    >>> wall.GlobalId = y
    
    >>> wall
    
    #1=IfcWall('21kM83$Dr0Hf8QJq1_q2ct',$,$,$,$,$,$,$,$)
    

    If it isn't a UUID or not 1:1 the correct place to store it is in the Tag attribute. E.g. wall.Tag = rhinoGuid.

  6. B
  7. M

    @BIMrookie92 indeed there are rules in IFC about how GlobalIds are structured and when they are not followed things break.

  8. B

    Just to be clear, I didnt try to insinuate that there was something erroenous with ifcopenshell, I knew I was (obviously) doing something wrong (since it didnt work). I was not aware of how assigning a compressed hex guid was the correct approach, but now I know:)

Login or Register to reply.