Compare commits
No commits in common. "tool/solver" and "main" have entirely different histories.
tool/solve
...
main
|
@ -36,7 +36,7 @@ Test the environment with `python3 -c "import nhf"`
|
||||||
To visualize an object, create a file `visualize.py`, and run `cq-editor`:
|
To visualize an object, create a file `visualize.py`, and run `cq-editor`:
|
||||||
|
|
||||||
``` sh
|
``` sh
|
||||||
CQ-editor visualize.py
|
python3 -m cq_editor visualize.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### Folder Structure
|
### Folder Structure
|
||||||
|
|
|
@ -317,7 +317,7 @@ class TorsionJoint:
|
||||||
if not rider_slot_begin:
|
if not rider_slot_begin:
|
||||||
rider_slot_begin = self.rider_slot_begin
|
rider_slot_begin = self.rider_slot_begin
|
||||||
def slot(loc):
|
def slot(loc):
|
||||||
wire = Cq.Wire.makePolygon(self._slot_polygon(flip=False)).close()
|
wire = Cq.Wire.makePolygon(self._slot_polygon(flip=False))
|
||||||
face = Cq.Face.makeFromWires(wire)
|
face = Cq.Face.makeFromWires(wire)
|
||||||
return face.located(loc)
|
return face.located(loc)
|
||||||
wall_profile = (
|
wall_profile = (
|
||||||
|
|
24
nhf/utils.py
24
nhf/utils.py
|
@ -8,6 +8,30 @@ from cadquery.occ_impl.solver import ConstraintSpec
|
||||||
from nhf import Role
|
from nhf import Role
|
||||||
from nhf.materials import KEY_ITEM, KEY_MATERIAL
|
from nhf.materials import KEY_ITEM, KEY_MATERIAL
|
||||||
|
|
||||||
|
# Bug fixes
|
||||||
|
def _subloc(self, name: str) -> Tuple[Cq.Location, str]:
|
||||||
|
"""
|
||||||
|
Calculate relative location of an object in a subassembly.
|
||||||
|
|
||||||
|
Returns the relative positions as well as the name of the top assembly.
|
||||||
|
"""
|
||||||
|
|
||||||
|
rv = Cq.Location()
|
||||||
|
obj = self.objects[name]
|
||||||
|
name_out = name
|
||||||
|
|
||||||
|
if obj not in self.children and obj is not self:
|
||||||
|
locs = []
|
||||||
|
while not obj.parent is self:
|
||||||
|
locs.append(obj.loc)
|
||||||
|
obj = cast(Cq.Assembly, obj.parent)
|
||||||
|
name_out = obj.name
|
||||||
|
|
||||||
|
rv = functools.reduce(lambda l1, l2: l2 * l1, locs)
|
||||||
|
|
||||||
|
return (rv, name_out)
|
||||||
|
Cq.Assembly._subloc = _subloc
|
||||||
|
|
||||||
### Vector arithmetic
|
### Vector arithmetic
|
||||||
|
|
||||||
def location_sub(self: Cq.Location, rhs: Cq.Location) -> Cq.Vector:
|
def location_sub(self: Cq.Location, rhs: Cq.Location) -> Cq.Vector:
|
||||||
|
|
Loading…
Reference in New Issue