From 6bd237e41eade41740dc37241f897a076ff7071c Mon Sep 17 00:00:00 2001 From: WandererFan Date: Tue, 30 Jan 2018 16:30:23 -0500 Subject: [PATCH] Update TechDraw Unit Test set Allow unit test to run in console mode Change to unique document names for each unit test Fix error in CMake install for test files Correct Py3/Py2 unicode error --- src/Mod/TechDraw/CMakeLists.txt | 34 + src/Mod/TechDraw/TDTest/DHatchTest.py | 61 + src/Mod/TechDraw/TDTest/DProjGroupTest.py | 79 + src/Mod/TechDraw/TDTest/DVAnnoSymImageTest.py | 65 + src/Mod/TechDraw/TDTest/DVDimensionTest.py | 80 + src/Mod/TechDraw/TDTest/DVPartTest.py | 47 + src/Mod/TechDraw/TDTest/DVSectionTest.py | 60 + src/Mod/TechDraw/TDTest/TestHatch.svg | 111 ++ src/Mod/TechDraw/TDTest/TestImage.png | Bin 0 -> 4097 bytes src/Mod/TechDraw/TDTest/TestSymbol.svg | 58 + src/Mod/TechDraw/TDTest/TestTemplate.svg | 1679 +++++++++++++++++ src/Mod/TechDraw/TDTest/__init__.py | 0 src/Mod/TechDraw/TestTechDrawApp.py | 81 +- src/Mod/TechDraw/moveViews.py | 51 + 14 files changed, 2378 insertions(+), 28 deletions(-) create mode 100644 src/Mod/TechDraw/TDTest/DHatchTest.py create mode 100644 src/Mod/TechDraw/TDTest/DProjGroupTest.py create mode 100644 src/Mod/TechDraw/TDTest/DVAnnoSymImageTest.py create mode 100644 src/Mod/TechDraw/TDTest/DVDimensionTest.py create mode 100644 src/Mod/TechDraw/TDTest/DVPartTest.py create mode 100644 src/Mod/TechDraw/TDTest/DVSectionTest.py create mode 100644 src/Mod/TechDraw/TDTest/TestHatch.svg create mode 100644 src/Mod/TechDraw/TDTest/TestImage.png create mode 100644 src/Mod/TechDraw/TDTest/TestSymbol.svg create mode 100644 src/Mod/TechDraw/TDTest/TestTemplate.svg create mode 100644 src/Mod/TechDraw/TDTest/__init__.py create mode 100644 src/Mod/TechDraw/moveViews.py 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 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/TDTest/TestImage.png b/src/Mod/TechDraw/TDTest/TestImage.png new file mode 100644 index 0000000000000000000000000000000000000000..119ab54cc7b5c739481d91a2805913b27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_P;kT0mfMy``)A`$-`$sl#L7B1Nw4_%e9H)AT!>U{J)xiuL-3jm$bnnd< zqow3s)+Ldie&89VhaeMk#i>EU$=p73v07SK=H#~}Di0&NgZ`&M3m0po}aqbm + + + + + + + + image/svg+xml + + + + + + + + + SVG + + 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 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This drawing is our property; it can't be reproduced or communicated without our written consent. + A4 + + + + + + + + + Designed by Name + Date + Scale + Weight + Title + Subtitle + Drawing number + Sheet + + 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 = "\n" +svgTail = "\n" + +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()