Changes for show_object and updates to examples.
This commit is contained in:
parent
a54a7a21a6
commit
fed83573f2
|
@ -16,4 +16,4 @@ result = cq.Workplane("XY").box(length, height, thickness)
|
||||||
# from Helpers import show
|
# from Helpers import show
|
||||||
# show(result) # Render the result of this script
|
# show(result) # Render the result of this script
|
||||||
|
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -17,4 +17,4 @@ result = cq.Workplane("XY").box(length, height, thickness) \
|
||||||
.faces(">Z").workplane().hole(center_hole_dia)
|
.faces(">Z").workplane().hole(center_hole_dia)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -31,4 +31,4 @@ result = cq.Workplane("XY").box(length, height, thickness) \
|
||||||
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
|
.vertices().cboreHole(cbore_hole_diameter, cbore_diameter, cbore_depth)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -26,4 +26,4 @@ result = cq.Workplane("front").circle(circle_radius) \
|
||||||
.extrude(thickness)
|
.extrude(thickness)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -29,4 +29,4 @@ result = cq.Workplane("front").lineTo(width, 0) \
|
||||||
.close().extrude(thickness)
|
.close().extrude(thickness)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -32,4 +32,4 @@ result = result.center(-1.5, 1.5).circle(0.25)
|
||||||
result = result.extrude(thickness)
|
result = result.extrude(thickness)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -29,4 +29,4 @@ r = r.circle(hole_pattern_radius)
|
||||||
result = r.extrude(thickness)
|
result = r.extrude(thickness)
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -36,4 +36,4 @@ result = cq.Workplane("front").box(width, height, thickness) \
|
||||||
.cutThruAll()
|
.cutThruAll()
|
||||||
|
|
||||||
# Displays the result of this script
|
# Displays the result of this script
|
||||||
build_object(result)
|
show_object(result)
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
# This example is meant to be used from within the CadQuery module of FreeCAD.
|
import cadquery as cq
|
||||||
import cadquery
|
|
||||||
from Helpers import show
|
|
||||||
|
|
||||||
# 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)
|
(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 = [
|
pts = [
|
||||||
(0, H/2.0),
|
(0, H/2.0),
|
||||||
(W/2.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
|
# We generate half of the I-beam outline and then mirror it to create the full
|
||||||
# I-beam
|
# I-beam.
|
||||||
result = cadquery.Workplane("front").polyline(pts).mirrorY().extrude(L)
|
# 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
|
# Displays the result of this script
|
||||||
show(result)
|
show_object(result)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# This example is meant to be used from within the CadQuery module of FreeCAD.
|
import cadquery as cq
|
||||||
import cadquery
|
|
||||||
from Helpers import show
|
|
||||||
|
|
||||||
# The workplane we want to create the spline on to extrude
|
# 1. Establishes a workplane to create the spline on to extrude.
|
||||||
s = cadquery.Workplane("XY")
|
# 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
|
# The points that the spline will pass through
|
||||||
sPnts = [
|
sPnts = [
|
||||||
|
@ -16,11 +16,12 @@ sPnts = [
|
||||||
(0, 1.0)
|
(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()
|
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)
|
result = r.extrude(0.5)
|
||||||
|
|
||||||
# Render the solid
|
# Displays the result of this script
|
||||||
show(result)
|
show_object(result)
|
||||||
|
|
|
@ -132,7 +132,7 @@ class CadQueryExecuteScript:
|
||||||
scriptText = cqCodePane.toPlainText().encode('utf-8')
|
scriptText = cqCodePane.toPlainText().encode('utf-8')
|
||||||
|
|
||||||
# Check to see if we are executig a CQGI compliant script
|
# 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")
|
FreeCAD.Console.PrintMessage("Executing CQGI-compliant script.\r\n")
|
||||||
|
|
||||||
# A repreentation of the CQ script with all the metadata attached
|
# A repreentation of the CQ script with all the metadata attached
|
||||||
|
@ -417,8 +417,8 @@ class CadQueryValidateScript:
|
||||||
|
|
||||||
scriptText = cqCodePane.toPlainText().encode('utf-8')
|
scriptText = cqCodePane.toPlainText().encode('utf-8')
|
||||||
|
|
||||||
if "build_object(" not in scriptText or "# build_object(" in scriptText or "#build_boject(" in scriptText:
|
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 build_object, no output available. Script must be CQGI compliant to get build output, variable editing and validation.\r\n")
|
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
|
return
|
||||||
|
|
||||||
# A repreentation of the CQ script with all the metadata attached
|
# A repreentation of the CQ script with all the metadata attached
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0c40258e28c0fad08b699430bce34ea2613d8d1e
|
Subproject commit 654f04c2e7e21fb1ebefcca519da86bcb342ee83
|
Loading…
Reference in New Issue
Block a user