SketcherExample.py

Go to the documentation of this file.
00001 # Example hwo to use the basic sketcher tools
00002 from Sketcher import *
00003 from Part import *
00004 from FreeCAD import *
00005 
00006 # set some constances for the constraints
00007 StartPoint = 1
00008 EndPoint = 2
00009 MiddlePoint = 3
00010 
00011 # create a document and a Sketch object
00012 if(App.activeDocument() == None):App.newDocument()
00013 
00014 f = App.activeDocument().addObject("Sketcher::SketchObject","Sketch")
00015 
00016 # add geometry to the sketch
00017 f.Geometry = [Line(Vector(0,0,0),Vector(2,20,0)),Line(Vector(0,0,0),Vector(20,2,0))]
00018 
00019 # add constraints to the sketch
00020 f.Constraints = [Constraint('Vertical',0),Constraint('Horizontal',1)]
00021 
00022 # recompute (solving) the sketch
00023 App.activeDocument().recompute()
00024 
00025 # add another constraint to tie the start points together
00026 l = f.Constraints
00027 l.append(Constraint('Coincident',0,StartPoint,1,StartPoint))
00028 f.Constraints = l
00029 
00030 # again recompute
00031 App.activeDocument().recompute()
00032 
00033 f.Geometry
00034 
00035 

Generated on Wed Nov 23 19:00:38 2011 for FreeCAD by  doxygen 1.6.1