diff --git a/Examples/Ex001_Simple_Block.py b/Examples/Ex001_Simple_Block.py index 12c0ae5..f72445f 100644 --- a/Examples/Ex001_Simple_Block.py +++ b/Examples/Ex001_Simple_Block.py @@ -16,4 +16,4 @@ result = cq.Workplane("XY").box(length, height, thickness) # from Helpers import show # show(result) # Render the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex002_Block_With_Bored_Center_Hole.py b/Examples/Ex002_Block_With_Bored_Center_Hole.py index a1dda36..a825f98 100644 --- a/Examples/Ex002_Block_With_Bored_Center_Hole.py +++ b/Examples/Ex002_Block_With_Bored_Center_Hole.py @@ -17,4 +17,4 @@ result = cq.Workplane("XY").box(length, height, thickness) \ .faces(">Z").workplane().hole(center_hole_dia) # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex003_Pillow_Block_With_Counterbored_Holes.py b/Examples/Ex003_Pillow_Block_With_Counterbored_Holes.py index 981b5c1..50ad422 100644 --- a/Examples/Ex003_Pillow_Block_With_Counterbored_Holes.py +++ b/Examples/Ex003_Pillow_Block_With_Counterbored_Holes.py @@ -31,4 +31,4 @@ result = cq.Workplane("XY").box(length, height, thickness) \ .vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth) # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex004_Extruded_Cylindrical_Plate.py b/Examples/Ex004_Extruded_Cylindrical_Plate.py index 4ab483d..6ccb2ec 100644 --- a/Examples/Ex004_Extruded_Cylindrical_Plate.py +++ b/Examples/Ex004_Extruded_Cylindrical_Plate.py @@ -26,4 +26,4 @@ result = cq.Workplane("front").circle(circle_radius) \ .extrude(thickness) # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex005_Extruded_Lines_and_Arcs.py b/Examples/Ex005_Extruded_Lines_and_Arcs.py index cc67cbf..62b51a4 100644 --- a/Examples/Ex005_Extruded_Lines_and_Arcs.py +++ b/Examples/Ex005_Extruded_Lines_and_Arcs.py @@ -29,4 +29,4 @@ result = cq.Workplane("front").lineTo(width, 0) \ .close().extrude(thickness) # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex006_Moving_the_Current_Working_Point.py b/Examples/Ex006_Moving_the_Current_Working_Point.py index 166fe9f..3c26121 100644 --- a/Examples/Ex006_Moving_the_Current_Working_Point.py +++ b/Examples/Ex006_Moving_the_Current_Working_Point.py @@ -32,4 +32,4 @@ result = result.center(-1.5, 1.5).circle(0.25) result = result.extrude(thickness) # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex007_Using_Point_Lists.py b/Examples/Ex007_Using_Point_Lists.py index 7a1bb84..d824c75 100644 --- a/Examples/Ex007_Using_Point_Lists.py +++ b/Examples/Ex007_Using_Point_Lists.py @@ -29,4 +29,4 @@ r = r.circle(hole_pattern_radius) result = r.extrude(thickness) # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex008_Polygon_Creation.py b/Examples/Ex008_Polygon_Creation.py index c9d37c9..2fdecfc 100644 --- a/Examples/Ex008_Polygon_Creation.py +++ b/Examples/Ex008_Polygon_Creation.py @@ -36,4 +36,4 @@ result = cq.Workplane("front").box(width, height, thickness) \ .cutThruAll() # Displays the result of this script -build_object(result) +show_object(result) diff --git a/Examples/Ex009_Polylines.py b/Examples/Ex009_Polylines.py index 2de65be..fc164c6 100644 --- a/Examples/Ex009_Polylines.py +++ b/Examples/Ex009_Polylines.py @@ -1,11 +1,10 @@ -# This example is meant to be used from within the CadQuery module of FreeCAD. -import cadquery -from Helpers import show +import cadquery as cq -# Set up our Length, Height, Width, and thickness of the beam +# These can be modified rather than hardcoding values for each dimension. +# Define up our Length, Height, Width, and thickness of the beam (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 points that the polyline will be drawn to/thru pts = [ (0, H/2.0), (W/2.0, H/2.0), @@ -18,8 +17,24 @@ pts = [ ] # 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) +# I-beam. +# 1. Establishes a workplane that an object can be built on. +# 1a. Uses the named plane orientation "front" to define the workplane, meaning +# that the positive Z direction is "up", and the negative Z direction +# is "down". +# 2. moveTo() is used to move the first point from the origin (0, 0) to +# (0, 10.0), with 10.0 being half the height (H/2.0). If this is not done +# the first line will start from the origin, creating an extra segment that +# will cause the extrude to have an invalid shape. +# 3. The polyline function takes a list of points and generates the lines +# through all the points at once. +# 3. Only half of the I-beam profile has been drawn so far. That half is +# mirrored around the Y-axis to create the complete I-beam profile. +# 4. The I-beam profile is extruded to the final length of the beam. +result = cq.Workplane("front").moveTo(0, H/2.0) \ + .polyline(pts) \ + .mirrorY() \ + .extrude(L) -# Render the solid -show(result) +# Displays the result of this script +show_object(result) diff --git a/Examples/Ex010_Defining_an_Edge_with_a_Spline.py b/Examples/Ex010_Defining_an_Edge_with_a_Spline.py index ad985c5..8b4c67c 100644 --- a/Examples/Ex010_Defining_an_Edge_with_a_Spline.py +++ b/Examples/Ex010_Defining_an_Edge_with_a_Spline.py @@ -1,9 +1,9 @@ -# This example is meant to be used from within the CadQuery module of FreeCAD. -import cadquery -from Helpers import show +import cadquery as cq -# The workplane we want to create the spline on to extrude -s = cadquery.Workplane("XY") +# 1. Establishes a workplane to create the spline on to extrude. +# 1a. Uses the X and Y origins to define the workplane, meaning that the +# positive Z direction is "up", and the negative Z direction is "down". +s = cq.Workplane("XY") # The points that the spline will pass through sPnts = [ @@ -16,11 +16,12 @@ sPnts = [ (0, 1.0) ] -# Generate our plate with the spline feature and make sure it's a closed entity +# 2. Generate our plate with the spline feature and make sure it is 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 +# 3. Extrude to turn the wire into a plate result = r.extrude(0.5) -# Render the solid -show(result) +# Displays the result of this script +show_object(result) diff --git a/Gui/Command.py b/Gui/Command.py index f679ced..002742f 100644 --- a/Gui/Command.py +++ b/Gui/Command.py @@ -132,7 +132,7 @@ class CadQueryExecuteScript: scriptText = cqCodePane.toPlainText().encode('utf-8') # Check to see if we are executig a CQGI compliant script - if ("build_object(" in scriptText and "# build_object(" not in scriptText and "#build_boject(" not in scriptText) or ("debug(" in scriptText and "# debug(" not in scriptText and "#debug(" not in scriptText): + if ("show_object(" in scriptText and "# show_object(" not in scriptText and "#show_boject(" not in scriptText) or ("debug(" in scriptText and "# debug(" not in scriptText and "#debug(" not in scriptText): FreeCAD.Console.PrintMessage("Executing CQGI-compliant script.\r\n") # A repreentation of the CQ script with all the metadata attached @@ -417,8 +417,8 @@ class CadQueryValidateScript: scriptText = cqCodePane.toPlainText().encode('utf-8') - if "build_object(" not in scriptText or "# build_object(" in scriptText or "#build_boject(" in scriptText: - FreeCAD.Console.PrintError("Script did not call build_object, no output available. Script must be CQGI compliant to get build output, variable editing and validation.\r\n") + if ("show_object(" not in scriptText and "# show_object(" in scriptText and "#show_boject(" in scriptText) or ("debug(" not in scriptText and "# debug(" in scriptText and "#debug(" in scriptText): + FreeCAD.Console.PrintError("Script did not call show_object or debug, no output available. Script must be CQGI compliant to get build output, variable editing and validation.\r\n") return # A repreentation of the CQ script with all the metadata attached diff --git a/Libs/cadquery b/Libs/cadquery index 0c40258..654f04c 160000 --- a/Libs/cadquery +++ b/Libs/cadquery @@ -1 +1 @@ -Subproject commit 0c40258e28c0fad08b699430bce34ea2613d8d1e +Subproject commit 654f04c2e7e21fb1ebefcca519da86bcb342ee83