# -*- coding: utf-8 -*- # Macro Begin: C:\Users\deeja\AppData\Roaming\FreeCAD\Macro\Test_SubtractivePipe.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++ import FreeCAD import PartDesign import PartDesignGui import Sketcher App.newDocument("Sans nom") #App.setActiveDocument("Sans_nom") #App.ActiveDocument=App.getDocument("Sans_nom") #Gui.ActiveDocument=Gui.getDocument("Sans_nom") #Gui.activeDocument().activeView().viewDefaultOrientation() App.activeDocument().addObject('PartDesign::Body','Body') #Gui.activateView('Gui::View3DInventor', True) #Gui.activeView().setActiveObject('pdbody', App.activeDocument().Body) App.activeDocument().Body.newObject('Sketcher::SketchObject','Sketch') App.activeDocument().Sketch.Support = (App.activeDocument().XY_Plane, ['']) App.activeDocument().Sketch.MapMode = 'FlatFace' App.ActiveDocument.recompute() #Gui.activeDocument().setEdit('Sketch') #Gui.activateWorkbench('SketcherWorkbench') #ActiveSketch = App.ActiveDocument.getObject('Sketch') #tv = Show.TempoVis(App.ActiveDocument) #if ActiveSketch.ViewObject.HideDependent: # objs = tv.get_all_dependent(ActiveSketch) # objs = filter(lambda x: not x.TypeId.startswith("TechDraw::"), objs) # objs = filter(lambda x: not x.TypeId.startswith("Drawing::"), objs) # tv.hide(objs) #if ActiveSketch.ViewObject.ShowSupport: # tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom("PartDesign::Plane")]) #if ActiveSketch.ViewObject.ShowLinks: # tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry]) #tv.hide(ActiveSketch) #ActiveSketch.ViewObject.TempoVis = tv #del(tv) # #ActiveSketch = App.ActiveDocument.getObject('Sketch') #if ActiveSketch.ViewObject.RestoreCamera: # ActiveSketch.ViewObject.TempoVis.saveCamera() # geoList = [] geoList.append(Part.LineSegment(App.Vector(-12.439816,13.332624,0),App.Vector(13.987350,13.332624,0))) geoList.append(Part.LineSegment(App.Vector(13.987350,13.332624,0),App.Vector(13.987350,-14.999204,0))) geoList.append(Part.LineSegment(App.Vector(13.987350,-14.999204,0),App.Vector(-12.439816,-14.999204,0))) geoList.append(Part.LineSegment(App.Vector(-12.439816,-14.999204,0),App.Vector(-12.439816,13.332624,0))) App.ActiveDocument.Sketch.addGeometry(geoList,False) conList = [] conList.append(Sketcher.Constraint('Coincident',0,2,1,1)) conList.append(Sketcher.Constraint('Coincident',1,2,2,1)) conList.append(Sketcher.Constraint('Coincident',2,2,3,1)) conList.append(Sketcher.Constraint('Coincident',3,2,0,1)) conList.append(Sketcher.Constraint('Horizontal',0)) conList.append(Sketcher.Constraint('Horizontal',2)) conList.append(Sketcher.Constraint('Vertical',1)) conList.append(Sketcher.Constraint('Vertical',3)) App.ActiveDocument.Sketch.addConstraint(conList) App.ActiveDocument.recompute() #Gui.activeDocument().resetEdit() #ActiveSketch = App.ActiveDocument.getObject('Sketch') #tv = ActiveSketch.ViewObject.TempoVis #if tv: # tv.restore() #ActiveSketch.ViewObject.TempoVis = None #del(tv) # #Gui.activateWorkbench('PartDesignWorkbench') App.ActiveDocument.recompute() #Gui.activeDocument().activeView().viewIsometric() App.activeDocument().Body.newObject("PartDesign::Pad","Pad") App.activeDocument().Pad.Profile = App.activeDocument().Sketch App.activeDocument().Pad.Length = 10.0 App.ActiveDocument.recompute() #Gui.activeDocument().hide("Sketch") App.ActiveDocument.recompute() #Gui.ActiveDocument.Pad.ShapeColor=Gui.ActiveDocument.Body.ShapeColor #Gui.ActiveDocument.Pad.LineColor=Gui.ActiveDocument.Body.LineColor #Gui.ActiveDocument.Pad.PointColor=Gui.ActiveDocument.Body.PointColor #Gui.ActiveDocument.Pad.Transparency=Gui.ActiveDocument.Body.Transparency #Gui.ActiveDocument.Pad.DisplayMode=Gui.ActiveDocument.Body.DisplayMode #Gui.activeDocument().setEdit('Pad', 0) #Gui.Selection.clearSelection() #Gui.activeDocument().hide("Sketch") App.ActiveDocument.Pad.Length = 30.000000 App.ActiveDocument.Pad.Length2 = 100.000000 App.ActiveDocument.Pad.Type = 0 App.ActiveDocument.Pad.UpToFace = None App.ActiveDocument.Pad.Reversed = 0 App.ActiveDocument.Pad.Midplane = 0 App.ActiveDocument.Pad.Offset = 0.000000 App.ActiveDocument.recompute() #Gui.activeDocument().resetEdit() #Gui.SendMsgToActiveView("ViewFit") App.activeDocument().Body.newObject('Sketcher::SketchObject','Sketch001') App.activeDocument().Sketch001.Support = (App.activeDocument().XZ_Plane, ['']) App.activeDocument().Sketch001.MapMode = 'FlatFace' App.ActiveDocument.recompute() #Gui.activeDocument().setEdit('Sketch001') #Gui.activateWorkbench('SketcherWorkbench') #ActiveSketch = App.ActiveDocument.getObject('Sketch001') #tv = Show.TempoVis(App.ActiveDocument) #if ActiveSketch.ViewObject.HideDependent: # objs = tv.get_all_dependent(ActiveSketch) # objs = filter(lambda x: not x.TypeId.startswith("TechDraw::"), objs) # objs = filter(lambda x: not x.TypeId.startswith("Drawing::"), objs) # tv.hide(objs) #if ActiveSketch.ViewObject.ShowSupport: # tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom("PartDesign::Plane")]) #if ActiveSketch.ViewObject.ShowLinks: # tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry]) #tv.hide(ActiveSketch) #ActiveSketch.ViewObject.TempoVis = tv #del(tv) # #ActiveSketch = App.ActiveDocument.getObject('Sketch001') #if ActiveSketch.ViewObject.RestoreCamera: # ActiveSketch.ViewObject.TempoVis.saveCamera() # App.ActiveDocument.Sketch001.addGeometry(Part.LineSegment(App.Vector(-24.063456,8.601261,0),App.Vector(18.286116,20.472610,0)),False) App.ActiveDocument.recompute() #Gui.activeDocument().resetEdit() #ActiveSketch = App.ActiveDocument.getObject('Sketch001') #tv = ActiveSketch.ViewObject.TempoVis #if tv: # tv.restore() #ActiveSketch.ViewObject.TempoVis = None #del(tv) # #Gui.activateWorkbench('PartDesignWorkbench') App.ActiveDocument.recompute() #Gui.activeDocument().setEdit('Sketch001') #Gui.activateWorkbench('SketcherWorkbench') #ActiveSketch = App.ActiveDocument.getObject('Sketch001') #tv = Show.TempoVis(App.ActiveDocument) #if ActiveSketch.ViewObject.HideDependent: # objs = tv.get_all_dependent(ActiveSketch) # objs = filter(lambda x: not x.TypeId.startswith("TechDraw::"), objs) # objs = filter(lambda x: not x.TypeId.startswith("Drawing::"), objs) # tv.hide(objs) #if ActiveSketch.ViewObject.ShowSupport: # tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom("PartDesign::Plane")]) #if ActiveSketch.ViewObject.ShowLinks: # tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry]) #tv.hide(ActiveSketch) #ActiveSketch.ViewObject.TempoVis = tv #del(tv) # #ActiveSketch = App.ActiveDocument.getObject('Sketch001') #if ActiveSketch.ViewObject.RestoreCamera: # ActiveSketch.ViewObject.TempoVis.saveCamera() # #Gui.activeDocument().activeView().viewIsometric() #Gui.getDocument('Sans_nom').resetEdit() #ActiveSketch = App.ActiveDocument.getObject('Sketch001') #tv = ActiveSketch.ViewObject.TempoVis #if tv: # tv.restore() #ActiveSketch.ViewObject.TempoVis = None #del(tv) # #Gui.activateWorkbench('PartDesignWorkbench') App.getDocument('Sans_nom').recompute() App.activeDocument().Body.newObject('Sketcher::SketchObject','Sketch002') App.activeDocument().Sketch002.Support = (App.activeDocument().YZ_Plane, ['']) App.activeDocument().Sketch002.MapMode = 'FlatFace' App.ActiveDocument.recompute() #Gui.activeDocument().setEdit('Sketch002') #Gui.activateWorkbench('SketcherWorkbench') #ActiveSketch = App.ActiveDocument.getObject('Sketch002') #tv = Show.TempoVis(App.ActiveDocument) #if ActiveSketch.ViewObject.HideDependent: # objs = tv.get_all_dependent(ActiveSketch) # objs = filter(lambda x: not x.TypeId.startswith("TechDraw::"), objs) # objs = filter(lambda x: not x.TypeId.startswith("Drawing::"), objs) # tv.hide(objs) #if ActiveSketch.ViewObject.ShowSupport: # tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom("PartDesign::Plane")]) #if ActiveSketch.ViewObject.ShowLinks: # tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry]) #tv.hide(ActiveSketch) #ActiveSketch.ViewObject.TempoVis = tv #del(tv) # #ActiveSketch = App.ActiveDocument.getObject('Sketch002') #if ActiveSketch.ViewObject.RestoreCamera: # ActiveSketch.ViewObject.TempoVis.saveCamera() # App.ActiveDocument.Sketch002.addGeometry(Part.Circle(App.Vector(0.493656,20.770469,0),App.Vector(0,0,1),6.841867),False) App.ActiveDocument.recompute() App.ActiveDocument.Sketch002.addExternal("Sketch001","Edge1") App.ActiveDocument.recompute() App.ActiveDocument.Sketch002.addConstraint(Sketcher.Constraint('Coincident',0,3,-3,2)) App.ActiveDocument.recompute() #Gui.activeDocument().resetEdit() #ActiveSketch = App.ActiveDocument.getObject('Sketch002') #tv = ActiveSketch.ViewObject.TempoVis #if tv: # tv.restore() #ActiveSketch.ViewObject.TempoVis = None #del(tv) # #Gui.activateWorkbench('PartDesignWorkbench') App.ActiveDocument.recompute() App.activeDocument().Body.newObject("PartDesign::SubtractivePipe","SubtractivePipe") App.activeDocument().SubtractivePipe.Profile = App.activeDocument().Sketch002 App.ActiveDocument.recompute() #Gui.activeDocument().hide("Sketch002") App.ActiveDocument.recompute() #Gui.ActiveDocument.SubtractivePipe.ShapeColor=Gui.ActiveDocument.Body.ShapeColor #Gui.ActiveDocument.SubtractivePipe.LineColor=Gui.ActiveDocument.Body.LineColor #Gui.ActiveDocument.SubtractivePipe.PointColor=Gui.ActiveDocument.Body.PointColor #Gui.ActiveDocument.SubtractivePipe.Transparency=Gui.ActiveDocument.Body.Transparency #Gui.ActiveDocument.SubtractivePipe.DisplayMode=Gui.ActiveDocument.Body.DisplayMode #Gui.activeDocument().setEdit('SubtractivePipe', 0) #Gui.Selection.clearSelection() App.ActiveDocument.recompute() #Gui.activeDocument().resetEdit() # Macro End: C:\Users\deeja\AppData\Roaming\FreeCAD\Macro\Test_SubtractivePipe.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++