@@ -766,7 +766,7 @@ def execute(self, context):
766766 cam_width = context .scene .render .resolution_x
767767 cam_height = context .scene .render .resolution_y
768768 cam_aspect = cam_width / cam_height
769-
769+
770770 if viewpoint .snapshot :
771771 obj .data .show_background_images = True
772772 obj .data .background_images .clear ()
@@ -787,7 +787,7 @@ def execute(self, context):
787787 area .spaces [0 ].region_3d .view_perspective = "CAMERA"
788788
789789 if self .file :
790- self .set_viewpoint_components (viewpoint )
790+ self .set_viewpoint_components (viewpoint , context )
791791
792792 gp = bpy .data .grease_pencils .get ("BCF" )
793793 if gp :
@@ -803,10 +803,10 @@ def execute(self, context):
803803 if viewpoint .bitmaps :
804804 self .create_bitmaps (bcfxml , viewpoint , topic )
805805
806- self .setup_camera (viewpoint , obj , cam_aspect )
806+ self .setup_camera (viewpoint , obj , cam_aspect , context )
807807 return {"FINISHED" }
808808
809- def setup_camera (self , viewpoint , obj , cam_aspect ):
809+ def setup_camera (self , viewpoint , obj , cam_aspect , context ):
810810 if viewpoint .orthogonal_camera :
811811 camera = viewpoint .orthogonal_camera
812812 obj .data .type = "ORTHO"
@@ -831,7 +831,7 @@ def setup_camera(self, viewpoint, obj, cam_aspect):
831831 [x_axis [2 ], y_axis [2 ], z_axis [2 ], camera .camera_view_point .z ],
832832 [0 , 0 , 0 , 1 ],
833833 ))
834- props = bpy . context .scene .BIMGeoreferenceProperties
834+ props = context .scene .BIMGeoreferenceProperties
835835 if props .has_blender_offset :
836836 unit_scale = ifcopenshell .util .unit .calculate_unit_scale (self .file )
837837 matrix = ifcopenshell .util .geolocation .global2local (
@@ -844,7 +844,7 @@ def setup_camera(self, viewpoint, obj, cam_aspect):
844844 )
845845 obj .matrix_world = Matrix (matrix .tolist ())
846846
847- def set_viewpoint_components (self , viewpoint ):
847+ def set_viewpoint_components (self , viewpoint , context ):
848848 if not viewpoint .components :
849849 return
850850
@@ -854,10 +854,10 @@ def set_viewpoint_components(self, viewpoint):
854854 exception_global_ids = [v .ifc_guid for v in viewpoint .components .visibility .exceptions ]
855855
856856 if viewpoint .components .visibility .default_visibility :
857- old = bpy . context .area .type
858- bpy . context .area .type = "VIEW_3D"
857+ old = context .area .type
858+ context .area .type = "VIEW_3D"
859859 bpy .ops .object .hide_view_clear ()
860- bpy . context .area .type = old
860+ context .area .type = old
861861 for global_id in exception_global_ids :
862862 obj = IfcStore .get_element (global_id )
863863 if obj :
@@ -869,35 +869,35 @@ def set_viewpoint_components(self, viewpoint):
869869 if obj :
870870 objs .append (obj )
871871 if objs :
872- old = bpy . context .area .type
873- bpy . context .area .type = "VIEW_3D"
872+ old = context .area .type
873+ context .area .type = "VIEW_3D"
874874 context_override = {}
875875 context_override ["object" ] = context_override ["active_object" ] = objs [0 ]
876876 context_override ["selected_objects" ] = context_override ["selected_editable_objects" ] = objs
877877 bpy .ops .object .hide_view_set (context_override , unselected = True )
878- bpy . context .area .type = old
878+ context .area .type = old
879879
880880 if viewpoint .components .view_setup_hints :
881881 if not viewpoint .components .view_setup_hints .spaces_visible :
882- self .hide_spaces ()
882+ self .hide_spaces (context )
883883 if viewpoint .components .view_setup_hints .openings_visible is not None :
884- self .set_openings_visibility (viewpoint .components .view_setup_hints .openings_visible )
884+ self .set_openings_visibility (viewpoint .components .view_setup_hints .openings_visible , context )
885885 else :
886- self .hide_spaces ()
887- self .set_openings_visibility (False )
886+ self .hide_spaces (context )
887+ self .set_openings_visibility (False , context )
888888
889889 self .set_selection (viewpoint )
890890 self .set_colours (viewpoint )
891891
892- def hide_spaces (self ):
893- old = bpy . context .area .type
894- bpy . context .area .type = "VIEW_3D"
892+ def hide_spaces (self , context ):
893+ old = context .area .type
894+ context .area .type = "VIEW_3D"
895895 bpy .ops .object .select_pattern (pattern = "IfcSpace/*" )
896896 bpy .ops .object .hide_view_set ({})
897- bpy . context .area .type = old
897+ context .area .type = old
898898
899- def set_openings_visibility (self , is_visible ):
900- for collection in self .get_opening_collections ():
899+ def set_openings_visibility (self , is_visible , context ):
900+ for collection in self .get_opening_collections (context ):
901901 collection .hide_viewport = not is_visible
902902
903903 def set_selection (self , viewpoint ):
@@ -918,9 +918,9 @@ def set_colours(self, viewpoint):
918918 if obj :
919919 obj .color = self .hex_to_rgb (color )
920920
921- def get_opening_collections (self ):
921+ def get_opening_collections (self , context ):
922922 collections = []
923- for collection in bpy . context .view_layer .layer_collection .children :
923+ for collection in context .view_layer .layer_collection .children :
924924 opening_collection = collection .children .get ("IfcOpeningElements" )
925925 if opening_collection :
926926 collections .append (opening_collection )
0 commit comments