Comparison of reading IfcGloballyUniqueId from IFC in different OS

Below is the comparison of reading IfcGloballyUniqueId from IFC file by using
ifcopenshell (Python2.7) in different OS.

Download IFC file: GNE_TDP202.ifc

On Ubuntu:

root@98a1aa8ab4a9:/share# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic
root@98a1aa8ab4a9:/share# ipython
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import ifcopenshell as ifc

In [2]: f = ifc.open("GNE_TDP202.ifc")

In [3]: products = f.by_type("ifcproduct")

In [4]: products
Out[4]:
[#22=IfcSite('2oAZ$Cu_aHwBkVc2Blr0Hl',#5,'GNE College','',$,$,$,$,.ELEMENT.,(30,51,31),(75,51,37),0.245512,$,#21),
 #23=IfcBuilding('2oAZ$Du_aHwBkVc2Blr0Hl',#5,'Nanak Tower II','',$,$,$,$,.ELEMENT.,$,$,$),
 #108=IfcGrid('2oAZ$Fu_aHwBkVc2Blr0Hl',#5,'Axes','',$,#104,#107,(#27,#31,#35,#39),(#43,#47,#51,#55,#59,#63,#67,#71,#75,#79,#83,#87,#91,#95,#99,#103),$),
 #126=IfcBuildingStorey('2oAZ$Hu_aHwBkVc2Blr0Hl',#5,'Level 0','',$,$,$,$,.ELEMENT.,0.),
 #127=IfcBuildingElementProxy('2oAZ$Iu_aHwBkVc2Blr0Hl',#5,'WPProxy','',$,$,$,$,.ELEMENT.),
 #128=IfcBuildingStorey('2oAZ$Ju_aHwBkVc2Blr0Hl',#5,'Level 1','',$,$,$,$,.ELEMENT.,3.6),
 #129=IfcBuildingElementProxy('2oAZ$Ku_aHwBkVc2Blr0Hl',#5,'WPProxy001','',$,$,$,$,.ELEMENT.),
 #130=IfcBuildingStorey('2oAZ$Lu_aHwBkVc2Blr0Hl',#5,'Level 2','',$,$,$,$,.ELEMENT.,7.2),
 #131=IfcBuildingElementProxy('2oAZ$Mu_aHwBkVc2Blr0Hl',#5,'WPProxy002','',$,$,$,$,.ELEMENT.),
 #132=IfcBuildingStorey('2oAZ$Nu_aHwBkVc2Blr0Hl',#5,'Level 3','',$,$,$,$,.ELEMENT.,10.8),
 #133=IfcBuildingElementProxy('2oAZ$Ou_aHwBkVc2Blr0Hl',#5,'WPProxy003','',$,$,$,$,.ELEMENT.),
 #134=IfcBuildingStorey('2oAZ$Pu_aHwBkVc2Blr0Hl',#5,'Level 4','',$,$,$,$,.ELEMENT.,14.4),
 #135=IfcBuildingElementProxy('2oAZ$Qu_aHwBkVc2Blr0Hl',#5,'WPProxy004','',$,$,$,$,.ELEMENT.),
 #179=IfcAnnotation('2oAZ$du_aHwBkVc2Blr0Hl',#5,'Building Outline','',$,#9,#178),
 #187=IfcAnnotation('2oAZ$eu_aHwBkVc2Blr0Hl',#5,'Building Label','',$,#9,#186)]

In [5]: entity = products[0]

In [6]: entity
Out[6]: #22=IfcSite('2oAZ$Cu_aHwBkVc2Blr0Hl',#5,'GNE College','',$,$,$,$,.ELEMENT.,(30,51,31),(75,51,37),0.245512,$,#21)

In [7]: entity.GlobalId
Out[7]: u'\U006f0032\U005a0041\U00430024\U005f0075\U00480061\U00420077\U0056006b\U00320063\U006c0042\U00300072\U006c0048\x00\x03\x00\U3b99aea0\u55ef\x08\x00\U99b25b86\U5ba20919\x01\U626f6c47'

In [8]: str(entity.GlobalId)
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
 in ()
----> 1 str(entity.GlobalId)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)

On Mac OSx:

λ ~/ uname -a
Darwin Amritpals-MacBook-Pro.local 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64
λ ~/ ipython
Python 2.7.15 (default, Jan 12 2019, 21:07:57)
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import ifcopenshell as ifc

In [2]: f = ifc.open("GNE_TDP202.ifc")

In [3]: products = f.by_type("ifcproduct")

