Skip to content

Constraints docs [WIP] #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 30, 2020
2 changes: 1 addition & 1 deletion cadquery/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _query(self, q: str) -> Tuple[str, Optional[Shape]]:
obj = self.objects[name].obj

if isinstance(obj, Workplane) and query.tag:
tmp = obj.ctx.tags[query.tag]
tmp = obj._getTagged(query.tag)
elif isinstance(obj, (Workplane, Shape)):
tmp = Workplane().add(obj)
else:
Expand Down
18 changes: 12 additions & 6 deletions cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,10 @@ def last(self) -> "Workplane":
"""
return self.newObject([self.objects[-1]])

def end(self) -> "Workplane":
def end(self, n: int = 1) -> "Workplane":
"""
Return the parent of this CQ element
Return the nth parent of this CQ element
:param n: number of ancestor to return (default: 1)
:rtype: a CQ object
:raises: ValueError if there are no more parents in the chain.

Expand All @@ -650,10 +651,15 @@ def end(self) -> "Workplane":

CQ(obj).faces("+Z")
"""
if self.parent:
return self.parent
else:
raise ValueError("Cannot End the chain-- no parents!")

rv = self
for _ in range(n):
if rv.parent:
rv = rv.parent
else:
raise ValueError("Cannot End the chain-- no parents!")

return rv

def _findType(self, types, searchStack=True, searchParents=True):

Expand Down
Binary file added doc/_static/door_assy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/door_assy_freecad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions doc/apireference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ All 2-d operations require a **Workplane** object to be created.
Workplane.sagittaArc
Workplane.radiusArc
Workplane.tangentArcPoint
Workplane.rotateAndCopy
Workplane.mirrorY
Workplane.mirrorX
Workplane.wire
Expand Down Expand Up @@ -166,8 +165,7 @@ Selectors
Objects that filter and select CAD objects. Selectors are used to select existing geometry
as a basis for futher operations.

.. currentmodule:: cadquery

.. currentmodule:: cadquery.selectors
.. autosummary::

NearestToPointSelector
Expand All @@ -186,19 +184,21 @@ as a basis for futher operations.
SubtractSelector
InverseSelector
StringSyntaxSelector

.. _assembly:

Assemblies
----------

Workplane and Shape objects can be connected together into assemblies

.. currentmodule:: cadquery

.. autosummary::

Assembly
Assembly.add
Assembly.save
Assembly.constrain
Assembly.solve
Constraint
Color
Loading