Draft: split FilterObjectsForModifiers from Draft.py

This commit is contained in:
carlopav
2020-04-26 10:44:44 +02:00
committed by Yorik van Havre
parent 2b79869274
commit 8157b86629
2 changed files with 30 additions and 22 deletions

View File

@@ -955,6 +955,31 @@ def get_movable_children(objectslist, recursive=True):
getMovableChildren = get_movable_children
def filter_objects_for_modifiers(objects, isCopied=False):
filteredObjects = []
for obj in objects:
if hasattr(obj, "MoveBase") and obj.MoveBase and obj.Base:
parents = []
for parent in obj.Base.InList:
if parent.isDerivedFrom("Part::Feature"):
parents.append(parent.Name)
if len(parents) > 1:
warningMessage = _tr("%s shares a base with %d other objects. Please check if you want to modify this.") % (obj.Name,len(parents) - 1)
App.Console.PrintError(warningMessage)
if App.GuiUp:
FreeCADGui.getMainWindow().showMessage(warningMessage, 0)
filteredObjects.append(obj.Base)
elif hasattr(obj,"Placement") and obj.getEditorMode("Placement") == ["ReadOnly"] and not isCopied:
App.Console.PrintError(_tr("%s cannot be modified because its placement is readonly.") % obj.Name)
continue
else:
filteredObjects.append(obj)
return filteredObjects
filterObjectsForModifiers = filter_objects_for_modifiers
def utf8_decode(text):
r"""Decode the input string and return a unicode string.