From 507914a4c11e1710a94c8d8e1a41461b9068bb26 Mon Sep 17 00:00:00 2001 From: didi-ux <61912702+didi-ux@users.noreply.github.com> Date: Wed, 29 Apr 2020 15:51:13 +0200 Subject: [PATCH] Fix visualization for pythonocc 7.4.0 Following up the issue disscused here: https://sourceforge.net/p/ifcopenshell/discussion/1782717/thread/06e3103d93/ The yield and for-loop in initialize_display() changed slightly, 'GetHandles' and 'SetDiffuse' were removed. The directions are now V3d_TypeOfOrientation enumerations (randomly chosen by me) instead of tuples of integers. --- .../ifcopenshell/geom/occ_utils.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py index 8455d477329..0565f836fbf 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py @@ -60,11 +60,11 @@ def initialize_display(): def setup(): viewer_handle = handle.GetViewer() - viewer = viewer_handle.GetObject() + viewer = viewer_handle.GetObject() if hasattr(viewer_handle, "GetObject") else viewer_handle def lights(): viewer.InitActiveLights() - while True: + for _ in range(2): try: active_light = viewer.ActiveLight() except BaseException: @@ -76,10 +76,10 @@ def lights(): for l in lights: viewer.DelLight(l) - for dir in [(3, 2, 1), (-1, -2, -3)]: + for dir in [V3d.V3d_TypeOfOrientation_Yup_AxoRight, V3d.V3d_TypeOfOrientation_Zup_AxoRight]: light = V3d.V3d_DirectionalLight(viewer_handle) - light.SetDirection(*dir) - viewer.SetLightOn(light.GetHandle()) + light.SetDirection(dir) + viewer.SetLightOn(light) setup() return handle @@ -102,7 +102,6 @@ def display_shape(shape, clr=None, viewer_handle=None): representation = None material = Graphic3d.Graphic3d_MaterialAspect(Graphic3d.Graphic3d_NOM_PLASTER) - material.SetDiffuse(1) if representation and not clr: if len(set(representation.styles)) == 1: @@ -178,7 +177,7 @@ def r(): clr = Quantity.Quantity_Color(r(), r(), r(), Quantity.Quantity_TOC_RGB) ais.SetColor(clr) - ais_handle = ais.GetHandle() + ais_handle = ais viewer_handle.Context.Display(ais_handle, False) return ais_handle