Browse Source

possibility to set stage on groups (wip)

pull/1/head
Youen Toupin 3 years ago
parent
commit
819644560a
  1. 15
      ahb_cmd_set_part_stage.py
  2. 13
      ahb_context.py

15
ahb_cmd_set_part_stage.py

@ -22,15 +22,22 @@ class AHB_SetPartStage:
obj: App.DocumentObject
for obj in Gui.Selection.getSelection():
if obj is not None and obj.TypeId == 'Part::Feature':
if obj is not None and obj.TypeId in ['Part::Feature','App::Part']:
if not "AssemblyHandbook_Stage" in obj.PropertiesList:
obj.addProperty("App::PropertyInteger", "AssemblyHandbook_Stage", "AssemblyHandbook")
if not "AssemblyHandbook_RenderLines" in obj.PropertiesList:
obj.addProperty("App::PropertyBool", "AssemblyHandbook_RenderLines", "AssemblyHandbook")
obj.AssemblyHandbook_RenderLines = True
if obj.AssemblyHandbook_Stage != stageId:
obj.AssemblyHandbook_Stage = stageId
workbench.context.onPartStageChanged(obj)
obj.AssemblyHandbook_Stage = stageId
# if we are setting the stage on a part, remove the property from all features of that part
if obj.TypeId == 'App::Part':
for feature in obj.Group:
if 'AssemblyHandbook_Stage' in feature.PropertiesList:
feature.removeProperty('AssemblyHandbook_Stage')
workbench.context.onPartStageChanged(obj)
from ahb_command import AHB_CommandWrapper
AHB_CommandWrapper.addGuiCommand('AHB_setPartStage', AHB_SetPartStage())

13
ahb_context.py

@ -39,7 +39,7 @@ class AHB_Context:
doc = App.ActiveDocument
for obj in doc.Objects:
if obj.TypeId == 'Part::Feature':
if obj.TypeId in ['Part::Feature', 'App::Part']:
if 'AssemblyHandbook_Stage' in obj.PropertiesList:
allStages.add(obj.AssemblyHandbook_Stage)
@ -56,10 +56,15 @@ class AHB_Context:
part.ViewObject.ShapeColor = (0.8,0.8,0.8,0.0)
for obj in doc.Objects:
if obj.TypeId == 'Part::Feature':
if obj.TypeId in ['Part::Feature', 'App::Part']:
if 'AssemblyHandbook_Stage' in obj.PropertiesList:
stageIndex = allStages.index(obj.AssemblyHandbook_Stage)
obj.ViewObject.ShapeColor = _colors[stageIndex % len(_colors)]
if obj.TypeId == 'Part::Feature':
obj.ViewObject.ShapeColor = _colors[stageIndex % len(_colors)]
elif obj.TypeId == 'App::Part':
for feature in obj.Group:
if feature.TypeId == 'Part::Feature':
feature.ViewObject.ShapeColor = _colors[stageIndex % len(_colors)]
self._updateVisibility()
@ -75,7 +80,7 @@ class AHB_Context:
doc = App.ActiveDocument
for obj in doc.Objects:
if obj.TypeId == 'Part::Feature':
if obj.TypeId == 'Part::Feature' in ['Part::Feature', 'App::Part']:
if 'AssemblyHandbook_Stage' in obj.PropertiesList:
obj.ViewObject.Visibility = self._allStagesVisible or activeStageId is None or obj.AssemblyHandbook_Stage <= activeStageId

Loading…
Cancel
Save