Draft: split FilterObjectsForModifiers from Draft.py
This commit is contained in:
committed by
Yorik van Havre
parent
7bdf54e933
commit
3351cde462
@@ -141,6 +141,9 @@ from draftutils.utils import svg_patterns
|
||||
from draftutils.utils import getMovableChildren
|
||||
from draftutils.utils import get_movable_children
|
||||
|
||||
from draftutils.utils import filter_objects_for_modifiers
|
||||
from draftutils.utils import filterObjectsForModifiers
|
||||
|
||||
from draftutils.gui_utils import get3DView
|
||||
from draftutils.gui_utils import get_3d_view
|
||||
|
||||
@@ -682,7 +685,7 @@ def move(objectslist,vector,copy=False):
|
||||
objectslist.extend(getMovableChildren(objectslist))
|
||||
newobjlist = []
|
||||
newgroups = {}
|
||||
objectslist = filterObjectsForModifiers(objectslist, copy)
|
||||
objectslist = filter_objects_for_modifiers(objectslist, copy)
|
||||
for obj in objectslist:
|
||||
newobj = None
|
||||
# real_vector have been introduced to take into account
|
||||
@@ -826,26 +829,6 @@ def array(objectslist,arg1,arg2,arg3,arg4=None,arg5=None,arg6=None):
|
||||
else:
|
||||
polarArray(objectslist,arg1,arg2,arg3)
|
||||
|
||||
def filterObjectsForModifiers(objects, isCopied=False):
|
||||
filteredObjects = []
|
||||
for object in objects:
|
||||
if hasattr(object, "MoveBase") and object.MoveBase and object.Base:
|
||||
parents = []
|
||||
for parent in object.Base.InList:
|
||||
if parent.isDerivedFrom("Part::Feature"):
|
||||
parents.append(parent.Name)
|
||||
if len(parents) > 1:
|
||||
warningMessage = translate("draft","%s shares a base with %d other objects. Please check if you want to modify this.") % (object.Name,len(parents) - 1)
|
||||
FreeCAD.Console.PrintError(warningMessage)
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.getMainWindow().showMessage(warningMessage, 0)
|
||||
filteredObjects.append(object.Base)
|
||||
elif hasattr(object,"Placement") and object.getEditorMode("Placement") == ["ReadOnly"] and not isCopied:
|
||||
FreeCAD.Console.PrintError(translate("Draft","%s cannot be modified because its placement is readonly.") % obj.Name)
|
||||
continue
|
||||
else:
|
||||
filteredObjects.append(object)
|
||||
return filteredObjects
|
||||
|
||||
def rotateVertex(object, vertex_index, angle, center, axis):
|
||||
points = object.Points
|
||||
@@ -880,7 +863,7 @@ def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False)
|
||||
objectslist.extend(getMovableChildren(objectslist))
|
||||
newobjlist = []
|
||||
newgroups = {}
|
||||
objectslist = filterObjectsForModifiers(objectslist, copy)
|
||||
objectslist = filter_objects_for_modifiers(objectslist, copy)
|
||||
for obj in objectslist:
|
||||
newobj = None
|
||||
# real_center and real_axis are introduced to take into account
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user