Draft: Fixed bug in edit mode - Fixes #4047
This commit is contained in:
@@ -82,13 +82,16 @@ class Edit():
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
self.call = None
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
self.finish()
|
||||
return
|
||||
|
||||
self.parseSelection()
|
||||
|
||||
if not self.obj:
|
||||
for obj in FreeCADGui.Selection.getSelection():
|
||||
self.finish()
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
self.finish()
|
||||
return
|
||||
|
||||
# store selectable state of the object
|
||||
if hasattr(self.obj.ViewObject,"Selectable"):
|
||||
@@ -120,19 +123,20 @@ class Edit():
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(translate("draft", "No edit point found for selected object")+"\n")
|
||||
self.finish()
|
||||
return
|
||||
|
||||
def parseSelection(self):
|
||||
selection = FreeCADGui.Selection.getSelection()
|
||||
if len(selection) != 1:
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Please select only one object")+"\n")
|
||||
self.finish()
|
||||
try:
|
||||
if "Proxy" in selection[0].PropertiesList and hasattr(selection[0].Proxy,"Type"):
|
||||
if Draft.getType(selection[0]) in self.supportedObjs:
|
||||
self.obj = selection[0]
|
||||
except:
|
||||
FreeCAD.Console.PrintWarning(translate("draft", "This object is not editable")+"\n")
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Please select exactly one object")+"\n")
|
||||
self.finish()
|
||||
return
|
||||
if "Proxy" in selection[0].PropertiesList and hasattr(selection[0].Proxy,"Type"):
|
||||
if Draft.getType(selection[0]) in self.supportedObjs:
|
||||
self.obj = selection[0]
|
||||
return
|
||||
FreeCAD.Console.PrintWarning(translate("draft", "This object is not editable")+"\n")
|
||||
return
|
||||
|
||||
def getPlacement(self,obj):
|
||||
if "Placement" in obj.PropertiesList:
|
||||
@@ -353,8 +357,9 @@ class Edit():
|
||||
if FreeCADGui.Snapper.grid:
|
||||
FreeCADGui.Snapper.grid.set()
|
||||
self.running = False
|
||||
# following line causes crash
|
||||
# FreeCADGui.ActiveDocument.resetEdit()
|
||||
# delay resetting edit mode otherwise it doesn't happen
|
||||
from PySide import QtCore
|
||||
QtCore.QTimer.singleShot(0,FreeCADGui.ActiveDocument.resetEdit)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# PREVIEW
|
||||
@@ -1120,4 +1125,4 @@ class Edit():
|
||||
if self.editing == 0:
|
||||
self.obj.TagPosition = self.invpl.multVec(v)
|
||||
else:
|
||||
self.obj.Group[self.editing-1].Placement.Base = self.invpl.multVec(v)
|
||||
self.obj.Group[self.editing-1].Placement.Base = self.invpl.multVec(v)
|
||||
|
||||
@@ -4715,13 +4715,16 @@ class Shape2DView(Modifier):
|
||||
if "Face" in e:
|
||||
faces.append(int(e[4:])-1)
|
||||
#print(objs,faces)
|
||||
if len(objs) == 1:
|
||||
if faces:
|
||||
Draft.makeShape2DView(objs[0],vec,facenumbers=faces)
|
||||
return
|
||||
for o in objs:
|
||||
Draft.makeShape2DView(o,vec)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
commitlist = []
|
||||
FreeCADGui.addModule("Draft")
|
||||
if (len(objs) == 1) and faces:
|
||||
commitlist.append("Draft.makeShape2DView(FreeCAD.ActiveDocument."+objs[0].Name+",FreeCAD.Vector"+str(tuple(vec))+",facenumbers="+str(faces)+")")
|
||||
else:
|
||||
for o in objs:
|
||||
commitlist.append("Draft.makeShape2DView(FreeCAD.ActiveDocument."+o.Name+",FreeCAD.Vector"+str(tuple(vec))+")")
|
||||
if commitlist:
|
||||
commitlist.append("FreeCAD.ActiveDocument.recompute()")
|
||||
self.commit(translate("draft","Create 2D view"),commitlist)
|
||||
self.finish()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user