Partial attempt to embed libraries in module.
This commit is contained in:
parent
8fbf4ee4c1
commit
00766a2d75
32
CadQuery/Examples/Ex001_Simple_Block.py
Normal file
32
CadQuery/Examples/Ex001_Simple_Block.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#File: Ex001_Simple_Block.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex001_Simple_Block
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex001_Simple_Block)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more in-depth explanation of this example at http://parametricparts.com/docs/quickstart.html
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the box. These can be modified rather than changing the box's code directly.
|
||||||
|
length = 80.0
|
||||||
|
height = 60.0
|
||||||
|
thickness = 10.0
|
||||||
|
|
||||||
|
#Create a 3D box based on the dimension variables above
|
||||||
|
result = cadquery.Workplane("XY").box(length, height, thickness)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
33
CadQuery/Examples/Ex002_Block_With_Bored_Center_Hole.py
Normal file
33
CadQuery/Examples/Ex002_Block_With_Bored_Center_Hole.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#File: Ex002_Block_With_Bored_Center_Hole.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex002_Block_With_Bored_Center_Hole
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex002_Block_With_Bored_Center_Hole)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more in-depth explantion of this example at http://parametricparts.com/docs/quickstart.html
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the box. These can be modified rather than changing the box's code directly.
|
||||||
|
length = 80.0
|
||||||
|
height = 60.0
|
||||||
|
thickness = 10.0
|
||||||
|
center_hole_dia = 22.0
|
||||||
|
|
||||||
|
#Create a 3D box based on the dimension variables above and add a 22mm center hole
|
||||||
|
result = cadquery.Workplane("XY").box(length, height, thickness) \
|
||||||
|
.faces(">Z").workplane().hole(center_hole_dia)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
|
@ -0,0 +1,40 @@
|
||||||
|
#File: Ex003_Pillow_Block_With_Counterbored_Holes.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex003_Pillow_Block_With_Counterbored_Holes
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex003_Pillow_Block_With_Counterbored_Holes)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more in-depth explanation of this example at http://parametricparts.com/docs/quickstart.html
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the box. These can be modified rather than changing the box's code directly.
|
||||||
|
length = 80.0
|
||||||
|
height = 60.0
|
||||||
|
thickness = 10.0
|
||||||
|
center_hole_dia = 22.0
|
||||||
|
cbore_hole_diameter = 2.4
|
||||||
|
cbore_diameter = 4.4
|
||||||
|
cbore_depth = 2.1
|
||||||
|
|
||||||
|
#Create a 3D box based on the dimension variables above and add 4 counterbored holes
|
||||||
|
result = cadquery.Workplane("XY").box(length, height, thickness) \
|
||||||
|
.faces(">Z").workplane().hole(center_hole_dia) \
|
||||||
|
.faces(">Z").workplane() \
|
||||||
|
.rect(length - 8.0, height - 8.0, forConstruction = True) \
|
||||||
|
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
34
CadQuery/Examples/Ex004_Extruded_Cylindrical_Plate.py
Normal file
34
CadQuery/Examples/Ex004_Extruded_Cylindrical_Plate.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#File: Ex004_Extruded_Cylindrical_Plate.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex004_Extruded_Cylindrical_Plate
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex004_Extruded_Cylindrical_Plate)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
||||||
|
circle_radius = 50.0
|
||||||
|
rectangle_width = 13.0
|
||||||
|
rectangle_length = 19.0
|
||||||
|
thickness = 13.0
|
||||||
|
|
||||||
|
#Extrude a cylindrical plate with a rectangular hole in the middle of it
|
||||||
|
result = cadquery.Workplane("front").circle(circle_radius).rect(rectangle_width, rectangle_length).extrude(thickness)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
33
CadQuery/Examples/Ex005_Extruded_Lines_and_Arcs.py
Normal file
33
CadQuery/Examples/Ex005_Extruded_Lines_and_Arcs.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#File: Ex005_Extruded_Lines_and_Arcs.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex005_Extruded_Lines_and_Arcs
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex005_Extruded_Lines_and_Arcs)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
#(Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
||||||
|
width = 2.0
|
||||||
|
thickness = 0.25
|
||||||
|
|
||||||
|
#Extrude a plate outline made of lines and an arc
|
||||||
|
result = cadquery.Workplane("front").lineTo(width, 0).lineTo(width, 1.0).threePointArc((1.0, 1.5),(0.0, 1.0)) \
|
||||||
|
.close().extrude(thickness)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
38
CadQuery/Examples/Ex006_Moving_the_Current_Working_Point.py
Normal file
38
CadQuery/Examples/Ex006_Moving_the_Current_Working_Point.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#File: Ex006_Moving_the_Current_Working_Point.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex006_Moving_the_Current_Working_Point
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex006_Moving_the_Current_Working_Point)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
||||||
|
circle_radius = 3.0
|
||||||
|
thickness = 0.25
|
||||||
|
|
||||||
|
#Make the plate with two cutouts in it
|
||||||
|
result = cadquery.Workplane("front").circle(circle_radius) # Current point is the center of the circle, at (0,0)
|
||||||
|
result = result.center(1.5,0.0).rect(0.5,0.5) # New work center is (1.5,0.0)
|
||||||
|
|
||||||
|
result = result.center(-1.5,1.5).circle(0.25) # New work center is ( 0.0,1.5).
|
||||||
|
#The new center is specified relative to the previous center, not global coordinates!
|
||||||
|
|
||||||
|
result = result.extrude(thickness)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
36
CadQuery/Examples/Ex007_Using_Point_Lists.py
Normal file
36
CadQuery/Examples/Ex007_Using_Point_Lists.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#File: Ex007_Using_Point_Lists.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex007_Using_Point_Lists
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex007_Using_Point_Lists)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
||||||
|
plate_radius = 2.0
|
||||||
|
hole_pattern_radius = 0.25
|
||||||
|
thickness = 0.125
|
||||||
|
|
||||||
|
#Make the plate with 4 holes in it at various points
|
||||||
|
r = cadquery.Workplane("front").circle(plate_radius) # Make the base
|
||||||
|
r = r.pushPoints([(1.5, 0), (0, 1.5), (-1.5, 0), (0, -1.5)]) # Now four points are on the stack
|
||||||
|
r = r.circle(hole_pattern_radius) # Circle will operate on all four points
|
||||||
|
result = r.extrude(thickness)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
36
CadQuery/Examples/Ex008_Polygon_Creation.py
Normal file
36
CadQuery/Examples/Ex008_Polygon_Creation.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#File: Ex008_Polygon_Creation.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex008_Polygon_Creation
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex008_Polygon_Creation)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
||||||
|
width = 3.0
|
||||||
|
height = 4.0
|
||||||
|
thickness = 0.25
|
||||||
|
polygon_sides = 6
|
||||||
|
polygon_dia = 1.0
|
||||||
|
|
||||||
|
#Create a plate with two polygons cut through it
|
||||||
|
result = cadquery.Workplane("front").box(width, height, thickness).pushPoints([(0, 0.75), (0, -0.75)]) \
|
||||||
|
.polygon(polygon_sides, polygon_dia).cutThruAll()
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
44
CadQuery/Examples/Ex009_Polylines.py
Normal file
44
CadQuery/Examples/Ex009_Polylines.py
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#File: Ex009_Polylines.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex009_Polylines
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex009_Polylines)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Set up our Length, Height, Width, and thickness that will be used to define the locations that the polyline
|
||||||
|
#is drawn to/thru
|
||||||
|
(L, H, W, t) = (100.0, 20.0, 20.0, 1.0)
|
||||||
|
|
||||||
|
#Define the locations that the polyline will be drawn to/thru
|
||||||
|
pts = [
|
||||||
|
(0, H/2.0),
|
||||||
|
(W/2.0, H/2.0),
|
||||||
|
(W/2.0, (H/2.0 - t)),
|
||||||
|
(t/2.0, (H/2.0-t)),
|
||||||
|
(t/2.0, (t - H/2.0)),
|
||||||
|
(W/2.0, (t - H/2.0)),
|
||||||
|
(W/2.0, H/-2.0),
|
||||||
|
(0, H/-2.0)
|
||||||
|
]
|
||||||
|
|
||||||
|
#We generate half of the I-beam outline and then mirror it to create the full I-beam
|
||||||
|
result = cadquery.Workplane("front").polyline(pts).mirrorY().extrude(L)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
45
CadQuery/Examples/Ex010_Defining_an_Edge_with_a_Spline.py
Normal file
45
CadQuery/Examples/Ex010_Defining_an_Edge_with_a_Spline.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#File: Ex010_Defining_an_Edge_with_a_Spline.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex010_Defining_an_Edge_with_a_Spline
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex010_Defining_an_Edge_with_a_Spline)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The workplane we want to create the spline on to extrude
|
||||||
|
s = cadquery.Workplane("XY")
|
||||||
|
|
||||||
|
#The points that the spline will pass through
|
||||||
|
sPnts = [
|
||||||
|
(2.75, 1.5),
|
||||||
|
(2.5, 1.75),
|
||||||
|
(2.0, 1.5),
|
||||||
|
(1.5, 1.0),
|
||||||
|
(1.0, 1.25),
|
||||||
|
(0.5, 1.0),
|
||||||
|
(0, 1.0)
|
||||||
|
]
|
||||||
|
|
||||||
|
#Generate our plate with the spline feature and make sure it's a closed entity
|
||||||
|
r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts).close()
|
||||||
|
|
||||||
|
#Extrude to turn the wire into a plate
|
||||||
|
result = r.extrude(0.5)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
34
CadQuery/Examples/Ex011_Mirroring_Symmetric_Geometry.py
Normal file
34
CadQuery/Examples/Ex011_Mirroring_Symmetric_Geometry.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#File: Ex011_Mirroring_Symmetric_Geometry.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex011_Mirroring_Symmetric_Geometry
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex011_Mirroring_Symmetric_Geometry)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#1.0 is the distance, not coordinate
|
||||||
|
r = cadquery.Workplane("front").hLine(1.0)
|
||||||
|
|
||||||
|
#hLineTo allows using xCoordinate not distance
|
||||||
|
r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0)
|
||||||
|
|
||||||
|
#Mirror the geometry and extrude
|
||||||
|
result = r.mirrorY().extrude(0.25)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
31
CadQuery/Examples/Ex012_Creating_Workplanes_on_Faces.py
Normal file
31
CadQuery/Examples/Ex012_Creating_Workplanes_on_Faces.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#File: Ex012_Creating_Workplanes_on_Faces.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex012_Creating_Workplanes_on_Faces
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex012_Creating_Workplanes_on_Faces)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Make a basic prism
|
||||||
|
result = cadquery.Workplane("front").box(2,3,0.5)
|
||||||
|
|
||||||
|
#Find the top-most face and make a hole
|
||||||
|
result = result.faces(">Z").workplane().hole(0.5)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
34
CadQuery/Examples/Ex013_Locating_a_Workplane_on_a_Vertex.py
Normal file
34
CadQuery/Examples/Ex013_Locating_a_Workplane_on_a_Vertex.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#File: Ex013_Locating_a_Workplane_on_a_Vertex.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex013_Locating_a_Workplane_on_a_Vertex
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex013_Locating_a_Workplane_on_a_Vertex)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Make a basic prism
|
||||||
|
result = cadquery.Workplane("front").box(3, 2, 0.5)
|
||||||
|
|
||||||
|
#Select the lower left vertex and make a workplane
|
||||||
|
result = result.faces(">Z").vertices("<XY").workplane()
|
||||||
|
|
||||||
|
#Cut the corner out
|
||||||
|
result = result.circle(1.0).cutThruAll()
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
34
CadQuery/Examples/Ex014_Offset_Workplanes.py
Normal file
34
CadQuery/Examples/Ex014_Offset_Workplanes.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#File: Ex014_Offset_Workplanes.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex014_Offset_Workplanes
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex014_Offset_Workplanes)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Make a basic prism
|
||||||
|
result = cadquery.Workplane("front").box(3, 2, 0.5)
|
||||||
|
|
||||||
|
#Workplane is offset from the object surface
|
||||||
|
result = result.faces("<X").workplane(offset=0.75)
|
||||||
|
|
||||||
|
#Create a disc
|
||||||
|
result = result.circle(1.0).extrude(0.5)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
32
CadQuery/Examples/Ex015_Rotated_Workplanes.py
Normal file
32
CadQuery/Examples/Ex015_Rotated_Workplanes.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#File: Ex015_Rotated_Workplanes.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex015_Rotated_Workplanes
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex015_Rotated_Workplanes)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
from cadquery import Vector
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a rotated workplane and put holes in each corner of a rectangle on that workplane, producing angled holes
|
||||||
|
#in the face
|
||||||
|
result = cadquery.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").workplane() \
|
||||||
|
.transformed(offset=Vector(0, -1.5, 1.0), rotate=Vector(60, 0, 0)) \
|
||||||
|
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
29
CadQuery/Examples/Ex016_Using_Construction_Geometry.py
Normal file
29
CadQuery/Examples/Ex016_Using_Construction_Geometry.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#File: Ex016_Using_Construction_Geometry.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex016_Using_Construction_Geometry
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex016_Using_Construction_Geometry)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a block with holes in each corner of a rectangle on that workplane
|
||||||
|
result = cadquery.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane() \
|
||||||
|
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
28
CadQuery/Examples/Ex017_Shelling_to_Create_Thin_Features.py
Normal file
28
CadQuery/Examples/Ex017_Shelling_to_Create_Thin_Features.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#File: Ex017_Shelling_to_Create_Thin_Features.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex017_Shelling_to_Create_Thin_Features
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex017_Shelling_to_Create_Thin_Features)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a hollow box that's open on both ends with a thin wall
|
||||||
|
result = cadquery.Workplane("front").box(2, 2, 2).faces("+Z").shell(0.05)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
29
CadQuery/Examples/Ex018_Making_Lofts.py
Normal file
29
CadQuery/Examples/Ex018_Making_Lofts.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#File: Ex018_Making_Lofts.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex018_Making_Lofts
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex018_Making_Lofts)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a lofted section between a rectangle and a circular section
|
||||||
|
result = cadquery.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").circle(1.5) \
|
||||||
|
.workplane(offset=3.0).rect(0.75, 0.5).loft(combine=True)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
30
CadQuery/Examples/Ex019_Counter_Sunk_Holes.py
Normal file
30
CadQuery/Examples/Ex019_Counter_Sunk_Holes.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#File: Ex019_Counter_Sunk_Holes.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex019_Counter_Sunk_Holes
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex019_Counter_Sunk_Holes)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a plate with 4 counter-sunk holes in it
|
||||||
|
result = cadquery.Workplane(cadquery.Plane.XY()).box(4, 2, 0.5).faces(">Z").workplane() \
|
||||||
|
.rect(3.5, 1.5, forConstruction=True)\
|
||||||
|
.vertices().cskHole(0.125, 0.25, 82.0, depth=None)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
28
CadQuery/Examples/Ex020_Rounding_Corners_with_Fillets.py
Normal file
28
CadQuery/Examples/Ex020_Rounding_Corners_with_Fillets.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#File: Ex020_Rounding_Corners_with_Fillets.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex020_Rounding_Corners_with_Fillets
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex020_Rounding_Corners_with_Fillets)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a plate with 4 rounded corners in the Z-axis
|
||||||
|
result = cadquery.Workplane("XY").box(3, 3, 0.5).edges("|Z").fillet(0.125)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
31
CadQuery/Examples/Ex021_Splitting_an_Object.py
Normal file
31
CadQuery/Examples/Ex021_Splitting_an_Object.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#File: Ex021_Splitting_an_Object.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex021_Splitting_an_Object
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex021_Splitting_an_Object)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Create a simple block with a hole through it that we can split
|
||||||
|
c = cadquery.Workplane("XY").box(1, 1, 1).faces(">Z").workplane().circle(0.25).cutThruAll()
|
||||||
|
|
||||||
|
#Cut the block in half sideways
|
||||||
|
result = c.faces(">Y").workplane(-0.5).split(keepTop=True)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
40
CadQuery/Examples/Ex022_Classic_OCC_Bottle.py
Normal file
40
CadQuery/Examples/Ex022_Classic_OCC_Bottle.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#File: Ex022_Classic_OCC_Bottle.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex022_Classic_OCC_Bottle
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex022_Classic_OCC_Bottle)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Set up the length, width, and thickness
|
||||||
|
(L,w,t) = (20.0, 6.0, 3.0)
|
||||||
|
s = cadquery.Workplane("XY")
|
||||||
|
|
||||||
|
#Draw half the profile of the bottle and extrude it
|
||||||
|
p = s.center(-L / 2.0, 0).vLine(w / 2.0) \
|
||||||
|
.threePointArc((L / 2.0, w / 2.0 + t),(L, w / 2.0)).vLine(-w / 2.0) \
|
||||||
|
.mirrorX().extrude(30.0, True)
|
||||||
|
|
||||||
|
#Make the neck
|
||||||
|
p.faces(">Z").workplane().circle(3.0).extrude(2.0, True)
|
||||||
|
|
||||||
|
#Make a shell
|
||||||
|
result = p.faces(">Z").shell(0.3)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
102
CadQuery/Examples/Ex023_Parametric_Enclosure.py
Normal file
102
CadQuery/Examples/Ex023_Parametric_Enclosure.py
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#File: Ex023_Parametric_Enclosure.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex023_Parametric_Enclosure
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex023_Parametric_Enclosure)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#Parameter definitions
|
||||||
|
p_outerWidth = 100.0 # Outer width of box enclosure
|
||||||
|
p_outerLength = 150.0 # Outer length of box enclosure
|
||||||
|
p_outerHeight = 50.0 # Outer height of box enclosure
|
||||||
|
|
||||||
|
p_thickness = 3.0 # Thickness of the box walls
|
||||||
|
p_sideRadius = 10.0 # Radius for the curves around the sides of the bo
|
||||||
|
p_topAndBottomRadius = 2.0 # Radius for the curves on the top and bottom edges of the box
|
||||||
|
|
||||||
|
p_screwpostInset = 12.0 # How far in from the edges the screwposts should be placed
|
||||||
|
p_screwpostID = 4.0 # Inner diameter of the screwpost holes, should be roughly screw diameter not including threads
|
||||||
|
p_screwpostOD = 10.0 # Outer diameter of the screwposts. Determines overall thickness of the posts
|
||||||
|
|
||||||
|
p_boreDiameter = 8.0 # Diameter of the counterbore hole, if any
|
||||||
|
p_boreDepth = 1.0 # Depth of the counterbore hole, if
|
||||||
|
p_countersinkDiameter = 0.0 # Outer diameter of countersink. Should roughly match the outer diameter of the screw head
|
||||||
|
p_countersinkAngle = 90.0 # Countersink angle (complete angle between opposite sides, not from center to one side)
|
||||||
|
p_flipLid = True # Whether to place the lid with the top facing down or not.
|
||||||
|
p_lipHeight = 1.0 # Height of lip on the underside of the lid. Sits inside the box body for a snug fit.
|
||||||
|
|
||||||
|
#Outer shell
|
||||||
|
oshell = cadquery.Workplane("XY").rect(p_outerWidth, p_outerLength).extrude(p_outerHeight + p_lipHeight)
|
||||||
|
|
||||||
|
#Weird geometry happens if we make the fillets in the wrong order
|
||||||
|
if p_sideRadius > p_topAndBottomRadius:
|
||||||
|
oshell.edges("|Z").fillet(p_sideRadius)
|
||||||
|
oshell.edges("#Z").fillet(p_topAndBottomRadius)
|
||||||
|
else:
|
||||||
|
oshell.edges("#Z").fillet(p_topAndBottomRadius)
|
||||||
|
oshell.edges("|Z").fillet(p_sideRadius)
|
||||||
|
|
||||||
|
#Inner shell
|
||||||
|
ishell = oshell.faces("<Z").workplane(p_thickness, True)\
|
||||||
|
.rect((p_outerWidth - 2.0 * p_thickness),(p_outerLength - 2.0 * p_thickness))\
|
||||||
|
.extrude((p_outerHeight - 2.0 * p_thickness), False) # Set combine false to produce just the new boss
|
||||||
|
ishell.edges("|Z").fillet(p_sideRadius - p_thickness)
|
||||||
|
|
||||||
|
#Make the box outer box
|
||||||
|
box = oshell.cut(ishell)
|
||||||
|
|
||||||
|
#Make the screwposts
|
||||||
|
POSTWIDTH = (p_outerWidth - 2.0 * p_screwpostInset)
|
||||||
|
POSTLENGTH = (p_outerLength - 2.0 * p_screwpostInset)
|
||||||
|
|
||||||
|
postCenters = box.faces(">Z").workplane(-p_thickness)\
|
||||||
|
.rect(POSTWIDTH, POSTLENGTH, forConstruction=True)\
|
||||||
|
.vertices()
|
||||||
|
|
||||||
|
for v in postCenters.all():
|
||||||
|
v.circle(p_screwpostOD / 2.0).circle(p_screwpostID / 2.0)\
|
||||||
|
.extrude((-1.0) * ((p_outerHeight + p_lipHeight) - (2.0 * p_thickness)), True)
|
||||||
|
|
||||||
|
#Split lid into top and bottom parts
|
||||||
|
(lid, bottom) = box.faces(">Z").workplane(-p_thickness - p_lipHeight).split(keepTop=True, keepBottom=True).all()
|
||||||
|
|
||||||
|
#Translate the lid, and subtract the bottom from it to produce the lid inset
|
||||||
|
lowerLid = lid.translate((0, 0, -p_lipHeight))
|
||||||
|
cutlip = lowerLid.cut(bottom).translate((p_outerWidth + p_thickness, 0, p_thickness - p_outerHeight + p_lipHeight))
|
||||||
|
|
||||||
|
#Compute centers for counterbore/countersink or counterbore
|
||||||
|
topOfLidCenters = cutlip.faces(">Z").workplane().rect(POSTWIDTH, POSTLENGTH, forConstruction=True).vertices()
|
||||||
|
|
||||||
|
#Add holes of the desired type
|
||||||
|
if p_boreDiameter > 0 and p_boreDepth > 0:
|
||||||
|
topOfLid = topOfLidCenters.cboreHole(p_screwpostID, p_boreDiameter, p_boreDepth, (2.0) * p_thickness)
|
||||||
|
elif p_countersinkDiameter > 0 and p_countersinkAngle > 0:
|
||||||
|
topOfLid = topOfLidCenters.cskHole(p_screwpostID, p_countersinkDiameter, p_countersinkAngle, (2.0) * p_thickness)
|
||||||
|
else:
|
||||||
|
topOfLid= topOfLidCenters.hole(p_screwpostID, 2.0 * p_thickness)
|
||||||
|
|
||||||
|
#Flip lid upside down if desired
|
||||||
|
if p_flipLid:
|
||||||
|
topOfLid.rotateAboutCenter((1, 0, 0), 180)
|
||||||
|
|
||||||
|
#Return the combined result
|
||||||
|
result = topOfLid.combineSolids(bottom)
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
|
@ -0,0 +1,41 @@
|
||||||
|
#File: Ex024_Using_FreeCAD_Solids_as_CQ_Objects.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex024_Using_FreeCAD_Solids_as_CQ_Objects
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex024_Using_FreeCAD_Solids_as_CQ_Objects)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery, FreeCAD, Part
|
||||||
|
|
||||||
|
#Create a new document that we can draw our model on
|
||||||
|
newDoc = FreeCAD.newDocument()
|
||||||
|
|
||||||
|
#shows a 1x1x1 FreeCAD cube in the display
|
||||||
|
initialBox = newDoc.addObject("Part::Box","initialBox")
|
||||||
|
newDoc.recompute()
|
||||||
|
|
||||||
|
#Make a CQ object
|
||||||
|
cqBox = cadquery.CQ(cadquery.Solid(initialBox.Shape))
|
||||||
|
|
||||||
|
#Extrude a peg
|
||||||
|
newThing = cqBox.faces(">Z").workplane().circle(0.5).extrude(0.25)
|
||||||
|
|
||||||
|
#Add a FreeCAD object to the tree and then store a CQ object in it
|
||||||
|
nextShape = newDoc.addObject("Part::Feature", "nextShape")
|
||||||
|
nextShape.Shape = newThing.val().wrapped
|
||||||
|
|
||||||
|
#Rerender the doc to see what the new solid looks like
|
||||||
|
newDoc.recompute()
|
41
CadQuery/Examples/Ex025_Revolution.py
Normal file
41
CadQuery/Examples/Ex025_Revolution.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#File: Ex025_Revolution.py
|
||||||
|
#To use this example file, you need to first follow the "Using CadQuery From Inside FreeCAD"
|
||||||
|
#instructions here: https://github.com/dcowden/cadquery#installing----using-cadquery-from-inside-freecad
|
||||||
|
|
||||||
|
#You run this example by typing the following in the FreeCAD python console, making sure to change
|
||||||
|
#the path to this example, and the name of the example appropriately.
|
||||||
|
#import sys
|
||||||
|
#sys.path.append('/home/user/Downloads/cadquery/examples/FreeCAD')
|
||||||
|
#import Ex025_Revolution
|
||||||
|
|
||||||
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
|
#reload(Ex025_Revolution)
|
||||||
|
|
||||||
|
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
|
||||||
|
# (Shape001, etc).
|
||||||
|
|
||||||
|
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
|
||||||
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
|
import cadquery
|
||||||
|
import Part
|
||||||
|
|
||||||
|
#The dimensions of the model. These can be modified rather than changing the shape's code directly.
|
||||||
|
rectangle_width = 10.0
|
||||||
|
rectangle_length = 10.0
|
||||||
|
angle_degrees = 360.0
|
||||||
|
|
||||||
|
#Revolve a cylinder from a rectangle
|
||||||
|
#Switch comments around in this section to try the revolve operation with different parameters
|
||||||
|
result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length, False).revolve()
|
||||||
|
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length, False).revolve(angle_degrees)
|
||||||
|
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length).revolve(angle_degrees,(-5,-5))
|
||||||
|
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length).revolve(angle_degrees,(-5, -5),(-5, 5))
|
||||||
|
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length).revolve(angle_degrees,(-5,-5),(-5,5), False)
|
||||||
|
|
||||||
|
#Revolve a donut with square walls
|
||||||
|
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length, True).revolve(angle_degrees, (20, 0), (20, 10))
|
||||||
|
|
||||||
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
|
Part.show(result.toFreecad())
|
|
@ -15,8 +15,12 @@ class CadQueryWorkbench (Workbench):
|
||||||
|
|
||||||
def Initialize(self):
|
def Initialize(self):
|
||||||
import os
|
import os
|
||||||
|
|
||||||
os.environ['QT_API'] = 'pyside'
|
os.environ['QT_API'] = 'pyside'
|
||||||
|
|
||||||
|
#sys.path.append('./Libs/cadquery.zip')
|
||||||
|
#sys.path.append('./Libs/pyqode.zip')
|
||||||
|
|
||||||
#If we need a CQ menu, this would be the way to add it
|
#If we need a CQ menu, this would be the way to add it
|
||||||
commands = ['CadQueryOpenScript', 'CadQuerySaveScript', 'CadQuerySaveAsScript', 'CadQueryExecuteScript',
|
commands = ['CadQueryOpenScript', 'CadQuerySaveScript', 'CadQuerySaveAsScript', 'CadQueryExecuteScript',
|
||||||
'CadQueryCloseScript']
|
'CadQueryCloseScript']
|
||||||
|
@ -57,20 +61,31 @@ class CadQueryWorkbench (Workbench):
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
QtGui.QApplication.UnicodeUTF8)
|
||||||
FreeCAD.Console.PrintError(msg)
|
FreeCAD.Console.PrintError(msg)
|
||||||
|
|
||||||
try:
|
#try:
|
||||||
|
# import os, sys, inspect
|
||||||
|
# cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0], "Libs/")))
|
||||||
|
# if cmd_subfolder not in sys.path:
|
||||||
|
# sys.path.append(cmd_subfolder)
|
||||||
|
import sys
|
||||||
|
sys.path.insert(0, '/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Libs/pyqode.zip')
|
||||||
|
sys.path.insert(0, '/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Libs/cadquery.zip')
|
||||||
|
sys.path.append('/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Libs/pyqode.zip')
|
||||||
|
sys.path.append('/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Libs/cadquery.zip')
|
||||||
|
#sys.path.insert(0, '/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Libs')
|
||||||
|
|
||||||
from pyqode.qt import QtWidgets
|
from pyqode.qt import QtWidgets
|
||||||
from pyqode.python.backend import server
|
from pyqode.python.backend import server
|
||||||
from pyqode.python.widgets import PyCodeEdit
|
from pyqode.python.widgets import PyCodeEdit
|
||||||
from pyqode.python.widgets import code_edit
|
from pyqode.python.widgets import code_edit
|
||||||
|
|
||||||
except ImportError:
|
# except ImportError:
|
||||||
msg = QtGui.QApplication.translate(
|
# msg = QtGui.QApplication.translate(
|
||||||
"cqCodeWidget",
|
# "cqCodeWidget",
|
||||||
"The pyQode library is not installed, please install it before using this workbench.\r\n"
|
# "The pyQode library is not installed, please install it before using this workbench.\r\n"
|
||||||
"Linux and MacOS Users: 'pip install --upgrade pyqode.core pyqode.qt pyqode.python'\r\n",
|
# "Linux and MacOS Users: 'pip install --upgrade pyqode.core pyqode.qt pyqode.python'\r\n",
|
||||||
None,
|
# None,
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
# QtGui.QApplication.UnicodeUTF8)
|
||||||
FreeCAD.Console.PrintError(msg)
|
# FreeCAD.Console.PrintError(msg)
|
||||||
|
|
||||||
#Make sure that we enforce a specific version (2.7) of the Python interpreter
|
#Make sure that we enforce a specific version (2.7) of the Python interpreter
|
||||||
ver = hex(sys.hexversion)
|
ver = hex(sys.hexversion)
|
||||||
|
@ -109,7 +124,7 @@ class CadQueryWorkbench (Workbench):
|
||||||
mw.addDockWidget(QtCore.Qt.LeftDockWidgetArea, cqCodeWidget)
|
mw.addDockWidget(QtCore.Qt.LeftDockWidgetArea, cqCodeWidget)
|
||||||
|
|
||||||
#Set up the text area for our CQ code
|
#Set up the text area for our CQ code
|
||||||
codePane = PyCodeEdit(server_script=server.__file__, interpreter=interpreter)
|
codePane = PyCodeEdit(server_script=server.__file__, interpreter=interpreter, args=['-S', '/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Libs/pyqode.zip'])
|
||||||
codePane.setObjectName("cqCodePane")
|
codePane.setObjectName("cqCodePane")
|
||||||
|
|
||||||
#Add the text area to our dock widget
|
#Add the text area to our dock widget
|
||||||
|
|
BIN
CadQuery/Libs/cadquery.zip
Normal file
BIN
CadQuery/Libs/cadquery.zip
Normal file
Binary file not shown.
BIN
CadQuery/Libs/pyqode.zip
Normal file
BIN
CadQuery/Libs/pyqode.zip
Normal file
Binary file not shown.
15
CadQuery/Tools/package_libraries.py
Normal file
15
CadQuery/Tools/package_libraries.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from qidle.system import embed_package_into_zip
|
||||||
|
|
||||||
|
import jedi
|
||||||
|
import pep8
|
||||||
|
import pyqode
|
||||||
|
import pyqode.core
|
||||||
|
import pyqode.python
|
||||||
|
import pyqode.qt
|
||||||
|
import qidle
|
||||||
|
import frosted
|
||||||
|
import pies
|
||||||
|
import cadquery
|
||||||
|
|
||||||
|
embed_package_into_zip([jedi, pep8, pyqode.core, pyqode.python, pyqode.qt, qidle, frosted, pies, cadquery],
|
||||||
|
zip_path='/home/jwright/Documents/Projects/CadQuery/cadquery-freecad-module/CadQuery/Tools/libraries.zip')
|
Loading…
Reference in New Issue
Block a user