-
Notifications
You must be signed in to change notification settings - Fork 2
/
table.py
23 lines (21 loc) · 1.38 KB
/
table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import FreeCAD
import Part
#This takes the dimensions from the user.
def table(base_length, base_width, base_height,leg_thickness, leg_height):
#These are the placements of the table.
make_cube(base_length, base_width, base_height, App.Placement(App.Vector(0,0,-leg_height),App.Rotation(App.Vector(0,0,1),0)))
make_cube(leg_thickness,leg_thickness,leg_height, App.Placement(App.Vector(0,0,- (leg_height + leg_height )),App.Rotation(App.Vector(0,0,1),0)))
make_cube(leg_thickness,leg_thickness,leg_height, App.Placement(App.Vector(base_length - leg_thickness,0,-(leg_height + leg_height)),App.Rotation(App.Vector(0,0,1),0)))
make_cube(leg_thickness,leg_thickness,leg_height,App.Placement(App.Vector(0,base_width - leg_thickness,-(leg_height + leg_height)),App.Rotation(App.Vector(0,0,1),0)))
make_cube(leg_thickness,leg_thickness,leg_height, App.Placement(App.Vector(base_length - leg_thickness,base_width - leg_thickness,-(leg_height + leg_height)),App.Rotation(App.Vector(0,0,1),0)))
App.ActiveDocument.recompute()
##Gui.SendMsgToActiveView("ViewFit")
#This function calls the above function five times.
def make_cube(length, width, height, placement):
cube_leg = App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.ActiveObject.Label = "legs"
cube_leg.Length = length
cube_leg.Width = width
cube_leg.Height = height
cube_leg.Placement = placement
App.ActiveDocument.recompute()