In [4]: products
Out[4]:
[#22=IfcSite('2oAZ$Cu_aHwBkVc2Blr0Hl',#5,'GNE College','',$,$,$,$,.ELEMENT.,(30,51,31),(75,51,37),0.245512,$,#21),
 #23=IfcBuilding('2oAZ$Du_aHwBkVc2Blr0Hl',#5,'Nanak Tower II','',$,$,$,$,.ELEMENT.,$,$,$),
 #108=IfcGrid('2oAZ$Fu_aHwBkVc2Blr0Hl',#5,'Axes','',$,#104,#107,(#27,#31,#35,#39),(#43,#47,#51,#55,#59,#63,#67,#71,#75,#79,#83,#87,#91,#95,#99,#103),$),
 #126=IfcBuildingStorey('2oAZ$Hu_aHwBkVc2Blr0Hl',#5,'Level 0','',$,$,$,$,.ELEMENT.,0.),
 #127=IfcBuildingElementProxy('2oAZ$Iu_aHwBkVc2Blr0Hl',#5,'WPProxy','',$,$,$,$,.ELEMENT.),
 #128=IfcBuildingStorey('2oAZ$Ju_aHwBkVc2Blr0Hl',#5,'Level 1','',$,$,$,$,.ELEMENT.,3.6),
 #129=IfcBuildingElementProxy('2oAZ$Ku_aHwBkVc2Blr0Hl',#5,'WPProxy001','',$,$,$,$,.ELEMENT.),
 #130=IfcBuildingStorey('2oAZ$Lu_aHwBkVc2Blr0Hl',#5,'Level 2','',$,$,$,$,.ELEMENT.,7.2),
 #131=IfcBuildingElementProxy('2oAZ$Mu_aHwBkVc2Blr0Hl',#5,'WPProxy002','',$,$,$,$,.ELEMENT.),
 #132=IfcBuildingStorey('2oAZ$Nu_aHwBkVc2Blr0Hl',#5,'Level 3','',$,$,$,$,.ELEMENT.,10.8),
 #133=IfcBuildingElementProxy('2oAZ$Ou_aHwBkVc2Blr0Hl',#5,'WPProxy003','',$,$,$,$,.ELEMENT.),
 #134=IfcBuildingStorey('2oAZ$Pu_aHwBkVc2Blr0Hl',#5,'Level 4','',$,$,$,$,.ELEMENT.,14.4),
 #135=IfcBuildingElementProxy('2oAZ$Qu_aHwBkVc2Blr0Hl',#5,'WPProxy004','',$,$,$,$,.ELEMENT.),
 #179=IfcAnnotation('2oAZ$du_aHwBkVc2Blr0Hl',#5,'Building Outline','',$,#9,#178),
 #187=IfcAnnotation('2oAZ$eu_aHwBkVc2Blr0Hl',#5,'Building Label','',$,#9,#186)]

In [5]: entity = products[0]

In [6]: entity
Out[6]: #22=IfcSite('2oAZ$Cu_aHwBkVc2Blr0Hl',#5,'GNE College','',$,$,$,$,.ELEMENT.,(30,51,31),(75,51,37),0.245512,$,#21)

In [7]: entity.GlobalId
Out[7]: u'2oAZ$Cu_aHwBkVc2Blr0Hl'

In [8]: str(entity.GlobalId)
Out[8]: '2oAZ$Cu_aHwBkVc2Blr0Hl'

Conclusion:

When we read IfcGloballyUniqueId from IFC file on Ubuntu, it gives UnicodeEncodeError
but on MacOSx ifcopenshell successfully parse IfcGloballyUniqueID (i.e. 2oAZ$Cu_aHwBkVc2Blr0Hl).

Enhancing the power of rebar object – FreeCAD

Today, I added a Total Length property to the rebar object. Total length is the length of the individual rebar multiplied by the number of occurrences of the rebar. Below is a screenshot of rebar object properties. See the Length and Total Length property in property value table.

length_totallength


Yesterday, I also had a discussion with Sean regarding GCI tasks. He told about interoperability task (for eg. export FreeCAD model to BRL-CAD).

Adding Length property in the rebar object – FreeCAD

Today, I introduced a new property in the rebar object of FreeCAD i.e. Length. This property calculates the total length of the rebar. The user will see this property in the property value table. This property is very useful for Bar bending schedule.

Below is the code which calculates the length of rebar:

def getLengthOfRebar(rebar):
    """ getLengthOfRebar(RebarObject): Calculates the length of the rebar."""
    base = rebar.Base
    # When rebar is derived from DWire
    if hasattr(base, "Length"):
        return base.Length
    # When rebar is derived from Sketch
    elif base.isDerivedFrom("Sketcher::SketchObject"):
        length = 0
        for geo in base.Geometry:
            length += geo.length()
        return length
    else:
        FreeCAD.Console.PrintError("Cannot calculate rebar length from its base object\n")
        return None