Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Changed the name of build_object() to show_object().
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwright committed Sep 15, 2017
1 parent 0c40258 commit 6901340
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions cadquery/cqgi.py
Expand Up @@ -101,7 +101,7 @@ def build(self, build_parameters=None, build_options=None):
self.set_param_values(build_parameters)
collector = ScriptCallback()
env = EnvironmentBuilder().with_real_builtins().with_cadquery_objects() \
.add_entry("build_object", collector.build_object) \
.add_entry("show_object", collector.show_object) \
.add_entry("debug", collector.debug) \
.add_entry("describe_parameter",collector.describe_parameter) \
.build()
Expand Down Expand Up @@ -286,14 +286,14 @@ def __str__(self):
class ScriptCallback(object):
"""
Allows a script to communicate with the container
the build_object() method is exposed to CQ scripts, to allow them
the show_object() method is exposed to CQ scripts, to allow them
to return objects to the execution environment
"""
def __init__(self):
self.outputObjects = []
self.debugObjects = []

def build_object(self, shape,options={}):
def show_object(self, shape,options={}):
"""
return an object to the executing environment, with options
:param shape: a cadquery object
Expand Down Expand Up @@ -340,7 +340,7 @@ class InvalidParameterError(Exception):

class NoOutputError(Exception):
"""
Raised when the script does not execute the build_object() method to
Raised when the script does not execute the show_object() method to
return a solid
"""
pass
Expand Down
12 changes: 6 additions & 6 deletions doc/cqgi.rst
Expand Up @@ -31,13 +31,13 @@ The Script Side
CQGI compliant containers provide an execution environment for scripts. The environment includes:

* the cadquery library is automatically imported as 'cq'.
* the :py:meth:`cadquery.cqgi.ScriptCallback.build_object()` method is defined that should be used to export a shape to the execution environment
* the :py:meth:`cadquery.cqgi.ScriptCallback.show_object()` method is defined that should be used to export a shape to the execution environment
* the :py:meth:`cadquery.cqgi.ScriptCallBack.debug()` method is defined, which can be used by scripts to debug model output during execution.

Scripts must call build_output at least once. Invoking build_object more than once will send multiple objects to
the container. An error will occur if the script does not return an object using the build_object() method.
Scripts must call build_output at least once. Invoking show_object more than once will send multiple objects to
the container. An error will occur if the script does not return an object using the show_object() method.

An optional options dictionary can be provided to the build_object method. If provided, it is passed onto the executing environment, and is used to render the object. Typically, this will be colors, transparency, and other visual affects.
An optional options dictionary can be provided to the show_object method. If provided, it is passed onto the executing environment, and is used to render the object. Typically, this will be colors, transparency, and other visual affects.


This CQGI compliant script produces a cube with a circle on top, and displays a workplane as well as an intermediate circle as debug output::
Expand All @@ -50,7 +50,7 @@ This CQGI compliant script produces a cube with a circle on top, and displays a
circle=top_of_cube_plane.circle(0.5)
debug(circle, { 'color': 'red' } )

build_object( circle.extrude(1.0),{"color": "#aaaaaa" )
show_object( circle.extrude(1.0),{"color": "#aaaaaa" )

Note that importing cadquery is not required.
At the end of this script, one object will be displayed, in addition to a workplane, a point, and a circle
Expand Down Expand Up @@ -157,7 +157,7 @@ These are the most important Methods and classes of the CQGI
parse
CQModel.build
BuildResult
ScriptCallback.build_object
ScriptCallback.show_object

Complete CQGI api
-----------------
Expand Down
54 changes: 27 additions & 27 deletions doc/examples.rst
Expand Up @@ -43,7 +43,7 @@ Just about the simplest possible example, a rectangular box
.. cq_plot::

result = cadquery.Workplane("front").box(2.0, 2.0, 0.5)
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -74,7 +74,7 @@ of a working plane is at the center of the face. The default hole depth is thro
result = cq.Workplane("XY").box(length, height, thickness) \
.faces(">Z").workplane().hole(center_hole_dia)

build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -97,7 +97,7 @@ By default, rectangles and circles are centered around the previous working poin
.. cq_plot::

result = cq.Workplane("front").circle(2.0).rect(0.5, 0.75).extrude(0.5)
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -123,7 +123,7 @@ closed curve.

result = cq.Workplane("front").lineTo(2.0, 0).lineTo(2.0, 1.0).threePointArc((1.0, 1.5),(0.0, 1.0))\
.close().extrude(0.25)
build_object(result)
show_object(result)


.. topic:: Api References
Expand Down Expand Up @@ -155,7 +155,7 @@ A new work plane center can be established at any point.
#the new center is specified relative to the previous center, not global coordinates!

result = result.extrude(0.25)
build_object(result)
show_object(result)


.. topic:: Api References
Expand Down Expand Up @@ -184,7 +184,7 @@ like :py:meth:`Workplane.circle` and :py:meth:`Workplane.rect`, will operate on
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( 0.25 ) # circle will operate on all four points
result = r.extrude(0.125 ) # make prism
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -206,7 +206,7 @@ correct for small hole sizes.

result = cq.Workplane("front").box(3.0, 4.0, 0.25).pushPoints ( [ ( 0,0.75 ),(0, -0.75) ]) \
.polygon(6, 1.0).cutThruAll()
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -238,7 +238,7 @@ This example uses a polyline to create one half of an i-beam shape, which is mir
(0,H/-2.0)
]
result = cq.Workplane("front").polyline(pts).mirrorY().extrude(L)
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -272,7 +272,7 @@ needs a complex profile
]
r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(sPnts).close()
result = r.extrude(0.5)
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -297,7 +297,7 @@ introduce horizontal and vertical lines, which make for slightly easier coding.
r = cq.Workplane("front").hLine(1.0) # 1.0 is the distance, not coordinate
r = r.vLine(0.5).hLine(-0.25).vLine(-0.25).hLineTo(0.0) # hLineTo allows using xCoordinate not distance
result =r.mirrorY().extrude(0.25 ) # mirror the geometry and extrude
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -356,7 +356,7 @@ Mirroring 3D Objects

result = result.union(mirXY_neg).union(mirXY_pos).union(mirZY_neg).union(mirZY_pos)

build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -391,7 +391,7 @@ Keep in mind that the origin of new workplanes are located at the center of a fa

result = cq.Workplane("front").box(2,3, 0.5) #make a basic prism
result = result.faces(">Z").workplane().hole(0.5) #find the top-most face and make a hole
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -420,7 +420,7 @@ how deep the part is
result = cq.Workplane("front").box(3,2, 0.5) #make a basic prism
result = result.faces(">Z").vertices("<XY").workplane() #select the lower left vertex and make a workplane
result = result.circle(1.0).cutThruAll() #cut the corner out
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -448,7 +448,7 @@ This example uses an offset workplane to make a compound object, which is perfec
result = cq.Workplane("front").box(3, 2, 0.5) #make a basic prism
result = result.faces("<X").workplane(offset=0.75) #workplane is offset from the object surface
result = result.circle(1.0).extrude(0.5) #disc
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -470,7 +470,7 @@ You can create a rotated work plane by specifying angles of rotation relative to
result = cq.Workplane("front").box(4.0, 4.0, 0.25).faces(">Z").workplane() \
.transformed(offset=cq.Vector(0, -1.5, 1.0),rotate=cq.Vector(60, 0, 0)) \
.rect(1.5,1.5,forConstruction=True).vertices().hole(0.25)
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -494,7 +494,7 @@ In the example below, a rectangle is drawn, and its vertices are used to locate

result = cq.Workplane("front").box(2, 2, 0.5).faces(">Z").workplane() \
.rect(1.5, 1.5, forConstruction=True).vertices().hole(0.125 )
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -518,7 +518,7 @@ are removed, and then the inside of the solid is 'hollowed out' to make the shel
.. cq_plot::

result = cq.Workplane("front").box(2, 2, 2).faces("+Z").shell(0.05)
build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -541,7 +541,7 @@ and a circular section.
result = cq.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)

build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -566,7 +566,7 @@ Similar to :py:meth:`Workplane.hole` , these functions operate on a list of poin
result = cq.Workplane(cq.Plane.XY()).box(4,2, 0.5).faces(">Z").workplane().rect(3.5, 1.5, forConstruction=True)\
.vertices().cboreHole(0.125, 0.25, 0.125, depth=None)

build_object(result)
show_object(result)

.. topic:: Api References

Expand All @@ -592,7 +592,7 @@ Here we fillet all of the edges of a simple plate.
.. cq_plot::

result = cq.Workplane("XY" ).box(3, 3, 0.5).edges("|Z").fillet(0.125)
build_object(result)
show_object(result)
.. topic:: Api References

Expand All @@ -619,7 +619,7 @@ with just a few lines of code.
.rect(length-padding,height-padding,forConstruction=True) \
.vertices().cboreHole(2.4, 4.4, 2.1)

build_object(result)
show_object(result)


Splitting an Object
Expand All @@ -633,7 +633,7 @@ You can split an object using a workplane, and retain either or both halves

#now cut it in half sideways
result = c.faces(">Y").workplane(-0.5).split(keepTop=True)
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -675,7 +675,7 @@ ones at 13 lines, but that's very short compared to the pythonOCC version, which

#make a shell
result = p.faces(">Z").shell(0.3)
build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -774,7 +774,7 @@ A Parametric Enclosure
#return the combined result
result =topOfLid.combineSolids(bottom)

build_object(result)
show_object(result)

.. topic:: Api References

Expand Down Expand Up @@ -859,7 +859,7 @@ regarding the underside of the brick.
tmp = s

# Render the solid
build_object(tmp)
show_object(tmp)


Braille Example
Expand Down Expand Up @@ -1043,7 +1043,7 @@ Braille Example
if base_thickness < get_cylinder_radius(_cell_geometry):
raise ValueError('Base thickness should be at least {}'.format(dot_height))

build_object(make_embossed_plate(text_lines, _cell_geometry))
show_object(make_embossed_plate(text_lines, _cell_geometry))

Panel With Various Connector Holes
-----------------------------------
Expand Down Expand Up @@ -1093,4 +1093,4 @@ Panel With Various Connector Holes
result = result.workplane(offset=1, centerOption='CenterOfBoundBox').center(-173,-30-idx*h_sep).moveTo(-2.9176,-5.3).threePointArc((-6.05,0),(-2.9176,5.3)).lineTo(2.9176,5.3).threePointArc((6.05,0),(2.9176,-5.3)).close().cutThruAll()

# Render the solid
build_object(result)
show_object(result)
2 changes: 1 addition & 1 deletion doc/extending.rst
Expand Up @@ -176,5 +176,5 @@ This ultra simple plugin makes cubes of the specified size for each stack point.
result = cq.Workplane("XY").box(6.0,8.0,0.5).faces(">Z")\
.rect(4.0,4.0,forConstruction=True).vertices() \
.makeCubes(1.0).combineSolids()
build_object(result)
show_object(result)

2 changes: 1 addition & 1 deletion doc/fileformat.rst
Expand Up @@ -12,7 +12,7 @@ like `The CadQuery Freecad Module <https://github.com/jmwright/cadquery-freecad-
`parametricParts.com <https://www.parametricparts.com>`_, there are a few conventions you need to be aware of:

* cadquery is already imported as 'cq'
* to return an object to the container, you need to call the build_object() method.
* to return an object to the container, you need to call the show_object() method.

Each script generally has three sections:

Expand Down
8 changes: 4 additions & 4 deletions doc/quickstart.rst
Expand Up @@ -62,7 +62,7 @@ with place-holders for the dimensions. Paste this into the CodeWindow:
result = cq.Workplane("XY").box(height, width, thickness)
# Render the solid
build_object(result)
show_object(result)
Press F2 to run the script. You should see Our basic base.

Expand Down Expand Up @@ -91,7 +91,7 @@ This modification will do the trick:
.faces(">Z").workplane().hole(diameter)
# Render the solid
build_object(result)
show_object(result)
Rebuild your model by pressing F2. Your block should look like this:

Expand Down Expand Up @@ -149,7 +149,7 @@ Good news!-- we can get the job done with just two lines of code. Here's the cod
.cboreHole(2.4, 4.4, 2.1)
# Render the solid
build_object(result)
show_object(result)
After pressing F2 to re-execute the model, you should see something like this:
Expand Down Expand Up @@ -215,7 +215,7 @@ We can do that using the preset dictionaries in the parameter definition:
.edges("|Z").fillet(2.0)
# Render the solid
build_object(result)
show_object(result)
**Line 13** fillets the edges using the :py:meth:`cadquery.CQ.fillet` method.

Expand Down
6 changes: 3 additions & 3 deletions doc/selectors.rst
Expand Up @@ -36,7 +36,7 @@ Selectors can be combined logically, currently defined operators include **and**
.edges("|Z and >Y") \
.chamfer(0.2)
build_object(result)
show_object(result)

Much more complex expressions are possible as well:

Expand All @@ -49,7 +49,7 @@ Much more complex expressions are possible as well:
.edges("not(<X or >X or <Y or >Y)") \
.chamfer(0.1)

build_object(result)
show_object(result)

.. _filteringfaces:

Expand Down Expand Up @@ -137,4 +137,4 @@ It is possible to use user defined vectors as a basis for the selectors. For exa
# chamfer only one edge
result = result.edges('>(-1,1,0)').chamfer(1)

build_object(result)
show_object(result)

0 comments on commit 6901340

Please sign in to comment.