Reuse projection settings from an existing view when creating new draft views.

Select a draft object and a view on a drawing page, then the view created for
the draft object will have the same projection settings as the selected view.
This commit is contained in:
Michael Georg Hansen 2014-12-17 21:56:02 +01:00 committed by wmayer
parent ef24aaa3ce
commit 1816f88575
2 changed files with 29 additions and 8 deletions

View File

@ -2154,7 +2154,7 @@ def getrgb(color,testbw=True):
col = "#000000"
return col
def makeDrawingView(obj,page,lwmod=None,tmod=None):
def makeDrawingView(obj,page,lwmod=None,tmod=None,otherProjection=None):
'''
makeDrawingView(object,page,[lwmod,tmod]) - adds a View of the given object to the
given page. lwmod modifies lineweights (in percent), tmod modifies text heights
@ -2174,6 +2174,21 @@ def makeDrawingView(obj,page,lwmod=None,tmod=None):
viewobj = FreeCAD.ActiveDocument.addObject("Drawing::FeatureViewPython","View"+obj.Name)
_DrawingView(viewobj)
page.addObject(viewobj)
if (otherProjection):
FreeCAD.Console.PrintWarning("using otherProjection")
if hasattr(otherProjection,"Scale"):
FreeCAD.Console.PrintWarning(otherProjection.Scale)
viewobj.Scale = otherProjection.Scale
if hasattr(otherProjection,"X"):
viewobj.X = otherProjection.X
if hasattr(otherProjection,"Y"):
viewobj.Y = otherProjection.Y
if hasattr(otherProjection,"Rotation"):
viewobj.Rotation = otherProjection.Rotation
if hasattr(otherProjection,"Direction"):
FreeCAD.Console.PrintWarning(otherProjection.Direction)
viewobj.Direction = otherProjection.Direction
else:
if hasattr(page.ViewObject,"HintScale"):
viewobj.Scale = page.ViewObject.HintScale
if hasattr(page.ViewObject,"HintOffsetX"):

View File

@ -3150,6 +3150,12 @@ class Drawing(Modifier):
self.page = obj
if not self.page:
self.page = self.createDefaultPage()
otherProjection = None
for obj in sel:
FreeCAD.Console.PrintWarning(obj)
if obj.isDerivedFrom("Drawing::FeatureView"):
otherProjection = obj
FreeCAD.Console.PrintWarning(otherProjection)
sel.reverse()
for obj in sel:
if obj.ViewObject.isVisible():
@ -3158,7 +3164,7 @@ class Drawing(Modifier):
#oldobj = self.page.getObject(name)
#if oldobj:
# self.doc.removeObject(oldobj.Name)
Draft.makeDrawingView(obj,self.page)
Draft.makeDrawingView(obj,self.page,None,None,otherProjection)
self.doc.recompute()
def createDefaultPage(self):