From ec97d10a51c4da1897c7e8edefe3a605f085bf73 Mon Sep 17 00:00:00 2001 From: Youen Date: Sat, 14 Jan 2023 16:10:13 +0100 Subject: [PATCH] Added possibility to hide specific objects in the rasterized image --- ahb_cmd_new_step.py | 1 + ahb_raster_view.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ahb_cmd_new_step.py b/ahb_cmd_new_step.py index 846ce7c..92d9f43 100644 --- a/ahb_cmd_new_step.py +++ b/ahb_cmd_new_step.py @@ -74,6 +74,7 @@ class AHB_New_Step: view.CoarseView = True view.addProperty("App::PropertyString", "Assembly_handbook_PreviousStepView", "Assembly_handbook") view.addProperty("App::PropertyBool", "Assembly_handbook_RasterView", "Assembly_handbook") + view.addProperty("App::PropertyXLinkList", "Assembly_handbook_HideParts", "Assembly_handbook") view.Assembly_handbook_RasterView = raster_view if raster_view: view.Visibility = False diff --git a/ahb_raster_view.py b/ahb_raster_view.py index 0200bff..20eef18 100644 --- a/ahb_raster_view.py +++ b/ahb_raster_view.py @@ -132,6 +132,11 @@ class RasterView: prev_parts = [] new_parts = [] all_parts = view.XSource + view.Source + + objects_to_hide = [] + if 'Assembly_handbook_HideParts' in view.PropertiesList: + objects_to_hide = self._flatten_objects_tree(view.Assembly_handbook_HideParts) + for part in all_parts: link = tmp_doc.addObject('App::Link', part.Name) link.Label = part.Label @@ -180,12 +185,12 @@ class RasterView: else: prev_parts.append(link) - # hide objects that we don't want to display ; also make a backup of properties we want to reset after we're done + # hide objects that we don't want to display ; also make a backup of properties we want to reset after we're done for obj in self._flatten_objects_tree([link]): if obj in objects_to_reset.keys(): continue - if self._should_render(obj): + if self._should_render(obj) and not obj in objects_to_hide: if not fast_render: objects_to_reset[obj] = ( obj.ViewObject.Visibility, @@ -285,7 +290,7 @@ class RasterView: # restore properties on objects we have modified for obj, props in objects_to_reset.items(): obj.ViewObject.Visibility = props[0] - if self._should_render(obj): + if self._should_render(obj) and not obj in objects_to_hide: obj.ViewObject.LineColor = props[1] obj.ViewObject.ShapeMaterial.AmbientColor = props[2] obj.ViewObject.ShapeMaterial.DiffuseColor = props[3]