Added toFreecad function and modified the examples to use it. Also cleaned up minor PEP non-conformances.
This commit is contained in:
parent
83e61efbe4
commit
528e4e3a46
|
@ -256,6 +256,15 @@ class CQ(object):
|
||||||
"""
|
"""
|
||||||
return self.objects[0]
|
return self.objects[0]
|
||||||
|
|
||||||
|
def toFreecad(self):
|
||||||
|
"""
|
||||||
|
Directly returns the wrapped FreeCAD object to cut down on the amount of boiler plate code needed when
|
||||||
|
rendering a model in FreeCAD's 3D view.
|
||||||
|
:return: The wrapped FreeCAD object
|
||||||
|
:rtype A FreeCAD object or a SolidReference
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.objects[0].wrapped
|
||||||
|
|
||||||
|
|
||||||
def workplane(self,offset=0.0,invert=False):
|
def workplane(self,offset=0.0,invert=False):
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more in-depth explanation of this example at http://parametricparts.com/docs/quickstart.html
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -27,10 +28,5 @@ thickness = 10.0
|
||||||
#Create a 3D box based on the dimension variables above
|
#Create a 3D box based on the dimension variables above
|
||||||
result = cadquery.Workplane("XY").box(length, height, thickness)
|
result = cadquery.Workplane("XY").box(length, height, thickness)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -27,12 +27,7 @@ center_hole_dia = 22.0
|
||||||
|
|
||||||
#Create a 3D box based on the dimension variables above and add a 22mm center hole
|
#Create a 3D box based on the dimension variables above and add a 22mm center hole
|
||||||
result = cadquery.Workplane("XY").box(length, height, thickness) \
|
result = cadquery.Workplane("XY").box(length, height, thickness) \
|
||||||
.faces(">Z").workplane().hole(center_hole_dia)
|
.faces(">Z").workplane().hole(center_hole_dia)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,11 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more in-depth explanation of this example at http://parametricparts.com/docs/quickstart.html
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -30,15 +31,10 @@ cbore_depth = 2.1
|
||||||
|
|
||||||
#Create a 3D box based on the dimension variables above and add 4 counterbored holes
|
#Create a 3D box based on the dimension variables above and add 4 counterbored holes
|
||||||
result = cadquery.Workplane("XY").box(length, height, thickness) \
|
result = cadquery.Workplane("XY").box(length, height, thickness) \
|
||||||
.faces(">Z").workplane().hole(center_hole_dia) \
|
.faces(">Z").workplane().hole(center_hole_dia) \
|
||||||
.faces(">Z").workplane() \
|
.faces(">Z").workplane() \
|
||||||
.rect(length - 8.0, height - 8.0, forConstruction = True) \
|
.rect(length - 8.0, height - 8.0, forConstruction = True) \
|
||||||
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
|
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -22,16 +24,11 @@ import Part
|
||||||
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
#The dimensions of the model. These can be modified rather than changing the box's code directly.
|
||||||
circle_radius = 50.0
|
circle_radius = 50.0
|
||||||
rectangle_width = 13.0
|
rectangle_width = 13.0
|
||||||
rectange_length = 19.0
|
rectangle_length = 19.0
|
||||||
thickness = 13.0
|
thickness = 13.0
|
||||||
|
|
||||||
#Extrude a cylindrical plate with a rectangular hole in the middle of it
|
#Extrude a cylindrical plate with a rectangular hole in the middle of it
|
||||||
result = cadquery.Workplane("front").circle(circle_radius).rect(rectangle_width, rectange_length).extrude(thickness)
|
result = cadquery.Workplane("front").circle(circle_radius).rect(rectangle_width, rectangle_length).extrude(thickness)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -24,12 +26,8 @@ width = 2.0
|
||||||
thickness = 0.25
|
thickness = 0.25
|
||||||
|
|
||||||
#Extrude a plate outline made of lines and an arc
|
#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)
|
result = cadquery.Workplane("front").lineTo(width, 0).lineTo(width, 1.0).threePointArc((1.0, 1.5),(0.0, 1.0)) \
|
||||||
|
.close().extrude(thickness)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -24,18 +26,13 @@ circle_radius = 3.0
|
||||||
thickness = 0.25
|
thickness = 0.25
|
||||||
|
|
||||||
#Make the plate with two cutouts in it
|
#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 = 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,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).
|
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!
|
#The new center is specified relative to the previous center, not global coordinates!
|
||||||
|
|
||||||
result = result.extrude(thickness)
|
result = result.extrude(thickness)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -25,15 +27,10 @@ hole_pattern_radius = 0.25
|
||||||
thickness = 0.125
|
thickness = 0.125
|
||||||
|
|
||||||
#Make the plate with 4 holes in it at various points
|
#Make the plate with 4 holes in it at various points
|
||||||
r = cadquery.Workplane("front").circle(plate_radius) #Make the base
|
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.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
|
r = r.circle(hole_pattern_radius) # Circle will operate on all four points
|
||||||
result = r.extrude(thickness)
|
result = r.extrude(thickness)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -27,13 +29,8 @@ polygon_sides = 6
|
||||||
polygon_dia = 1.0
|
polygon_dia = 1.0
|
||||||
|
|
||||||
#Create a plate with two polygons cut through it
|
#Create a plate with two polygons cut through it
|
||||||
result = cadquery.Workplane("front").box(width, height, thickness).pushPoints ( [ ( 0,0.75 ),(0,-0.75) ]) \
|
result = cadquery.Workplane("front").box(width, height, thickness).pushPoints([(0, 0.75), (0, -0.75)]) \
|
||||||
.polygon(polygon_sides, polygon_dia).cutThruAll()
|
.polygon(polygon_sides, polygon_dia).cutThruAll()
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,16 +11,19 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
#reload(Ex009_Polylines)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
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
|
#Set up our Length, Height, Width, and thickness that will be used to define the locations that the polyline
|
||||||
(L,H,W,t) = ( 100.0, 20.0, 20.0, 1.0)
|
#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
|
#Define the locations that the polyline will be drawn to/thru
|
||||||
pts = [
|
pts = [
|
||||||
|
@ -29,7 +32,7 @@ pts = [
|
||||||
(W/2.0, (H/2.0 - t)),
|
(W/2.0, (H/2.0 - t)),
|
||||||
(t/2.0, (H/2.0-t)),
|
(t/2.0, (H/2.0-t)),
|
||||||
(t/2.0, (t - H/2.0)),
|
(t/2.0, (t - H/2.0)),
|
||||||
(W/2.0, (t -H/2.0)),
|
(W/2.0, (t - H/2.0)),
|
||||||
(W/2.0, H/-2.0),
|
(W/2.0, H/-2.0),
|
||||||
(0, H/-2.0)
|
(0, H/-2.0)
|
||||||
]
|
]
|
||||||
|
@ -37,10 +40,5 @@ pts = [
|
||||||
#We generate half of the I-beam outline and then mirror it to create the full I-beam
|
#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)
|
result = cadquery.Workplane("front").polyline(pts).mirrorY().extrude(L)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -39,10 +41,5 @@ r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts).close()
|
||||||
#Extrude to turn the wire into a plate
|
#Extrude to turn the wire into a plate
|
||||||
result = r.extrude(0.5)
|
result = r.extrude(0.5)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -26,12 +28,7 @@ r = cadquery.Workplane("front").hLine(1.0)
|
||||||
r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0)
|
r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0)
|
||||||
|
|
||||||
#Mirror the geometry and extrude
|
#Mirror the geometry and extrude
|
||||||
result =r.mirrorY().extrude(0.25)
|
result = r.mirrorY().extrude(0.25)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -25,10 +27,5 @@ result = cadquery.Workplane("front").box(2,3,0.5)
|
||||||
#Find the top-most face and make a hole
|
#Find the top-most face and make a hole
|
||||||
result = result.faces(">Z").workplane().hole(0.5)
|
result = result.faces(">Z").workplane().hole(0.5)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,16 +11,18 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Make a basic prism
|
#Make a basic prism
|
||||||
result = cadquery.Workplane("front").box(3,2,0.5)
|
result = cadquery.Workplane("front").box(3, 2, 0.5)
|
||||||
|
|
||||||
#Select the lower left vertex and make a workplane
|
#Select the lower left vertex and make a workplane
|
||||||
result = result.faces(">Z").vertices("<XY").workplane()
|
result = result.faces(">Z").vertices("<XY").workplane()
|
||||||
|
@ -28,10 +30,5 @@ result = result.faces(">Z").vertices("<XY").workplane()
|
||||||
#Cut the corner out
|
#Cut the corner out
|
||||||
result = result.circle(1.0).cutThruAll()
|
result = result.circle(1.0).cutThruAll()
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,16 +11,18 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Make a basic prism
|
#Make a basic prism
|
||||||
result = cadquery.Workplane("front").box(3,2,0.5)
|
result = cadquery.Workplane("front").box(3, 2, 0.5)
|
||||||
|
|
||||||
#Workplane is offset from the object surface
|
#Workplane is offset from the object surface
|
||||||
result = result.faces("<X").workplane(offset=0.75)
|
result = result.faces("<X").workplane(offset=0.75)
|
||||||
|
@ -28,10 +30,5 @@ result = result.faces("<X").workplane(offset=0.75)
|
||||||
#Create a disc
|
#Create a disc
|
||||||
result = result.circle(1.0).extrude(0.5)
|
result = result.circle(1.0).extrude(0.5)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,24 +11,22 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
from cadquery import Vector
|
from cadquery import Vector
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Create a rotated workplane and put holes in each corner of a rectangle on that workplane, producing angled holes in the face
|
#Create a rotated workplane and put holes in each corner of a rectangle on that workplane, producing angled holes
|
||||||
result = cadquery.Workplane("front").box(4.0,4.0,0.25).faces(">Z").workplane() \
|
#in the face
|
||||||
.transformed(offset=Vector(0,-1.5,1.0),rotate=Vector(60,0,0)) \
|
result = cadquery.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").workplane() \
|
||||||
.rect(1.5,1.5,forConstruction=True).vertices().hole(0.25)
|
.transformed(offset=Vector(0, -1.5, 1.0), rotate=Vector(60, 0, 0)) \
|
||||||
|
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.25)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -23,10 +25,5 @@ import Part
|
||||||
result = cadquery.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane() \
|
result = cadquery.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane() \
|
||||||
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125)
|
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,21 +11,18 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Create a hollow box that's open on both ends with a thin wall
|
#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)
|
result = cadquery.Workplane("front").box(2, 2, 2).faces("+Z").shell(0.05)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -23,10 +25,5 @@ import Part
|
||||||
result = cadquery.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").circle(1.5) \
|
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)
|
.workplane(offset=3.0).rect(0.75, 0.5).loft(combine=True)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,22 +11,20 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Create a plate with 4 counter-sunk holes in it
|
#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)\
|
result = cadquery.Workplane(cadquery.Plane.XY()).box(4, 2, 0.5).faces(">Z").workplane() \
|
||||||
.vertices().cskHole(0.125, 0.25, 82.0, depth=None)
|
.rect(3.5, 1.5, forConstruction=True)\
|
||||||
|
.vertices().cskHole(0.125, 0.25, 82.0, depth=None)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,21 +11,18 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Create a plate with 4 rounded corners in the Z-axis
|
#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)
|
result = cadquery.Workplane("XY").box(3, 3, 0.5).edges("|Z").fillet(0.125)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -25,10 +27,5 @@ c = cadquery.Workplane("XY").box(1, 1, 1).faces(">Z").workplane().circle(0.25).c
|
||||||
#Cut the block in half sideways
|
#Cut the block in half sideways
|
||||||
result = c.faces(">Y").workplane(-0.5).split(keepTop=True)
|
result = c.faces(">Y").workplane(-0.5).split(keepTop=True)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -34,10 +36,5 @@ p.faces(">Z").workplane().circle(3.0).extrude(2.0, True)
|
||||||
#Make a shell
|
#Make a shell
|
||||||
result = p.faces(">Z").shell(0.3)
|
result = p.faces(">Z").shell(0.3)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,33 +11,35 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
|
||||||
#Parameter definitions
|
#Parameter definitions
|
||||||
p_outerWidth = 100.0 #Outer width of box enclosure
|
p_outerWidth = 100.0 # Outer width of box enclosure
|
||||||
p_outerLength = 150.0 #Outer length of box enclosure
|
p_outerLength = 150.0 # Outer length of box enclosure
|
||||||
p_outerHeight = 50.0 #Outer height of box enclosure
|
p_outerHeight = 50.0 # Outer height of box enclosure
|
||||||
|
|
||||||
p_thickness = 3.0 #Thickness of the box walls
|
p_thickness = 3.0 # Thickness of the box walls
|
||||||
p_sideRadius = 10.0 #Radius for the curves around the sides of the bo
|
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_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_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_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_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_boreDiameter = 8.0 # Diameter of the counterbore hole, if any
|
||||||
p_boreDepth = 1.0 #Depth of the counterbore hole, if
|
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_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_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_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.
|
p_lipHeight = 1.0 # Height of lip on the underside of the lid. Sits inside the box body for a snug fit.
|
||||||
|
|
||||||
#Outer shell
|
#Outer shell
|
||||||
oshell = cadquery.Workplane("XY").rect(p_outerWidth, p_outerLength).extrude(p_outerHeight + p_lipHeight)
|
oshell = cadquery.Workplane("XY").rect(p_outerWidth, p_outerLength).extrude(p_outerHeight + p_lipHeight)
|
||||||
|
@ -53,7 +55,7 @@ else:
|
||||||
#Inner shell
|
#Inner shell
|
||||||
ishell = oshell.faces("<Z").workplane(p_thickness, True)\
|
ishell = oshell.faces("<Z").workplane(p_thickness, True)\
|
||||||
.rect((p_outerWidth - 2.0 * p_thickness),(p_outerLength - 2.0 * p_thickness))\
|
.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
|
.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)
|
ishell.edges("|Z").fillet(p_sideRadius - p_thickness)
|
||||||
|
|
||||||
#Make the box outer box
|
#Make the box outer box
|
||||||
|
@ -61,7 +63,7 @@ box = oshell.cut(ishell)
|
||||||
|
|
||||||
#Make the screwposts
|
#Make the screwposts
|
||||||
POSTWIDTH = (p_outerWidth - 2.0 * p_screwpostInset)
|
POSTWIDTH = (p_outerWidth - 2.0 * p_screwpostInset)
|
||||||
POSTLENGTH = (p_outerLength - 2.0 * p_screwpostInset)
|
POSTLENGTH = (p_outerLength - 2.0 * p_screwpostInset)
|
||||||
|
|
||||||
postCenters = box.faces(">Z").workplane(-p_thickness)\
|
postCenters = box.faces(">Z").workplane(-p_thickness)\
|
||||||
.rect(POSTWIDTH, POSTLENGTH, forConstruction=True)\
|
.rect(POSTWIDTH, POSTLENGTH, forConstruction=True)\
|
||||||
|
@ -72,11 +74,11 @@ for v in postCenters.all():
|
||||||
.extrude((-1.0) * ((p_outerHeight + p_lipHeight) - (2.0 * p_thickness)), True)
|
.extrude((-1.0) * ((p_outerHeight + p_lipHeight) - (2.0 * p_thickness)), True)
|
||||||
|
|
||||||
#Split lid into top and bottom parts
|
#Split lid into top and bottom parts
|
||||||
(lid, bottom) = box.faces(">Z").workplane(-p_thickness - p_lipHeight ).split(keepTop=True, keepBottom=True).all() #splits into two solids
|
(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
|
#Translate the lid, and subtract the bottom from it to produce the lid inset
|
||||||
lowerLid = lid.translate((0,0, -p_lipHeight))
|
lowerLid = lid.translate((0, 0, -p_lipHeight))
|
||||||
cutlip = lowerLid.cut(bottom).translate((p_outerWidth + p_thickness , 0, p_thickness - p_outerHeight + 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
|
#Compute centers for counterbore/countersink or counterbore
|
||||||
topOfLidCenters = cutlip.faces(">Z").workplane().rect(POSTWIDTH, POSTLENGTH, forConstruction=True).vertices()
|
topOfLidCenters = cutlip.faces(">Z").workplane().rect(POSTWIDTH, POSTLENGTH, forConstruction=True).vertices()
|
||||||
|
@ -87,7 +89,7 @@ if p_boreDiameter > 0 and p_boreDepth > 0:
|
||||||
elif p_countersinkDiameter > 0 and p_countersinkAngle > 0:
|
elif p_countersinkDiameter > 0 and p_countersinkAngle > 0:
|
||||||
topOfLid = topOfLidCenters.cskHole(p_screwpostID, p_countersinkDiameter, p_countersinkAngle, (2.0) * p_thickness)
|
topOfLid = topOfLidCenters.cskHole(p_screwpostID, p_countersinkDiameter, p_countersinkAngle, (2.0) * p_thickness)
|
||||||
else:
|
else:
|
||||||
topOfLid= topOfLidCenters.hole(p_screwpostID, (2.0) * p_thickness)
|
topOfLid= topOfLidCenters.hole(p_screwpostID, 2.0 * p_thickness)
|
||||||
|
|
||||||
#Flip lid upside down if desired
|
#Flip lid upside down if desired
|
||||||
if p_flipLid:
|
if p_flipLid:
|
||||||
|
@ -96,10 +98,5 @@ if p_flipLid:
|
||||||
#Return the combined result
|
#Return the combined result
|
||||||
result = topOfLid.combineSolids(bottom)
|
result = topOfLid.combineSolids(bottom)
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,14 +11,16 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#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)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery, FreeCAD, Part
|
import cadquery, FreeCAD, Part
|
||||||
|
|
||||||
#Create a new document that we can draw our modle on
|
#Create a new document that we can draw our model on
|
||||||
newDoc = FreeCAD.newDocument()
|
newDoc = FreeCAD.newDocument()
|
||||||
|
|
||||||
#shows a 1x1x1 FreeCAD cube in the display
|
#shows a 1x1x1 FreeCAD cube in the display
|
||||||
|
@ -32,10 +34,8 @@ cqBox = cadquery.CQ(cadquery.Solid(initialBox.Shape))
|
||||||
newThing = cqBox.faces(">Z").workplane().circle(0.5).extrude(0.25)
|
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
|
#Add a FreeCAD object to the tree and then store a CQ object in it
|
||||||
nextShape = newDoc.addObject("Part::Feature","nextShape")
|
nextShape = newDoc.addObject("Part::Feature", "nextShape")
|
||||||
nextShape.Shape = newThing.val().wrapped
|
nextShape.Shape = newThing.val().wrapped
|
||||||
|
|
||||||
#Rerender the doc to see what the new solid looks like
|
#Rerender the doc to see what the new solid looks like
|
||||||
newDoc.recompute()
|
newDoc.recompute()
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
|
||||||
#reload(Ex025_Revolution)
|
#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'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 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
|
#You can get a more information on this example at
|
||||||
|
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
import Part
|
import Part
|
||||||
|
@ -35,10 +37,5 @@ result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length, False)
|
||||||
#Revolve a donut with square walls
|
#Revolve a donut with square walls
|
||||||
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length, True).revolve(angle_degrees, (20, 0), (20, 10))
|
#result = cadquery.Workplane("XY").rect(rectangle_width, rectangle_length, True).revolve(angle_degrees, (20, 0), (20, 10))
|
||||||
|
|
||||||
#Get a cadquery solid object
|
#Boiler plate code to render our solid in FreeCAD's GUI
|
||||||
solid = result.val()
|
Part.show(result.toFreecad())
|
||||||
|
|
||||||
#Use the wrapped property of a cadquery primitive to get a FreeCAD solid
|
|
||||||
Part.show(solid.wrapped)
|
|
||||||
|
|
||||||
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user