Fix a variety of IFC validation errors in entity creation and asset appending

This commit is contained in:
Dion Moult
2022-10-14 18:19:26 +11:00
parent 10bde73c1a
commit a34c0cb35c
9 changed files with 217 additions and 1395 deletions
@@ -1,13 +1,13 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1');
FILE_NAME('/dev/null','2021-11-08T10:06:41+11:00',(),(),'IfcOpenShell v0.7.0-ab506098','IfcOpenShell v0.7.0-ab506098','Nobody');
FILE_NAME('/dev/null','2022-10-14T18:00:26+11:00',(),(),'IfcOpenShell v0.7.0-dc67287d','IfcOpenShell v0.7.0-dc67287d','Nobody');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROJECT('1oJZZVd$b1PA6ggg_hh4cE',$,'BlenderBIM Demo',$,$,$,$,(#12,#16),#7);
#2=IFCPROJECTLIBRARY('3jWhYPJYL2eOMZ9UZerKqx',$,'BlenderBIM Demo Library',$,$,$,$,$,$);
#3=IFCRELDECLARES('1Wjv8iy5XBshHpEwChjCFa',$,$,$,#1,(#2));
#1=IFCPROJECT('0yOx2IKFL4HAbf$IjzE0Kp',$,'BlenderBIM Demo',$,$,$,$,(#12,#16),#7);
#2=IFCPROJECTLIBRARY('2jUXWJsnH2pxWl9Bl3Ljhd',$,'BlenderBIM Demo Library',$,$,$,$,$,$);
#3=IFCRELDECLARES('0Rn4fWoen7xB9hskGGEfEy',$,$,$,#1,(#2));
#4=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
#5=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
#6=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
@@ -24,82 +24,82 @@ DATA;
#17=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Model',*,*,*,*,#12,$,.MODEL_VIEW.,$);
#18=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Plan',*,*,*,*,#16,$,.PLAN_VIEW.,$);
#19=IFCMATERIAL('Unknown',$,$);
#20=IFCWALLTYPE('24Js5pn1PCeA_DXGWh67_f',$,'DEMO50',$,$,$,$,$,$,$);
#20=IFCWALLTYPE('0D2QFqmA18fvA6TUteIRXc',$,'WAL50',$,$,$,$,$,$,.NOTDEFINED.);
#21=IFCMATERIALLAYERSET((#23),$,$);
#22=IFCRELASSOCIATESMATERIAL('3gPuTuaVf1AAgeln9$alDb',$,$,$,(#20),#21);
#22=IFCRELASSOCIATESMATERIAL('0WbN7alqv8ix3w4MOdyl8F',$,$,$,(#20),#21);
#23=IFCMATERIALLAYER(#19,0.05,$,$,$,$,$);
#24=IFCRELDECLARES('3AJpFBgAf4OQzrklK7UbEn',$,$,$,#2,(#37,#41,#76,#47,#58,#91,#25,#225,#71,#159,#29,#62,#95,#20,#53,#86,#33,#66,#81));
#25=IFCWALLTYPE('1HCqnc9S51NhU$e0Xceg6o',$,'DEMO100',$,$,$,$,$,$,$);
#24=IFCRELDECLARES('13kodoVGr08Bn7WfGWndV_',$,$,$,#2,(#37,#41,#76,#47,#58,#91,#25,#225,#71,#159,#29,#62,#95,#20,#53,#86,#33,#66,#81));
#25=IFCWALLTYPE('0qRxb2OqjDEfFI9i7b6qAw',$,'WAL100',$,$,$,$,$,$,.NOTDEFINED.);
#26=IFCMATERIALLAYERSET((#28),$,$);
#27=IFCRELASSOCIATESMATERIAL('2Ikoi$G2PCXvk61V36wh3N',$,$,$,(#25),#26);
#27=IFCRELASSOCIATESMATERIAL('3BDm6HH553QhwCW7FPmjrR',$,$,$,(#25),#26);
#28=IFCMATERIALLAYER(#19,0.1,$,$,$,$,$);
#29=IFCWALLTYPE('3UPlZcHuTCi8CevFkzQjZ_',$,'DEMO200',$,$,$,$,$,$,$);
#29=IFCWALLTYPE('1KMENjmzj7cf_am9SYEaXW',$,'WAL200',$,$,$,$,$,$,.NOTDEFINED.);
#30=IFCMATERIALLAYERSET((#32),$,$);
#31=IFCRELASSOCIATESMATERIAL('3uAo69i4j4nwMM7VRW3TQn',$,$,$,(#29),#30);
#31=IFCRELASSOCIATESMATERIAL('1$36L06DrDYx1sZ9tBQ_WE',$,$,$,(#29),#30);
#32=IFCMATERIALLAYER(#19,0.2,$,$,$,$,$);
#33=IFCWALLTYPE('1y03E8PfTAJPit3967Y5Uf',$,'DEMO300',$,$,$,$,$,$,$);
#33=IFCWALLTYPE('2y5Y19etz3rhrt8P45fuGA',$,'WAL300',$,$,$,$,$,$,.NOTDEFINED.);
#34=IFCMATERIALLAYERSET((#36),$,$);
#35=IFCRELASSOCIATESMATERIAL('2pvy9lWJL62BoA9QC5KCOG',$,$,$,(#33),#34);
#35=IFCRELASSOCIATESMATERIAL('1WSONmheTD9xhiluqtfktr',$,$,$,(#33),#34);
#36=IFCMATERIALLAYER(#19,0.3,$,$,$,$,$);
#37=IFCCOVERINGTYPE('3ppA8IYrP2nffVvxie6ghZ',$,'DEMO10',$,$,$,$,$,$,$);
#37=IFCCOVERINGTYPE('1pAuiYopL5hxCATiIPV8QG',$,'COV10',$,$,$,$,$,$,.NOTDEFINED.);
#38=IFCMATERIALLAYERSET((#40),$,$);
#39=IFCRELASSOCIATESMATERIAL('2Lg3S9QRH4kPgHpYrtokt6',$,$,$,(#37),#38);
#39=IFCRELASSOCIATESMATERIAL('0ysRf97LT8fw28mDwt2vop',$,$,$,(#37),#38);
#40=IFCMATERIALLAYER(#19,0.01,$,$,$,$,$);
#41=IFCCOVERINGTYPE('3KuCqMbY16DRUygYOrLyYE',$,'DEMO20',$,$,(#45),$,$,$,$);
#41=IFCCOVERINGTYPE('00LbT8PQf3XwImYkj_i_$4',$,'COV20',$,$,(#45),$,$,$,.NOTDEFINED.);
#42=IFCMATERIALLAYERSET((#44),$,$);
#43=IFCRELASSOCIATESMATERIAL('27BA_9uQT6OfxSGgEbsKY4',$,$,$,(#41),#42);
#43=IFCRELASSOCIATESMATERIAL('0Kvr3quG19xw6$528t4NQi',$,$,$,(#41),#42);
#44=IFCMATERIALLAYER(#19,0.02,$,$,$,$,$);
#45=IFCPROPERTYSET('11$WHz$79EMw60BdaUh77w',$,'EPset_Parametric',$,(#46));
#45=IFCPROPERTYSET('1IZqsXecj8NQZcNAIAY48P',$,'EPset_Parametric',$,(#46));
#46=IFCPROPERTYSINGLEVALUE('LayerSetDirection',$,IFCLABEL('AXIS2'),$);
#47=IFCCOVERINGTYPE('2cYyQpe9f1vBW8C4D58QZS',$,'DEMO30',$,$,(#51),$,$,$,$);
#47=IFCCOVERINGTYPE('10YNsLMi9409CbEVFmDkJt',$,'COV30',$,$,(#51),$,$,$,.NOTDEFINED.);
#48=IFCMATERIALLAYERSET((#50),$,$);
#49=IFCRELASSOCIATESMATERIAL('1ir_2IiXX4Ax4VH5lcXGEu',$,$,$,(#47),#48);
#49=IFCRELASSOCIATESMATERIAL('2jZVWXllT9ugYrdBaIBAnt',$,$,$,(#47),#48);
#50=IFCMATERIALLAYER(#19,0.03,$,$,$,$,$);
#51=IFCPROPERTYSET('2IalIx1bj02AXv21tZC0Sz',$,'EPset_Parametric',$,(#52));
#51=IFCPROPERTYSET('2M2_M1eSXFYR8vFE96Ecy1',$,'EPset_Parametric',$,(#52));
#52=IFCPROPERTYSINGLEVALUE('LayerSetDirection',$,IFCLABEL('AXIS3'),$);
#53=IFCRAMPTYPE('23wMhiydD6yw5XpaFs6XCA',$,'DEMO200',$,$,$,$,$,$,$);
#53=IFCRAMPTYPE('09P6PVRiT44vIjup23Olfq',$,'RAM200',$,$,$,$,$,$,.NOTDEFINED.);
#54=IFCMATERIALLAYERSET((#56),$,$);
#55=IFCRELASSOCIATESMATERIAL('2SLXH7fU1D6OIOdV8Gq6T_',$,$,$,(#53),#54);
#55=IFCRELASSOCIATESMATERIAL('2Ghy1OMS1FLAOmdzrFp4rp',$,$,$,(#53),#54);
#56=IFCMATERIALLAYER(#19,0.2,$,$,$,$,$);
#57=IFCCIRCLEPROFILEDEF(.AREA.,$,$,0.3);
#58=IFCPILETYPE('3J5r90lrL3kv3b8uqOGsY1',$,'DEMO1',$,$,$,$,$,$,$);
#58=IFCPILETYPE('0X0OrCsUnDUPVeAu90N_K$',$,'P1',$,$,$,$,$,$,.NOTDEFINED.);
#59=IFCMATERIALPROFILESET($,$,(#61),$);
#60=IFCRELASSOCIATESMATERIAL('2vYxThgzHDSOHXKehbpw4S',$,$,$,(#58),#59);
#60=IFCRELASSOCIATESMATERIAL('1FiRvXL$nBkuT8B3FfiGT9',$,$,$,(#58),#59);
#61=IFCMATERIALPROFILE($,$,#19,#57,$,$);
#62=IFCSLABTYPE('0OWxf_nd97uvH$Sr4QbAVW',$,'DEMO150',$,$,$,$,$,$,$);
#62=IFCSLABTYPE('1helZ086v1o8JD3Ow1eWAy',$,'FLR150',$,$,$,$,$,$,.NOTDEFINED.);
#63=IFCMATERIALLAYERSET((#65),$,$);
#64=IFCRELASSOCIATESMATERIAL('3WSlLxuwH3Sfsul8DwR0LU',$,$,$,(#62),#63);
#64=IFCRELASSOCIATESMATERIAL('3BbM02xKH6h97dBaMJp$Rr',$,$,$,(#62),#63);
#65=IFCMATERIALLAYER(#19,0.2,$,$,$,$,$);
#66=IFCSLABTYPE('0wVKQLFFb2oAHccogmWWWy',$,'DEMO250',$,$,$,$,$,$,$);
#66=IFCSLABTYPE('1YAagoi$9D_hPiWtssbkcG',$,'FLR250',$,$,$,$,$,$,.NOTDEFINED.);
#67=IFCMATERIALLAYERSET((#69),$,$);
#68=IFCRELASSOCIATESMATERIAL('01R$pwjx14qOlDDfB34EBC',$,$,$,(#66),#67);
#68=IFCRELASSOCIATESMATERIAL('0m1oulHjT1u889pxJG$XG_',$,$,$,(#66),#67);
#69=IFCMATERIALLAYER(#19,0.3,$,$,$,$,$);
#70=IFCRECTANGLEPROFILEDEF(.AREA.,$,$,0.5,0.6);
#71=IFCCOLUMNTYPE('2OGUvw6Tj9deH3dTY4Hk3T',$,'DEMO1',$,$,$,$,$,$,$);
#71=IFCCOLUMNTYPE('1lzPzyyFfFYRgjqMHnKZLx',$,'C1',$,$,$,$,$,$,.NOTDEFINED.);
#72=IFCMATERIALPROFILESET($,$,(#74),$);
#73=IFCRELASSOCIATESMATERIAL('1f717ijc53DgmnoMRFBZ62',$,$,$,(#71),#72);
#73=IFCRELASSOCIATESMATERIAL('26fuP2VpfEnhlUsk0K1i4y',$,$,$,(#71),#72);
#74=IFCMATERIALPROFILE($,$,#19,#70,$,$);
#75=IFCCIRCLEHOLLOWPROFILEDEF(.AREA.,$,$,0.25,0.005);
#76=IFCCOLUMNTYPE('3_jg43QeDAWvPCl1D0Lw_q',$,'DEMO2',$,$,$,$,$,$,$);
#76=IFCCOLUMNTYPE('1qqu_K2Az3yvZSOapZmUrZ',$,'C2',$,$,$,$,$,$,.NOTDEFINED.);
#77=IFCMATERIALPROFILESET($,$,(#79),$);
#78=IFCRELASSOCIATESMATERIAL('3mX_vYbF92vxfOrjZFAuYk',$,$,$,(#76),#77);
#78=IFCRELASSOCIATESMATERIAL('2YQz9JCGXAogjkmN3RZeKI',$,$,$,(#76),#77);
#79=IFCMATERIALPROFILE($,$,#19,#75,$,$);
#80=IFCRECTANGLEHOLLOWPROFILEDEF(.AREA.,$,$,0.075,0.15,0.005,0.005,0.005);
#81=IFCCOLUMNTYPE('2ZJTQa2Db0MAv2N5bjUuXK',$,'DEMO3',$,$,$,$,$,$,$);
#81=IFCCOLUMNTYPE('1rnXRgQ3X6pfk5O9j4HCLm',$,'C3',$,$,$,$,$,$,.NOTDEFINED.);
#82=IFCMATERIALPROFILESET($,$,(#84),$);
#83=IFCRELASSOCIATESMATERIAL('0Yslq2hlz9Qe3PO16oqESz',$,$,$,(#81),#82);
#83=IFCRELASSOCIATESMATERIAL('2CQLZ1qlzA9uN2eRrpg99c',$,$,$,(#81),#82);
#84=IFCMATERIALPROFILE($,$,#19,#80,$,$);
#85=IFCISHAPEPROFILEDEF(.AREA.,'DEMO-I',$,0.1,0.2,0.005,0.01,0.005,$,$);
#86=IFCBEAMTYPE('2bUnl1uHnB$QSMF_fVajUw',$,'DEMO1',$,$,$,$,$,$,$);
#86=IFCBEAMTYPE('1xjrF860f2H9zb04Ui98Rt',$,'B1',$,$,$,$,$,$,.NOTDEFINED.);
#87=IFCMATERIALPROFILESET($,$,(#89),$);
#88=IFCRELASSOCIATESMATERIAL('08d9DxbyHAyRgRPc6W4Qsn',$,$,$,(#86),#87);
#88=IFCRELASSOCIATESMATERIAL('03i9c81690fx2ZTBBXcqkL',$,$,$,(#86),#87);
#89=IFCMATERIALPROFILE($,$,#19,#85,$,$);
#90=IFCCSHAPEPROFILEDEF(.AREA.,'DEMO-C',$,0.2,0.1,0.0015,0.03,0.005);
#91=IFCBEAMTYPE('0f1mNiwDTAiuSgrvotHh5$',$,'DEMO2',$,$,$,$,$,$,$);
#91=IFCBEAMTYPE('3mAc_7AGP06w4CzYOlYVL2',$,'B2',$,$,$,$,$,$,.NOTDEFINED.);
#92=IFCMATERIALPROFILESET($,$,(#94),$);
#93=IFCRELASSOCIATESMATERIAL('2cO0XhlFf8MxIg_eNDWX_X',$,$,$,(#91),#92);
#93=IFCRELASSOCIATESMATERIAL('2xvXgaSvL7KPR25fXz0fSE',$,$,$,(#91),#92);
#94=IFCMATERIALPROFILE($,$,#19,#90,$,$);
#95=IFCWINDOWTYPE('0ihTx2Iw1E2gRAq1N4pWVg',$,'DEMO1',$,$,$,(#136,#158),$,$,$,$,$,$);
#95=IFCWINDOWTYPE('1kxjrhA4P2dwwueZ0_nSuu',$,'WT01',$,$,$,(#136,#158),$,$,.NOTDEFINED.,.NOTDEFINED.,$,$);
#96=IFCINDEXEDPOLYGONALFACE((13,17,18,14));
#97=IFCINDEXEDPOLYGONALFACE((5,6,3,4));
#98=IFCINDEXEDPOLYGONALFACE((7,8,2,1));
@@ -126,14 +126,14 @@ DATA;
#119=IFCPOLYGONALFACESET(#118,$,(#96,#97,#98,#99,#100,#102,#103,#104,#105,#106,#107,#108,#109,#110,#111,#112),$);
#120=IFCPOLYGONALFACESET(#118,$,(#101,#113,#114,#115,#116,#117),$);
#121=IFCSHAPEREPRESENTATION(#17,'Body','Tessellation',(#119,#120));
#122=IFCSURFACESTYLE('Frame',.BOTH.,(#125));
#123=IFCCOLOURRGB($,0.0429765619337559,0.0429765619337559,0.0429765619337559);
#122=IFCSURFACESTYLE('Frame',.BOTH.,(#123));
#123=IFCSURFACESTYLERENDERING(#124,0.,#125,$,$,$,IFCNORMALISEDRATIOMEASURE(0.),IFCSPECULARROUGHNESS(0.4),.NOTDEFINED.);
#124=IFCCOLOURRGB($,0.0429765619337559,0.0429765619337559,0.0429765619337559);
#125=IFCSURFACESTYLERENDERING(#123,0.,#124,$,$,$,$,$,$);
#126=IFCSURFACESTYLE('Glass',.BOTH.,(#129));
#127=IFCCOLOURRGB($,0.800000011920929,1.,1.);
#125=IFCCOLOURRGB($,0.800000011920929,0.800000011920929,0.800000011920929);
#126=IFCSURFACESTYLE('Glass',.BOTH.,(#127));
#127=IFCSURFACESTYLERENDERING(#128,0.,#129,$,$,$,IFCNORMALISEDRATIOMEASURE(0.),IFCSPECULARROUGHNESS(0.5),.NOTDEFINED.);
#128=IFCCOLOURRGB($,0.800000011920929,1.,1.);
#129=IFCSURFACESTYLERENDERING(#127,0.799999997019768,#128,$,$,$,$,$,$);
#129=IFCCOLOURRGB($,0.800000011920929,0.800000011920929,0.800000011920929);
#130=IFCSTYLEDITEM(#119,(#122),'Frame');
#131=IFCSTYLEDITEM(#120,(#126),'Glass');
#132=IFCCARTESIANPOINT((0.,0.,0.));
@@ -163,7 +163,7 @@ DATA;
#156=IFCDIRECTION((0.,0.,1.));
#157=IFCAXIS2PLACEMENT3D(#154,#156,#155);
#158=IFCREPRESENTATIONMAP(#157,#153);
#159=IFCDOORTYPE('0HLh8Cp3f58hay4OhB7SHy',$,'DEMO1',$,$,$,(#204,#224),$,$,$,$,$,$);
#159=IFCDOORTYPE('0s370BWH51r8Xg03pJ5OBE',$,'DT01',$,$,$,(#204,#224),$,$,.NOTDEFINED.,.NOTDEFINED.,$,$);
#160=IFCINDEXEDPOLYGONALFACE((17,16,15,14));
#161=IFCINDEXEDPOLYGONALFACE((2,3,29,28));
#162=IFCINDEXEDPOLYGONALFACE((27,28,29,30,32,31));
@@ -194,14 +194,14 @@ DATA;
#187=IFCPOLYGONALFACESET(#186,$,(#161,#162,#163,#164,#165,#166,#169,#170,#171,#172,#173,#174,#175,#176,#179,#180,#182,#183,#184,#185),$);
#188=IFCPOLYGONALFACESET(#186,$,(#160,#167,#168,#177,#178,#181),$);
#189=IFCSHAPEREPRESENTATION(#17,'Body','Tessellation',(#187,#188));
#190=IFCSURFACESTYLE('Frame',.BOTH.,(#193));
#191=IFCCOLOURRGB($,0.0429765619337559,0.0429765619337559,0.0429765619337559);
#190=IFCSURFACESTYLE('Frame',.BOTH.,(#191));
#191=IFCSURFACESTYLERENDERING(#192,0.,#193,$,$,$,IFCNORMALISEDRATIOMEASURE(0.),IFCSPECULARROUGHNESS(0.4),.NOTDEFINED.);
#192=IFCCOLOURRGB($,0.0429765619337559,0.0429765619337559,0.0429765619337559);
#193=IFCSURFACESTYLERENDERING(#191,0.,#192,$,$,$,$,$,$);
#194=IFCSURFACESTYLE('Panel',.BOTH.,(#197));
#195=IFCCOLOURRGB($,0.184475064277649,0.184475019574165,0.184475019574165);
#193=IFCCOLOURRGB($,0.800000011920929,0.800000011920929,0.800000011920929);
#194=IFCSURFACESTYLE('Panel',.BOTH.,(#195));
#195=IFCSURFACESTYLERENDERING(#196,0.,#197,$,$,$,IFCNORMALISEDRATIOMEASURE(0.),IFCSPECULARROUGHNESS(0.5),.NOTDEFINED.);
#196=IFCCOLOURRGB($,0.184475064277649,0.184475019574165,0.184475019574165);
#197=IFCSURFACESTYLERENDERING(#195,0.,#196,$,$,$,$,$,$);
#197=IFCCOLOURRGB($,0.800000011920929,0.800000011920929,0.800000011920929);
#198=IFCSTYLEDITEM(#187,(#190),'Frame');
#199=IFCSTYLEDITEM(#188,(#194),'Panel');
#200=IFCCARTESIANPOINT((0.,0.,0.));
@@ -229,7 +229,7 @@ DATA;
#222=IFCDIRECTION((0.,0.,1.));
#223=IFCAXIS2PLACEMENT3D(#220,#222,#221);
#224=IFCREPRESENTATIONMAP(#223,#219);
#225=IFCFURNITURETYPE('1wgo6Pw4jDJO4F1GA9Qlmx',$,'BUNNY',$,$,$,(#946,#988),$,$,$,$);
#225=IFCFURNITURETYPE('227RrM$yD30RGzlTgbBH3c',$,'BUN01',$,$,$,(#946,#988),$,$,.NOTDEFINED.,.NOTDEFINED.);
#226=IFCINDEXEDPOLYGONALFACE((187,278,44));
#227=IFCINDEXEDPOLYGONALFACE((21,52,60));
#228=IFCINDEXEDPOLYGONALFACE((91,100,31));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+20 -20
View File
@@ -61,36 +61,36 @@ class LibraryGenerator:
self.material = ifcopenshell.api.run("material.add_material", self.file, name="Unknown")
self.create_layer_type("IfcWallType", "DEMO50", 0.05)
self.create_layer_type("IfcWallType", "DEMO100", 0.1)
self.create_layer_type("IfcWallType", "DEMO200", 0.2)
self.create_layer_type("IfcWallType", "DEMO300", 0.3)
self.create_layer_type("IfcWallType", "WAL50", 0.05)
self.create_layer_type("IfcWallType", "WAL100", 0.1)
self.create_layer_type("IfcWallType", "WAL200", 0.2)
self.create_layer_type("IfcWallType", "WAL300", 0.3)
self.create_layer_type("IfcCoveringType", "DEMO10", 0.01)
self.create_layer_type("IfcCoveringType", "COV10", 0.01)
product = self.create_layer_type("IfcCoveringType", "DEMO20", 0.02)
product = self.create_layer_type("IfcCoveringType", "COV20", 0.02)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=product, name="EPset_Parametric")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"LayerSetDirection": "AXIS2"})
product = self.create_layer_type("IfcCoveringType", "DEMO30", 0.03)
product = self.create_layer_type("IfcCoveringType", "COV30", 0.03)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=product, name="EPset_Parametric")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"LayerSetDirection": "AXIS3"})
self.create_layer_type("IfcRampType", "DEMO200", 0.2)
self.create_layer_type("IfcRampType", "RAM200", 0.2)
profile = self.file.create_entity("IfcCircleProfileDef", ProfileType="AREA", Radius=0.3)
self.create_profile_type("IfcPileType", "DEMO1", profile)
self.create_profile_type("IfcPileType", "P1", profile)
self.create_layer_type("IfcSlabType", "DEMO150", 0.2)
self.create_layer_type("IfcSlabType", "DEMO250", 0.3)
self.create_layer_type("IfcSlabType", "FLR150", 0.2)
self.create_layer_type("IfcSlabType", "FLR250", 0.3)
profile = self.file.create_entity("IfcRectangleProfileDef", ProfileType="AREA", XDim=0.5, YDim=0.6)
self.create_profile_type("IfcColumnType", "DEMO1", profile)
self.create_profile_type("IfcColumnType", "C1", profile)
profile = self.file.create_entity(
"IfcCircleHollowProfileDef", ProfileType="AREA", Radius=0.25, WallThickness=0.005
)
self.create_profile_type("IfcColumnType", "DEMO2", profile)
self.create_profile_type("IfcColumnType", "C2", profile)
profile = self.file.create_entity(
"IfcRectangleHollowProfileDef",
@@ -101,7 +101,7 @@ class LibraryGenerator:
InnerFilletRadius=0.005,
OuterFilletRadius=0.005,
)
self.create_profile_type("IfcColumnType", "DEMO3", profile)
self.create_profile_type("IfcColumnType", "C3", profile)
profile = self.file.create_entity(
"IfcIShapeProfileDef",
@@ -113,7 +113,7 @@ class LibraryGenerator:
FlangeThickness=0.01,
FilletRadius=0.005,
)
self.create_profile_type("IfcBeamType", "DEMO1", profile)
self.create_profile_type("IfcBeamType", "B1", profile)
profile = self.file.create_entity(
"IfcCShapeProfileDef",
@@ -125,13 +125,13 @@ class LibraryGenerator:
Girth=0.03,
InternalFilletRadius=0.005,
)
self.create_profile_type("IfcBeamType", "DEMO2", profile)
self.create_profile_type("IfcBeamType", "B2", profile)
self.create_type("IfcWindowType", "DEMO1", {"body": "Window", "annotation": "Window-Annotation"})
self.create_type("IfcDoorType", "DEMO1", {"body": "Door", "annotation": "Door-Annotation"})
self.create_type("IfcFurnitureType", "BUNNY", {"body": "Bunny", "annotation": "Bunny-Annotation"})
self.create_type("IfcWindowType", "WT01", {"body": "Window", "annotation": "Window-Annotation"})
self.create_type("IfcDoorType", "DT01", {"body": "Door", "annotation": "Door-Annotation"})
self.create_type("IfcFurnitureType", "BUN01", {"body": "Bunny", "annotation": "Bunny-Annotation"})
self.file.write("blenderbim-demo-library.ifc")
self.file.write("IFC4 Demo Library.ifc")
def create_layer_type(self, ifc_class, name, thickness):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
@@ -79,4 +79,6 @@ class Usecase:
RelatedElement=self.settings["related_element"],
RelatingConnectionType=self.settings["relating_connection"],
RelatedConnectionType=self.settings["related_connection"],
RelatingPriorities=[],
RelatedPriorities=[],
)
@@ -66,14 +66,7 @@ class Usecase:
for e in self.file.traverse(element.HasRepresentation[0])
if e.is_a("IfcGeometricRepresentationContext")
]
for added_context in added_contexts:
equivalent_existing_context = self.get_equivalent_existing_context(added_context)
if not equivalent_existing_context:
equivalent_existing_context = self.create_equivalent_context(added_context)
for inverse in self.file.get_inverse(added_context):
ifcopenshell.util.element.replace_attribute(inverse, added_context, equivalent_existing_context)
for added_context in added_contexts:
ifcopenshell.util.element.remove_deep(self.file, added_context)
self.reuse_existing_contexts(added_contexts)
return element
def append_cost_schedule(self):
@@ -101,14 +94,7 @@ class Usecase:
self.existing_contexts = self.file.by_type("IfcGeometricRepresentationContext")
element = self.add_element(self.settings["element"])
added_contexts = [e for e in self.file.traverse(element) if e.is_a("IfcGeometricRepresentationContext")]
for added_context in added_contexts:
equivalent_existing_context = self.get_equivalent_existing_context(added_context)
if not equivalent_existing_context:
equivalent_existing_context = self.create_equivalent_context(added_context)
for inverse in self.file.get_inverse(added_context):
ifcopenshell.util.element.replace_attribute(inverse, added_context, equivalent_existing_context)
for added_context in added_contexts:
ifcopenshell.util.element.remove_deep(self.file, added_context)
self.reuse_existing_contexts(added_contexts)
return element
def append_product(self):
@@ -125,14 +111,7 @@ class Usecase:
self.existing_contexts = self.file.by_type("IfcGeometricRepresentationContext")
element = self.add_element(self.settings["element"])
added_contexts = [e for e in self.file.traverse(element) if e.is_a("IfcGeometricRepresentationContext")]
for added_context in added_contexts:
equivalent_existing_context = self.get_equivalent_existing_context(added_context)
if not equivalent_existing_context:
equivalent_existing_context = self.create_equivalent_context(added_context)
for inverse in self.file.get_inverse(added_context):
ifcopenshell.util.element.replace_attribute(inverse, added_context, equivalent_existing_context)
for added_context in added_contexts:
ifcopenshell.util.element.remove_deep2(self.file, added_context)
self.reuse_existing_contexts(added_contexts)
element_type = ifcopenshell.util.element.get_type(self.settings["element"])
if element_type:
@@ -159,6 +138,7 @@ class Usecase:
new = self.file.add(element)
self.added_elements[element.id()] = new
for subelement in self.settings["library"].traverse(element):
self.added_elements[subelement.id()] = self.file.add(subelement)
self.check_inverses(subelement)
return new
@@ -206,6 +186,16 @@ class Usecase:
return True
return False
def reuse_existing_contexts(self, added_contexts):
for added_context in added_contexts:
equivalent_existing_context = self.get_equivalent_existing_context(added_context)
if not equivalent_existing_context:
equivalent_existing_context = self.create_equivalent_context(added_context)
for inverse in self.file.get_inverse(added_context):
ifcopenshell.util.element.replace_attribute(inverse, added_context, equivalent_existing_context)
for added_context in added_contexts:
ifcopenshell.util.element.remove_deep2(self.file, added_context)
def get_equivalent_existing_context(self, added_context):
for context in self.existing_contexts:
if context.is_a() != added_context.is_a():
@@ -50,14 +50,46 @@ class Usecase:
element.ObjectType = self.settings["predefined_type"]
elif hasattr(element, "ElementType"):
element.ElementType = self.settings["predefined_type"]
elif hasattr(element, "ProcessType"):
element.ProcessType = self.settings["predefined_type"]
elif hasattr(element, "ObjectType"):
element.ObjectType = self.settings["predefined_type"]
if self.file.schema == "IFC2X3":
self.handle_2x3_defaults(element)
elif self.file.schema == "IFC4":
self.handle_4_defaults(element)
return element
def handle_2x3_defaults(self, element):
if element.is_a("IfcElement") or element.is_a("IfcElementType"):
if not element.PredefinedType:
element.PredefinedType = "NOTDEFINED"
if element.is_a("IfcSpatialStructureElement"):
element.CompositionType = "ELEMENT"
elif element.is_a("IfcRoof"):
element.ShapeType = "NOTDEFINED"
elif element.is_a("IfcFurnitureType"):
element.AssemblyPlace = "NOTDEFINED"
elif element.is_a("IfcDoorStyle") or element.is_a("IfcWindowStyle"):
element.OperationType = "NOTDEFINED"
element.ConstructionType = "NOTDEFINED"
element.ParameterTakesPrecedence = False
element.Sizeable = False
def handle_4_defaults(self, element):
if element.is_a("IfcElement") or element.is_a("IfcElementType"):
if not element.PredefinedType:
element.PredefinedType = "NOTDEFINED"
if element.is_a("IfcDoorStyle") or element.is_a("IfcWindowStyle"):
element.OperationType = "NOTDEFINED"
element.ConstructionType = "NOTDEFINED"
element.ParameterTakesPrecedence = False
element.Sizeable = False
elif element.is_a("IfcDoorType"):
element.OperationType = "NOTDEFINED"
elif element.is_a("IfcWindowType"):
element.PartitioningType = "NOTDEFINED"
elif element.is_a("IfcFurnitureType"):
element.AssemblyPlace = "NOTDEFINED"
@@ -69,7 +69,8 @@ class TestAppendAsset(test.bootstrap.IFC4):
library.createIfcStyledItem(Item=item)
mapped_rep = library.createIfcShapeRepresentation(Items=[item])
element.RepresentationMaps = [library.createIfcRepresentationMap(MappedRepresentation=mapped_rep)]
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
new = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
assert len(new.RepresentationMaps[0].MappedRepresentation.Items[0].StyledByItem) == 1
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
def test_append_a_material(self):
@@ -108,6 +109,27 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
context = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
assert context == file_context
assert context.WorldCoordinateSystem
def test_append_a_material_with_a_representation_and_reuse_an_existing_subcontext(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
file_subcontext = ifcopenshell.api.run("context.add_context", self.file, parent=file_context, context_type="Model", context_identifier="Body", target_view="MODEL_VIEW")
library = ifcopenshell.api.run("project.create_file")
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
style = ifcopenshell.api.run("style.add_style", library)
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
subcontext = ifcopenshell.api.run("context.add_context", library, parent=context, context_type="Model", context_identifier="Body", target_view="MODEL_VIEW")
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=subcontext)
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcGeometricRepresentationContext", include_subtypes=False)) == 1
assert len(self.file.by_type("IfcGeometricRepresentationSubContext", include_subtypes=False)) == 1
subcontext = self.file.by_type("IfcMaterial")[0].HasRepresentation[0].Representations[0].ContextOfItems
assert subcontext == file_subcontext
assert subcontext.ParentContext.WorldCoordinateSystem
def test_append_a_material_with_a_representation_and_reuse_an_existing_context_by_a_new_subcontext(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
@@ -0,0 +1,72 @@
# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
#
# This file is part of IfcOpenShell.
#
# IfcOpenShell is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IfcOpenShell is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
class TestCreateEntity(test.bootstrap.IFC4):
def test_creating_a_simple_entity_with_automatic_global_id(self):
wall = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcWall", predefined_type="SOLIDWALL", name="Foo"
)
assert wall.is_a() == "IfcWall"
assert len(wall.GlobalId) == 22
assert wall.Name == "Foo"
assert wall.PredefinedType == "SOLIDWALL"
def test_handling_predefined_types(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall", name="Foo")
assert element.PredefinedType == "NOTDEFINED"
element = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcWall", predefined_type="SHEAR", name="Foo"
)
assert element.PredefinedType == "SHEAR"
element = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcWall", predefined_type="Foobar", name="Foo"
)
assert element.PredefinedType == "USERDEFINED"
assert element.ObjectType == "Foobar"
element = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcWallType", predefined_type="Foobar", name="Foo"
)
assert element.PredefinedType == "USERDEFINED"
assert element.ElementType == "Foobar"
element = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcTaskType", predefined_type="Foobar", name="Foo"
)
assert element.PredefinedType == "USERDEFINED"
assert element.ProcessType == "Foobar"
def test_setting_default_values_for_validity(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorStyle", name="Foo")
assert element.OperationType == "NOTDEFINED"
assert element.ConstructionType == "NOTDEFINED"
assert element.ParameterTakesPrecedence == False
assert element.Sizeable == False
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindowStyle", name="Foo")
assert element.OperationType == "NOTDEFINED"
assert element.ConstructionType == "NOTDEFINED"
assert element.ParameterTakesPrecedence == False
assert element.Sizeable == False
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDoorType", name="Foo")
assert element.OperationType == "NOTDEFINED"
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWindowType", name="Foo")
assert element.PartitioningType == "NOTDEFINED"
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFurnitureType", name="Foo")
assert element.AssemblyPlace == "NOTDEFINED"