diff --git a/src/Mod/TechDraw/CMakeLists.txt b/src/Mod/TechDraw/CMakeLists.txt
index f81f17dc00..506781aa7b 100644
--- a/src/Mod/TechDraw/CMakeLists.txt
+++ b/src/Mod/TechDraw/CMakeLists.txt
@@ -41,3 +41,37 @@ INSTALL(
FILES_MATCHING
PATTERN "*.csv*"
)
+
+#unit test files
+SET(TDTest_SRCS
+ TDTest/__init__.py
+ TDTest/DHatchTest.py
+ TDTest/DProjGroupTest.py
+ TDTest/DVAnnoSymImageTest.py
+ TDTest/DVDimensionTest.py
+ TDTest/DVPartTest.py
+ TDTest/DVSectionTest.py
+)
+
+SET(TDTestFile_SRCS
+ TDTest/TestHatch.svg
+ TDTest/TestImage.png
+ TDTest/TestSymbol.svg
+ TDTest/TestTemplate.svg
+)
+
+SET(TDAllTest
+ ${TDTest_SRCS}
+ ${TDTestFile_SRCS}
+)
+
+ADD_CUSTOM_TARGET(TDTestTarget ALL
+ SOURCES ${TDAllTest}
+)
+
+fc_copy_sources(TDTestTarget "${CMAKE_BINARY_DIR}/Mod/TechDraw" ${TDAllTest})
+
+# install Python packages (for make install)
+INSTALL(FILES ${TDTest_SRCS} DESTINATION Mod/TechDraw/TDTest)
+INSTALL(FILES ${TDTestFile_SRCS} DESTINATION Mod/TechDraw/TDTest)
+
diff --git a/src/Mod/TechDraw/TDTest/DHatchTest.py b/src/Mod/TechDraw/TDTest/DHatchTest.py
new file mode 100644
index 0000000000..86de504bcc
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/DHatchTest.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# test script for TechDraw module
+# creates a page and 1 views
+# adds a hatch area to view1
+from __future__ import print_function
+
+import FreeCAD
+import Part
+import Measure
+import TechDraw
+
+import os
+
+def DHatchTest():
+ path = os.path.dirname(os.path.abspath(__file__))
+ print ('TDHatch path: ' + path)
+ templateFileSpec = path+'/TestTemplate.svg'
+ hatchFileSpec = path + '/TestHatch.svg'
+
+ FreeCAD.newDocument("TDHatch")
+ FreeCAD.setActiveDocument("TDHatch")
+ FreeCAD.ActiveDocument=FreeCAD.getDocument("TDHatch")
+
+ #make source feature
+ box = FreeCAD.ActiveDocument.addObject("Part::Box","Box")
+
+ #make a page
+ page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage','Page')
+ FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate','Template')
+ FreeCAD.ActiveDocument.Template.Template = templateFileSpec
+ FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
+ page.Scale = 5.0
+# page.ViewObject.show() #unit tests run in console mode
+
+ #make Views
+ view1 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewPart','View')
+ FreeCAD.ActiveDocument.View.Source = [box]
+ rc = page.addView(view1)
+ FreeCAD.ActiveDocument.recompute()
+
+ #make hatch
+ print("making hatch")
+ hatch = FreeCAD.ActiveDocument.addObject('TechDraw::DrawHatch','Hatch')
+ hatch.Source = (view1,["Face0"])
+ hatch.HatchPattern = hatchFileSpec #comment out to use default from preferences
+ print("adding hatch to page")
+ rc = page.addView(hatch)
+ print("finished hatch")
+
+ FreeCAD.ActiveDocument.recompute()
+
+ rc = False
+ if ("Up-to-date" in hatch.State):
+ rc = True
+ FreeCAD.closeDocument("TDHatch")
+ return rc
+
+if __name__ == '__main__':
+ DHatchTest()
diff --git a/src/Mod/TechDraw/TDTest/DProjGroupTest.py b/src/Mod/TechDraw/TDTest/DProjGroupTest.py
new file mode 100644
index 0000000000..7cfd29076f
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/DProjGroupTest.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# test script for TechDraw module
+# creates a Box and a Sphere and makes a Fusions from them
+# creates a page
+# creates a Projection Group
+# adds Front,Left,Top projections to the group
+# a template in the source folder
+from __future__ import print_function
+
+import FreeCAD
+import Part
+import Measure
+import TechDraw
+import os
+
+def DProjGroupTest():
+ path = os.path.dirname(os.path.abspath(__file__))
+ print ('TDGroup path: ' + path)
+ templateFileSpec = path + '/TestTemplate.svg'
+
+ FreeCAD.newDocument("TDGroup")
+ FreeCAD.setActiveDocument("TDGroup")
+ FreeCAD.ActiveDocument=FreeCAD.getDocument("TDGroup")
+
+ #make Fusion feature
+ box = FreeCAD.ActiveDocument.addObject("Part::Box","Box")
+ sphere = FreeCAD.ActiveDocument.addObject("Part::Sphere","Sphere")
+ fusion = FreeCAD.ActiveDocument.addObject("Part::MultiFuse","Fusion")
+ FreeCAD.ActiveDocument.Fusion.Shapes = [box,sphere]
+
+ #make a page
+ print("making a page")
+ page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage','Page')
+ FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate','Template')
+ FreeCAD.ActiveDocument.Template.Template = templateFileSpec
+ FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
+# page.ViewObject.show() #unit tests run in console mode
+
+ #make projection group
+ print("making a projection group")
+ group = FreeCAD.ActiveDocument.addObject('TechDraw::DrawProjGroup','ProjGroup')
+ rc = page.addView(group)
+ group.Source = [fusion]
+
+ print("adding views")
+ leftView = group.addProjection("Left")
+ print("added Left")
+ topView = group.addProjection("Top")
+ print("added Top")
+ rightView = group.addProjection("Right")
+ print("added Right")
+ rearView = group.addProjection("Rear")
+ print("added Rear")
+ BottomView = group.addProjection("Bottom")
+ print("added Bottom")
+
+ #remove a view from projection group
+ #iv = group.removeProjection("Left")
+ #print("removed Left")
+
+ ##test getItemByLabel method
+ print("testing getItemByLabel")
+ label = "Top"
+ item = group.getItemByLabel(label)
+ print("Item Label: " + label + " Item Name: " + item.Name)
+
+ print("recomputing document")
+ FreeCAD.ActiveDocument.recompute()
+
+ rc = False
+ if ("Up-to-date" in group.State):
+ rc = True
+ FreeCAD.closeDocument("TDGroup")
+ return rc
+
+if __name__ == '__main__':
+ DProjGroupTest()
diff --git a/src/Mod/TechDraw/TDTest/DVAnnoSymImageTest.py b/src/Mod/TechDraw/TDTest/DVAnnoSymImageTest.py
new file mode 100644
index 0000000000..051ce23172
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/DVAnnoSymImageTest.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# annotation & symbol test script for TechDraw module
+# creates a page, 1 annotation and import 1 symbol
+from __future__ import print_function
+
+import FreeCAD
+import Part
+import Measure
+import TechDraw
+import os
+
+def DVAnnoSymImageTest():
+ path = os.path.dirname(os.path.abspath(__file__))
+ print ('TDTestAnno path: ' + path)
+ templateFileSpec = path + '/TestTemplate.svg'
+ symbolFileSpec = path + '/TestSymbol.svg'
+ imageFileSpec = path + '/TestImage.png'
+
+ FreeCAD.newDocument("TDAnno")
+ FreeCAD.setActiveDocument("TDAnno")
+ FreeCAD.ActiveDocument=FreeCAD.getDocument("TDAnno")
+
+ page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage','Page')
+ FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate','Template')
+ FreeCAD.ActiveDocument.Template.Template = templateFileSpec
+ FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
+# page.ViewObject.show() # unit tests run in console mode
+
+ #annotation
+ anno = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewAnnotation','TestAnno')
+ s = 'Different Text'
+ sl = list()
+ sl.append(s)
+ anno.Text = sl
+ anno.TextStyle = 'Bold'
+ rc = page.addView(anno)
+ anno.X = 30.0
+ anno.Y = 150.0
+
+ #symbol
+ sym = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewSymbol','TestSymbol')
+ f = open(symbolFileSpec, 'r')
+ svg = f.read()
+ f.close()
+ sym.Symbol = svg
+ rc = page.addView(sym)
+ sym.X = 220.0
+ sym.Y = 150.0
+
+ #image
+ img = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewImage','TestImage')
+ img.ImageFile = imageFileSpec
+ rc = page.addView(img)
+
+ FreeCAD.ActiveDocument.recompute()
+ rc = False
+ if ("Up-to-date" in anno.State) and ("Up-to-date" in sym.State) and ("Up-to-date" in img.State):
+ rc = True
+ FreeCAD.closeDocument("TDAnno")
+ return rc
+
+if __name__ == '__main__':
+ DVAnnoSymImageTest()
diff --git a/src/Mod/TechDraw/TDTest/DVDimensionTest.py b/src/Mod/TechDraw/TDTest/DVDimensionTest.py
new file mode 100644
index 0000000000..ad09888c17
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/DVDimensionTest.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# test script for TechDraw module
+# creates a page and 2 views
+# adds 1 length dimension to view1
+# adds 1 radius dimension to view2
+from __future__ import print_function
+
+import FreeCAD
+import Part
+import Measure
+import TechDraw
+import os
+
+def DVDimensionTest():
+ path = os.path.dirname(os.path.abspath(__file__))
+ print ('TDDim path: ' + path)
+ templateFileSpec = path + '/TestTemplate.svg'
+
+ FreeCAD.newDocument("TDDim")
+ FreeCAD.setActiveDocument("TDDim")
+ FreeCAD.ActiveDocument=FreeCAD.getDocument("TDDim")
+
+ #make source feature
+ box = FreeCAD.ActiveDocument.addObject("Part::Box","Box")
+ sphere = FreeCAD.ActiveDocument.addObject("Part::Sphere","Sphere")
+
+ #make a page
+ page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage','Page')
+ FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate','Template')
+ FreeCAD.ActiveDocument.Template.Template = templateFileSpec
+ FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
+ page.Scale = 5.0
+# page.ViewObject.show() # unit tests run in console mode
+
+ #make Views
+ view1 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewPart','View')
+ FreeCAD.ActiveDocument.View.Source = [FreeCAD.ActiveDocument.Box]
+ rc = page.addView(view1)
+ view1.X = 30
+ view1.Y = 150
+ view2 = FreeCAD.activeDocument().addObject('TechDraw::DrawViewPart','View001')
+ FreeCAD.activeDocument().View001.Source = [FreeCAD.activeDocument().Sphere]
+ rc = page.addView(view2)
+ view2.X = 220
+ view2.Y = 150
+ FreeCAD.ActiveDocument.recompute()
+
+ #make length dimension
+ print("making length dimension")
+ dim1 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewDimension','Dimension')
+ dim1.Type = "Distance"
+ objs = list()
+ objs.append(view1)
+ subObjs = list()
+ subObjs.append("Edge1")
+ dim1.References2D=[(view1, 'Edge1')]
+ print("adding dim1 to page")
+ rc = page.addView(dim1)
+ print("finished length dimension")
+
+ #make radius dimension
+ print("making radius dimension")
+ dim2 = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewDimension','Dimension001')
+ dim2.Type = "Radius"
+ dim2.MeasureType = "Projected"
+ dim2.References2D=[(view2, 'Edge0')]
+ rc = page.addView(dim2)
+
+ FreeCAD.ActiveDocument.recompute()
+
+ rc = False
+ if ("Up-to-date" in dim1.State) and ("Up-to-date" in dim2.State):
+ rc = True
+ FreeCAD.closeDocument("TDDim")
+ return rc
+
+if __name__ == '__main__':
+ DVDimensionTest()
diff --git a/src/Mod/TechDraw/TDTest/DVPartTest.py b/src/Mod/TechDraw/TDTest/DVPartTest.py
new file mode 100644
index 0000000000..29856f9d5a
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/DVPartTest.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# basic test script for TechDraw module
+# creates a page and 1 view
+from __future__ import print_function
+
+import FreeCAD
+import Part
+import Measure
+import TechDraw
+import os
+
+def DVPartTest():
+ path = os.path.dirname(os.path.abspath(__file__))
+ print ('TDPart path: ' + path)
+ templateFileSpec = path + '/TestTemplate.svg'
+
+ FreeCAD.newDocument("TDPart")
+ FreeCAD.setActiveDocument("TDPart")
+ FreeCAD.ActiveDocument=FreeCAD.getDocument("TDPart")
+
+ box = FreeCAD.ActiveDocument.addObject("Part::Box","Box")
+
+ page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage','Page')
+ FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate','Template')
+ FreeCAD.ActiveDocument.Template.Template = templateFileSpec
+ FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
+ page.Scale = 5.0
+# page.ViewObject.show() # unit tests run in console mode
+ print("page created")
+
+ view = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewPart','View')
+ rc = page.addView(view)
+
+ FreeCAD.ActiveDocument.View.Source = [FreeCAD.ActiveDocument.Box]
+
+ FreeCAD.ActiveDocument.recompute()
+
+ rc = False
+ if ("Up-to-date" in view.State):
+ rc = True
+ FreeCAD.closeDocument("TDPart")
+ return rc
+
+if __name__ == '__main__':
+ DVPartTest()
diff --git a/src/Mod/TechDraw/TDTest/DVSectionTest.py b/src/Mod/TechDraw/TDTest/DVSectionTest.py
new file mode 100644
index 0000000000..1f96d8f5cf
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/DVSectionTest.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# test script for TechDraw module
+# creates a page, 1 view and 1 section view
+from __future__ import print_function
+
+import FreeCAD
+import Part
+import Measure
+import TechDraw
+import os
+
+def DVSectionTest():
+ path = os.path.dirname(os.path.abspath(__file__))
+ print ('TDSection path: ' + path)
+ templateFileSpec = path + '/TestTemplate.svg'
+
+ FreeCAD.newDocument("TDSection")
+ FreeCAD.setActiveDocument("TDSection")
+ FreeCAD.ActiveDocument=FreeCAD.getDocument("TDSection")
+
+ box = FreeCAD.ActiveDocument.addObject("Part::Box","Box")
+
+ page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage','Page')
+ FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate','Template')
+ FreeCAD.ActiveDocument.Template.Template = templateFileSpec
+ FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
+ page.Scale = 5.0
+# page.ViewObject.show() # unit tests run in console mode
+ print("page created")
+
+ view = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewPart','View')
+ rc = page.addView(view)
+ view.Source = [box]
+ view.Direction = (0.0,0.0,1.0)
+ view.Rotation = 0.0
+ view.X = 30.0
+ view.Y = 150.0
+ print("view created")
+
+ section = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewSection','Section')
+ rc = page.addView(section)
+ section.Source = [box]
+ section.BaseView = view
+ section.Direction = (0.0,1.0,0.0)
+ section.SectionNormal = (0.0,1.0,0.0)
+ section.SectionOrigin = (5.0,5.0,5.0)
+ view.touch()
+ print("section created")
+
+ FreeCAD.ActiveDocument.recompute()
+ rc = False
+ if ("Up-to-date" in view.State) and ("Up-to-date" in section.State):
+ rc = True
+ FreeCAD.closeDocument("TDSection")
+ return rc
+
+if __name__ == '__main__':
+ DVSectionTest()
diff --git a/src/Mod/TechDraw/TDTest/TestHatch.svg b/src/Mod/TechDraw/TDTest/TestHatch.svg
new file mode 100644
index 0000000000..07b0da6af3
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/TestHatch.svg
@@ -0,0 +1,111 @@
+
+
diff --git a/src/Mod/TechDraw/TDTest/TestImage.png b/src/Mod/TechDraw/TDTest/TestImage.png
new file mode 100644
index 0000000000..119ab54cc7
Binary files /dev/null and b/src/Mod/TechDraw/TDTest/TestImage.png differ
diff --git a/src/Mod/TechDraw/TDTest/TestSymbol.svg b/src/Mod/TechDraw/TDTest/TestSymbol.svg
new file mode 100644
index 0000000000..6c38952473
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/TestSymbol.svg
@@ -0,0 +1,58 @@
+
+
+
+
diff --git a/src/Mod/TechDraw/TDTest/TestTemplate.svg b/src/Mod/TechDraw/TDTest/TestTemplate.svg
new file mode 100644
index 0000000000..33eaff6ef2
--- /dev/null
+++ b/src/Mod/TechDraw/TDTest/TestTemplate.svg
@@ -0,0 +1,1679 @@
+
+
diff --git a/src/Mod/TechDraw/TDTest/__init__.py b/src/Mod/TechDraw/TDTest/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/Mod/TechDraw/TestTechDrawApp.py b/src/Mod/TechDraw/TestTechDrawApp.py
index d5ce8b2194..78f22a7a9d 100644
--- a/src/Mod/TechDraw/TestTechDrawApp.py
+++ b/src/Mod/TechDraw/TestTechDrawApp.py
@@ -25,39 +25,64 @@ import TechDraw
import time
App = FreeCAD
+from TDTest.DHatchTest import DHatchTest
+from TDTest.DProjGroupTest import DProjGroupTest
+from TDTest.DVAnnoSymImageTest import DVAnnoSymImageTest
+from TDTest.DVDimensionTest import DVDimensionTest
+from TDTest.DVPartTest import DVPartTest
+from TDTest.DVSectionTest import DVSectionTest
+
#---------------------------------------------------------------------------
# define the test cases to test the FreeCAD TechDraw module
#---------------------------------------------------------------------------
class TechDrawTestCases(unittest.TestCase):
- def setUp(self):
- self.Doc = FreeCAD.newDocument("TechDrawTest")
+ def testViewPartCase(self):
+ print("starting TD DrawViewPart test")
+ rc = DVPartTest()
+ if rc:
+ print("TD DrawViewPart test passed")
+ else:
+ print("TD DrawViewPart test failed")
- def testPageCase(self):
- self.templateFileSpec = App.getResourceDir() + 'Mod/TechDraw/Templates/A4_LandscapeTD.svg'
- self.Box = self.Doc.addObject("Part::Box","Box")
- self.Page = self.Doc.addObject('TechDraw::DrawPage','Page')
- self.Template = self.Doc.addObject('TechDraw::DrawSVGTemplate','Template')
- self.Template.Template = self.templateFileSpec
- self.Page.Template = self.Template
- self.View = self.Doc.addObject('TechDraw::DrawViewPart','View')
- rc = self.Page.addView(self.View)
- self.View.Source = self.Box
- self.Anno = self.Doc.addObject('TechDraw::DrawViewAnnotation','TestAnno')
- rc = self.Page.addView(self.Anno)
- self.Sect = self.Doc.addObject('TechDraw::DrawViewSection','Section')
- self.Sect.Source = self.Box
- self.Sect.Direction = FreeCAD.Vector(-1.0,0.0,0.0)
- self.Sect.BaseView = self.View
- self.Sect.SectionDirection = "Right"
- self.Sect.SectionOrigin = FreeCAD.Vector(1.0,1.0,1.0)
- self.Sect.SectionNormal = FreeCAD.Vector(-1.0,0.0,0.0)
- rc = self.Page.addView(self.Sect)
- self.Doc.recompute()
- self.failUnless(len(self.Page.Views) == 3)
+ def testHatchCase(self):
+ print("starting TD DrawHatch test")
+ rc = DHatchTest()
+ if rc:
+ print("TD DrawHatch test passed")
+ else:
+ print("TD DrawHatch test failed")
+
+ def testAnnoSymImageCase(self):
+ print("starting TD DrawAnno/Sym/Image test")
+ rc = DVAnnoSymImageTest()
+ if rc:
+ print("TD DrawAnno/Sym/Image test passed")
+ else:
+ print("TD DrawAnno/Sym/Image test failed")
+
+ def testProjGroupCase(self):
+ print("starting TD DrawProjGroup test")
+ rc = DProjGroupTest()
+ if rc:
+ print("TD DrawProjGroup test passed")
+ else:
+ print("TD DrawProjGroup test failed")
+
+ def testDimensionCase(self):
+ print("starting TD DrawViewDimension test")
+ rc = DVDimensionTest()
+ if rc:
+ print("TD DrawViewDimension test passed")
+ else:
+ print("TD DrawViewDimension test failed")
+
+ def testSectionCase(self):
+ print("starting TD DrawViewSection test")
+ rc = DVSectionTest()
+ if rc:
+ print("TD DrawViewSection test passed")
+ else:
+ print("TD DrawViewSection test failed")
- def tearDown(self):
- #closing doc
- FreeCAD.closeDocument("TechDrawTest")
- #print ("omit closing document for debugging")
diff --git a/src/Mod/TechDraw/moveViews.py b/src/Mod/TechDraw/moveViews.py
new file mode 100644
index 0000000000..4c8d680af1
--- /dev/null
+++ b/src/Mod/TechDraw/moveViews.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# move Views from Drawing Page to TechDraw Page in the current document
+# usage: select 1 Drawing Page and 1 TechDraw Page, run moveViews macro
+# outcome: Content of Drawing Page will be inserted into TechDraw Page as DrawViewSymbol
+# (ie an SVG symbol)
+
+import FreeCAD
+import Part
+import Drawing
+import TechDraw
+
+svgHead = ""
+
+def moveViews():
+ s = FreeCADGui.Selection.getSelection()
+
+ if len(s) != 2:
+ print "Please select 1 Drawing Page and 1 TechDraw Page"
+ return
+
+ print "First object in selection is a: ", s[0].TypeId
+ print "Second object in selection is a: ", s[1].TypeId
+ if s[0].isDerivedFrom("Drawing::FeaturePage") and \
+ s[1].isDerivedFrom("TechDraw::DrawPage"):
+ dPage = s[0]
+ tPage = s[1]
+ elif s[0].isDerivedFrom("TechDraw::DrawPage") and \
+ s[1].isDerivedFrom("Drawing::FeaturePage"):
+ tPage = s[0]
+ dPage = s[1]
+ else:
+ print "Please select 1 Drawing Page and 1 TechDraw Page"
+ return
+
+ i = 1
+ for o in dPage.OutList:
+ newName = "DraftView" + str(i).zfill(3)
+ print "moving " + o.Name + " to " + newName
+ svg = svgHead + o.ViewResult + svgTail
+ no = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewSymbol',newName)
+ no.Symbol = svg
+ tPage.addView(no)
+ i += 1
+
+ print "moveViews moved " + str(i-1) + " views"
+
+if __name__ == '__main__':
+ moveViews()