- vision.PNG (369.18 KiB) Viewed 2602 times
- ifcpp.PNG (161.89 KiB) Viewed 2602 times
- ifcosweb.PNG (241.07 KiB) Viewed 2602 times
Code: Select all
>>> f = ifcopenshell.open('/home/dion/drive/bim/DhFundament.ifc')
>>> for e in f.by_type('IfcElement'):
... e.GlobalId = ifcopenshell.guid.new()
>>> f.write('/home/dion/drive/bim/DhFundament2.ifc')
Code: Select all
App.ActiveDocument.Structure023.IfcData["IfcUID"]
App.ActiveDocument.Structure045.IfcData["IfcUID"]
Code: Select all
>>>
>>> App.ActiveDocument.Structure023.IfcData["IfcUID"]
'0kEY3dMYL4nguYLQ7LgyaC'
>>> App.ActiveDocument.Structure045.IfcData["IfcUID"]
'0kEY3dMYL4nguYLQ7LgyaC'
>>>
This is quite easy.bernd wrote: ↑Fri Aug 28, 2020 6:58 am open the file from this post: https://forum.freecadweb.org/viewtopic. ... 89#p425838
rund following code:
Code: Select all
App.ActiveDocument.Structure023.IfcData["IfcUID"] App.ActiveDocument.Structure045.IfcData["IfcUID"]
The uuid are identical and thus identical exported in the ifc file. This should never ever happen in an exported ifc file.Code: Select all
>>> >>> App.ActiveDocument.Structure023.IfcData["IfcUID"] '0kEY3dMYL4nguYLQ7LgyaC' >>> App.ActiveDocument.Structure045.IfcData["IfcUID"] '0kEY3dMYL4nguYLQ7LgyaC' >>>
Reading https://community.osarch.org/discussion ... BlenderBIM would imply that the IFCUid would need to be a 'Global' unique identifier. If it really needs to be truly Globally unique, I think the only option would be to use an (essentially) randomly created UUID: https://docs.python.org/2/library/uuid.html#uuid.uuid1 by using uuid.uuid1() or uuid.uuid4().bernd wrote: ↑Fri Aug 28, 2020 4:17 pm I have been thinking ...
- we would need a new property. This property is like the FreeCAD name unique and can not be changed by the user
- this property is the id which will be used for ifc export.
- this id will be generated for every object on object creation (like the unique name)
- may be such id exists already. I will investigate ...
Code: Select all
import hashlib
m = hashlib.blake2b(digest_size = 16)
hashstring = App.ActiveDocument.ActiveObject.FullName.encode("ascii")
m.update(hashstring)
print(hashstring)
print(m.hexdigest())
Code: Select all
if not uid:
hash_for_uid = hashlib.blake2b(digest_size = 16)
hash_for_uid.update(obj.FullName.encode("ascii"))
uid = ifcopenshell.guid.compress(hash_for_uid.hexdigest())
# storing the uid for further use
if preferences['STORE_UID'] and hasattr(obj,"IfcData"):
d = obj.IfcData
d["IfcUID"] = uid
obj.IfcData = d
return uid