Traceback (most recent call last):
File "/home/mary/PycharmProjects/Ifc/examples/wall_window_door/onlyOneWall.py", line 288, in <module>
contextMio,None,IfcGeometricProjectionEnum.MODEL_VIEW,None)
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/file.py", line 39, in create_entity
e[idx] = arg
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/entity_instance.py", line 98, in setitem
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 1290, in <lambda> getattr = lambda self, name: _swig_getattr(self, entity_instance, name)
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 76, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 70, in _swig_getattr_nondynamic
return object.getattr(self, name)
AttributeError: type object 'object' has no attribute 'getattr'</lambda></module>
I added some prints to IfcOpenshell code for testing purposes, and they indicates that the error is relative to the assignment of the third explicit parameter (context) to the third actual omitted (derived) parameter. I post these prints too:
Fyi. I just addressed this in the code as well now (but you'll have to compile the C++ sources yourself to see or wait for the automated builds). You can now supply None for the derived attributes if you use only positional arguments. I think it's better to use keyword arguments to prevent confusion in these cases. Anyway, thanks for reporting this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
1) I encountered a problem when trying to instantiate an entity having derived attributes.
I am a newbie, but It looks like they aren't accurately managed ... (?)
This is my example fragment code:
context = ifcfile.createIfcGeometricRepresentationContext("AAA","BBB",3 ,0.0001, extrusion_placement, None)
ifcfile.createIfcGeometricRepresentationSubContext("A","B",context,None,IfcGeometricProjectionEnum.MODEL_VIEW,None)
and this is the error:
Traceback (most recent call last):
File "/home/mary/PycharmProjects/Ifc/examples/wall_window_door/onlyOneWall.py", line 288, in <module>
contextMio,None,IfcGeometricProjectionEnum.MODEL_VIEW,None)
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/file.py", line 39, in create_entity
e[idx] = arg
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/entity_instance.py", line 98, in setitem
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 1290, in <lambda>
getattr = lambda self, name: _swig_getattr(self, entity_instance, name)
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 76, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "/home/mary/.local/lib/python2.7/site-packages/ifcopenshell/ifcopenshell_wrapper.py", line 70, in _swig_getattr_nondynamic
return object.getattr(self, name)
AttributeError: type object 'object' has no attribute 'getattr'</lambda></module>
I added some prints to IfcOpenshell code for testing purposes, and they indicates that the error is relative to the assignment of the third explicit parameter (context) to the third actual omitted (derived) parameter. I post these prints too:
file.py -> create_entity -> ARGS: ('AAA', 'BBB', 3, 0.0001, #79=IfcAxis2Placement3D(#76,#77,#78), None)
file.py -> create_entity -> KWARGS: {}
ifcopenshell_wrapper.py -> _swig_getattr -> SELF, CLASS_TYPE, NAME: file.py -> create_entity -> E: IfcGeometricRepresentationContext($,$,$,$,$,$)
file.py -> create_entity -> ATTRS: [(0, 'AAA'), (1, 'BBB'), (2, 3), (3, 0.0001), (4, #79=IfcAxis2Placement3D(#76,#77,#78)), (5, None)]
file.py -> create_entity -> IDX, ARG: 0 AAA
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationContext($,$,$,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: AAA
entity_instance.py -> setitem -> ATTR_TYPE: String
file.py -> create_entity -> IDX, ARG: 1 BBB
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationContext('AAA',$,$,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: BBB
entity_instance.py -> setitem -> ATTR_TYPE: String
file.py -> create_entity -> IDX, ARG: 2 3
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationContext('AAA','BBB',$,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: 3
entity_instance.py -> setitem -> ATTR_TYPE: Int
file.py -> create_entity -> IDX, ARG: 3 0.0001
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationContext('AAA','BBB',3,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: 0.0001
entity_instance.py -> setitem -> ATTR_TYPE: Double
file.py -> create_entity -> IDX, ARG: 4 #79=IfcAxis2Placement3D(#76,#77,#78)
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: #79=IfcAxis2Placement3D(#76,#77,#78)
entity_instance.py -> setitem -> ATTR_TYPE: EntityInstance
file.py -> create_entity -> IDX, ARG: 5 None
file.py -> create_entity -> E: IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,#79,$)
file.py -> create_entity -> E: #159=IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,#79,$)
file.py -> create_entity -> ARGS: ('A', 'B', #159=IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,#79,$), None, <ifcgeometricprojectionenum.model_view: (2,)="">, None)
file.py -> create_entity -> KWARGS: {}
ifcopenshell_wrapper.py -> _swig_getattr -> SELF, CLASS_TYPE, NAME: file.py -> create_entity -> E: IfcGeometricRepresentationSubContext($,$,,,,,$,$,$,$)
file.py -> create_entity -> ATTRS: [(0, 'A'), (1, 'B'), (2, #159=IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,#79,$)), (3, None), (4, <ifcgeometricprojectionenum.model_view: (2,)="">), (5, None)]</ifcgeometricprojectionenum.model_view:>
file.py -> create_entity -> IDX, ARG: 0 A
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationSubContext($,$,,,,,$,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: A
entity_instance.py -> setitem -> ATTR_TYPE: String
file.py -> create_entity -> IDX, ARG: 1 B
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationSubContext('A',$,,,,,$,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: B
entity_instance.py -> setitem -> ATTR_TYPE: String
file.py -> create_entity -> IDX, ARG: 2 #159=IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,#79,$)
entity_instance.py -> setitem -> WRAPPED_DATA: IfcGeometricRepresentationSubContext('A','B',,,,,$,$,$,$)
entity_instance.py -> setitem -> UNWRAP_VALUE: #159=IfcGeometricRepresentationContext('AAA','BBB',3,0.0001,#79,$)
entity_instance.py -> setitem -> ATTR_TYPE: Derived
ifcopenshell_wrapper.py -> _swig_getattr -> SELF, CLASS_TYPE, NAME: IfcGeometricRepresentationSubContext('A','B',,,,,$,$,$,$) <class 'ifcopenshell.ifcopenshell_wrapper.entity_instance'=""> setArgumentAsDerived
ifcopenshell_wrapper.py -> _swig_getattr_nondynamic -> SELF, NAME : IfcGeometricRepresentationSubContext('A','B',,,,,$,$,$,$) setArgumen</class></ifcgeometricprojectionenum.model_view:>
(How can a function with derived/omitted parameters be correctly invoked? Can anyone correct this invocation?)
2) As regards the use of an enumeration data type (such as IfcGeometricProjectionEnum), I'm trying to invoke the function in this way:
ifcfile.createIfcGeometricRepresentationSubContext("A","B",context,None,IfcGeometricProjectionEnum.MODEL_VIEW,None)
even if I don't know how I can do it (IfcGeometricProjectionEnum seems not to be defined); however the execution stops on the reporter error.
How enumeration data types can be used?
What version of IfcOpenShell are you using? I need to look into this. For now maybe quickest way is to use keyword arguments.
Just assign the enumeration value you want to assign as a string.
"MODEL_VIEW"in this case.Thank you very much! Now It works!
However, I'm using IfcOpenshell-python for python2.7 64bit Linux - v0.50-preview2 (github.com)
Last edit: Mariangela De Angelis 2018-10-31
Fyi. I just addressed this in the code as well now (but you'll have to compile the C++ sources yourself to see or wait for the automated builds). You can now supply
Nonefor the derived attributes if you use only positional arguments. I think it's better to use keyword arguments to prevent confusion in these cases. Anyway, thanks for reporting this.