Skip to content

Commit

Permalink
Merge pull request #250 from kbwbe/lcs
Browse files Browse the repository at this point in the history
modified saving/restoring of transparency
  • Loading branch information
kbwbe authored Mar 13, 2019
2 parents be06106 + 1799b5b commit 03b297d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
2 changes: 1 addition & 1 deletion InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__title__ = 'A2plus assembly Workbench - InitGui file'
__author__ = 'kbwbe'

A2P_VERSION = 'V0.4.3'
A2P_VERSION = 'V0.4.4'



Expand Down
51 changes: 16 additions & 35 deletions a2plib.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,55 +216,36 @@ def setTransparency():
return

shapedObs = filterShapeObs(doc.Objects) # filter out partlist, spreadsheets etc..

sel = FreeCADGui.Selection

for obj in shapedObs:
if hasattr(obj,'ViewObject'):
if hasattr(obj.ViewObject,'Transparency'):
if hasattr(obj.ViewObject,'DiffuseColor'):
SAVED_TRANSPARENCY.append(
(obj.Name, obj.ViewObject.Transparency, obj.ViewObject.DiffuseColor)
)
else:
SAVED_TRANSPARENCY.append(
(obj.Name, obj.ViewObject.Transparency, obj.ViewObject.ShapeColor)
)
if hasattr(obj,'ViewObject'): # save "all-in" *MK
if hasattr(obj.ViewObject,'DiffuseColor'):
SAVED_TRANSPARENCY.append(
(obj.Name, obj.ViewObject.Transparency, obj.ViewObject.ShapeColor, obj.ViewObject.DiffuseColor)
)
else:
if hasattr(obj.ViewObject,'DiffuseColor'):
SAVED_TRANSPARENCY.append(
(obj.Name, obj.ViewObject.DiffuseColor)
)
else:
if hasattr(obj.ViewObject,'ShapeColor'):
SAVED_TRANSPARENCY.append(
(obj.Name, obj.ViewObject.ShapeColor)
)
SAVED_TRANSPARENCY.append(
(obj.Name, obj.ViewObject.Transparency, obj.ViewObject.ShapeColor, None)
)

obj.ViewObject.Transparency = 80
sel.addSelection(obj) # Transparency workaround. Transparency is taken when once been selected
sel.clearSelection()

sel.clearSelection()
#------------------------------------------------------------------------------
def restoreTransparency():
global SAVED_TRANSPARENCY
# restore transparency of objects...
doc = FreeCAD.ActiveDocument

sel = FreeCADGui.Selection
sel.clearSelection()

for setting in SAVED_TRANSPARENCY:
obj = doc.getObject(setting[0])
if obj is not None:
if hasattr(obj.ViewObject,'Transparency'):
if not hasattr(obj.ViewObject,'DiffuseColor'):
obj.ViewObject.ShapeColor = setting[2]
else:
obj.ViewObject.DiffuseColor = setting[2]
obj.ViewObject.Transparency = setting[1]
else:
if not hasattr(obj.ViewObject,'DiffuseColor'):
obj.ViewObject.ShapeColor = setting[1]
else:
obj.ViewObject.DiffuseColor = setting[1]
if obj is not None: # restore "all-in" *MK
obj.ViewObject.Transparency = setting[1]
obj.ViewObject.ShapeColor = setting[2]
obj.ViewObject.DiffuseColor = setting[3] # diffuse always at last
sel.addSelection(obj)
sel.clearSelection()

Expand Down

0 comments on commit 03b297d

Please sign in to comment.