2019-05-28 12:00:15 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-09-10 07:34:13 +00:00
|
|
|
from typing import Tuple, List, Sequence, Counter, ClassVar
|
2019-05-28 12:00:15 +00:00
|
|
|
|
|
|
|
def quaternion_u(
|
|
|
|
qw: float,
|
|
|
|
qx: float,
|
|
|
|
qy: float,
|
|
|
|
qz: float
|
|
|
|
) -> Tuple[float, float, float]:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Input quaternion, return unit vector of U axis.
|
|
|
|
|
|
|
|
Where `qw`, `qx`, `qy`, `qz` are corresponded to the W, X, Y, Z value of quaternion.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def quaternion_v(
|
|
|
|
qw: float,
|
|
|
|
qx: float,
|
|
|
|
qy: float,
|
|
|
|
qz: float
|
|
|
|
) -> Tuple[float, float, float]:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Input quaternion, return unit vector of V axis.
|
|
|
|
|
|
|
|
Signature is same as [quaternion_u](#quaternion_u).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def quaternion_n(
|
|
|
|
qw: float,
|
|
|
|
qx: float,
|
|
|
|
qy: float,
|
|
|
|
qz: float
|
|
|
|
) -> Tuple[float, float, float]:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Input quaternion, return unit vector of normal.
|
|
|
|
|
|
|
|
Signature is same as [quaternion_u](#quaternion_u).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def make_quaternion(
|
|
|
|
ux: float,
|
|
|
|
uy: float,
|
|
|
|
uz: float,
|
|
|
|
vx: float,
|
|
|
|
vy: float,
|
|
|
|
vz: float
|
|
|
|
) -> Tuple[float, float, float, float]:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Input two unit vector, return quaternion.
|
2019-05-28 12:00:15 +00:00
|
|
|
|
2020-02-02 13:44:32 +00:00
|
|
|
Where `ux`, `uy`, `uz` are corresponded to the value of U vector;
|
|
|
|
`vx`, `vy`, `vz` are corresponded to the value of V vector.
|
|
|
|
"""
|
|
|
|
...
|
2019-05-28 12:00:15 +00:00
|
|
|
|
|
|
|
class Params:
|
|
|
|
|
2020-02-02 13:44:32 +00:00
|
|
|
"""The handles of parameters."""
|
|
|
|
|
2019-05-28 12:00:15 +00:00
|
|
|
def __repr__(self) -> str:
|
|
|
|
...
|
|
|
|
|
|
|
|
class Entity:
|
|
|
|
|
2020-02-02 13:44:32 +00:00
|
|
|
"""The handles of entities."""
|
|
|
|
|
2020-01-29 03:40:41 +00:00
|
|
|
FREE_IN_3D: ClassVar[Entity] = ...
|
|
|
|
NONE: ClassVar[Entity] = ...
|
2019-05-28 12:00:15 +00:00
|
|
|
params: Params
|
|
|
|
|
|
|
|
def is_3d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 3D entity."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_none(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a empty entity."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_point_2d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 2D point."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_point_3d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 3D point."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_point(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a point."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_normal_2d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 2D normal."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_normal_3d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 3D normal."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_normal(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a normal."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_distance(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a distance."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_work_plane(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a work plane."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_line_2d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 2D line."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_line_3d(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a 3D line."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_line(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a line."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_cubic(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a cubic."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_circle(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a circle."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def is_arc(self) -> bool:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return True if this is a arc."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
|
...
|
|
|
|
|
|
|
|
class SolverSystem:
|
|
|
|
|
2020-02-02 13:44:32 +00:00
|
|
|
"""A solver system of Python-Solvespace.
|
|
|
|
|
|
|
|
The operation of entities and constraints are using the methods of this class.
|
|
|
|
"""
|
|
|
|
|
2019-09-06 14:18:11 +00:00
|
|
|
def __init__(self) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Initialization method. Create a solver system."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def clear(self) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Clear the system."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def set_group(self, g: int) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Set the current group (`g`)."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def group(self) -> int:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return the current group."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
2019-09-06 14:18:11 +00:00
|
|
|
def set_params(self, p: Params, params: Sequence[float]) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Set the parameters from a [Params] handle (`p`) belong to this system.
|
|
|
|
The values is come from `params`, length must be equal to the handle.
|
|
|
|
"""
|
2019-07-11 12:40:33 +00:00
|
|
|
...
|
|
|
|
|
2019-05-28 12:00:15 +00:00
|
|
|
def params(self, p: Params) -> Tuple[float, ...]:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Get the parameters from a [Params] handle (`p`) belong to this system.
|
|
|
|
The length of tuple is decided by handle.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def dof(self) -> int:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return the degrees of freedom of current group.
|
|
|
|
Only can be called after solving.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def constraints(self) -> Counter[str]:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Return the number of each constraint type.
|
|
|
|
The name of constraints is represented by string.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
2020-02-02 13:44:32 +00:00
|
|
|
def failures(self) -> List[int]:
|
|
|
|
"""Return a list of failed constraint numbers."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
2019-10-15 08:13:16 +00:00
|
|
|
def solve(self) -> int:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Start the solving, return the result flag."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def create_2d_base(self) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Create a 2D system on current group,
|
|
|
|
return the handle of work plane.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_point_2d(self, u: float, v: float, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a 2D point to specific work plane (`wp`) then return the handle.
|
|
|
|
|
|
|
|
Where `u`, `v` are corresponded to the value of U, V axis on the work plane.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_point_3d(self, x: float, y: float, z: float) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a 3D point then return the handle.
|
|
|
|
|
|
|
|
Where `x`, `y`, `z` are corresponded to the value of X, Y, Z axis.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_normal_2d(self, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a 2D normal orthogonal to specific work plane (`wp`)
|
|
|
|
then return the handle.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_normal_3d(self, qw: float, qx: float, qy: float, qz: float) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a 3D normal from quaternion then return the handle.
|
|
|
|
|
|
|
|
Where `qw`, `qx`, `qy`, `qz` are corresponded to
|
|
|
|
the W, X, Y, Z value of quaternion.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_distance(self, d: float, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a distance to specific work plane (`wp`) then return the handle.
|
|
|
|
|
|
|
|
Where `d` is distance value.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_line_2d(self, p1: Entity, p2: Entity, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a 2D line to specific work plane (`wp`) then return the handle.
|
|
|
|
|
|
|
|
Where `p1` is the start point; `p2` is the end point.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_line_3d(self, p1: Entity, p2: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a 3D line then return the handle.
|
|
|
|
|
|
|
|
Where `p1` is the start point; `p2` is the end point.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_cubic(self, p1: Entity, p2: Entity, p3: Entity, p4: Entity, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a cubic curve to specific work plane (`wp`) then return the handle.
|
|
|
|
|
|
|
|
Where `p1` to `p4` is the control points.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_arc(self, nm: Entity, ct: Entity, start: Entity, end: Entity, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add an arc to specific work plane (`wp`) then return the handle.
|
|
|
|
|
|
|
|
Where `nm` is the orthogonal normal; `ct` is the center point;
|
|
|
|
`start` is the start point; `end` is the end point.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_circle(self, nm: Entity, ct: Entity, radius: Entity, wp: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add an circle to specific work plane (`wp`) then return the handle.
|
|
|
|
|
|
|
|
Where `nm` is the orthogonal normal;
|
|
|
|
`ct` is the center point;
|
|
|
|
`radius` is the distance value represent radius.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_work_plane(self, origin: Entity, nm: Entity) -> Entity:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a work plane then return the handle.
|
|
|
|
|
|
|
|
Where `origin` is the origin point of the plane;
|
|
|
|
`nm` is the orthogonal normal.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def add_constraint(
|
|
|
|
self,
|
2019-10-15 08:13:16 +00:00
|
|
|
c_type: int,
|
2019-05-28 12:00:15 +00:00
|
|
|
wp: Entity,
|
|
|
|
v: float,
|
|
|
|
p1: Entity,
|
|
|
|
p2: Entity,
|
|
|
|
e1: Entity,
|
|
|
|
e2: Entity,
|
|
|
|
e3: Entity = Entity.NONE,
|
|
|
|
e4: Entity = Entity.NONE,
|
|
|
|
other: int = 0,
|
|
|
|
other2: int = 0
|
|
|
|
) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Add a constraint by type code `c_type`.
|
|
|
|
This is an origin function mapping to different constraint methods.
|
|
|
|
|
|
|
|
Where `wp` represents work plane; `v` represents constraint value;
|
|
|
|
`p1` and `p2` represent point entities; `e1` to `e4` represent other types of entity;
|
|
|
|
`other` and `other2` are control options of the constraint.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def coincident(self, e1: Entity, e2: Entity, wp: Entity = Entity.FREE_IN_3D) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Coincident two entities.
|
|
|
|
|
|
|
|
| Entity 1 (`e1`) | Entity 2 (`e2`) | Work plane (`wp`) |
|
|
|
|
|:---------------:|:---------------:|:-----------------:|
|
|
|
|
| [is_point] | [is_point] | Optional |
|
|
|
|
| [is_point] | [is_work_plane] | [Entity.FREE_IN_3D] |
|
|
|
|
| [is_point] | [is_line] | Optional |
|
|
|
|
| [is_point] | [is_circle] | Optional |
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def distance(
|
|
|
|
self,
|
|
|
|
e1: Entity,
|
|
|
|
e2: Entity,
|
|
|
|
value: float,
|
|
|
|
wp: Entity = Entity.FREE_IN_3D
|
|
|
|
) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Distance constraint between two entities.
|
|
|
|
|
|
|
|
If `value` is equal to zero, then turn into [coincident](#solversystemcoincident)
|
|
|
|
|
|
|
|
| Entity 1 (`e1`) | Entity 2 (`e2`) | Work plane (`wp`) |
|
|
|
|
|:---------------:|:---------------:|:-----------------:|
|
|
|
|
| [is_point] | [is_point] | Optional |
|
|
|
|
| [is_point] | [is_work_plane] | [Entity.FREE_IN_3D] |
|
|
|
|
| [is_point] | [is_line] | Optional |
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def equal(self, e1: Entity, e2: Entity, wp: Entity = Entity.FREE_IN_3D) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Equal constraint between two entities.
|
|
|
|
|
|
|
|
| Entity 1 (`e1`) | Entity 2 (`e2`) | Work plane (`wp`) |
|
|
|
|
|:---------------:|:---------------:|:-----------------:|
|
|
|
|
| [is_line] | [is_line] | Optional |
|
|
|
|
| [is_line] | [is_arc] | Optional |
|
|
|
|
| [is_line] | [is_circle] | Optional |
|
|
|
|
| [is_arc] | [is_arc] | Optional |
|
|
|
|
| [is_arc] | [is_circle] | Optional |
|
|
|
|
| [is_circle] | [is_circle] | Optional |
|
|
|
|
| [is_circle] | [is_arc] | Optional |
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def equal_included_angle(
|
|
|
|
self,
|
|
|
|
e1: Entity,
|
|
|
|
e2: Entity,
|
|
|
|
e3: Entity,
|
|
|
|
e4: Entity,
|
|
|
|
wp: Entity
|
|
|
|
) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Constraint that 2D line 1 (`e1`) and line 2 (`e2`),
|
|
|
|
line 3 (`e3`) and line 4 (`e4`) must have same included angle on work plane `wp`.
|
2019-05-28 12:00:15 +00:00
|
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
|
|
def equal_point_to_line(
|
|
|
|
self,
|
|
|
|
e1: Entity,
|
|
|
|
e2: Entity,
|
|
|
|
e3: Entity,
|
|
|
|
e4: Entity,
|
|
|
|
wp: Entity
|
|
|
|
) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Constraint that point 1 (`e1`) and line 1 (`e2`),
|
|
|
|
point 2 (`e3`) and line 2 (`e4`) must have same distance on work plane `wp`.
|
2019-05-28 12:00:15 +00:00
|
|
|
"""
|
|
|
|
...
|
|
|
|
|
|
|
|
def ratio(self, e1: Entity, e2: Entity, value: float, wp: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""The ratio (`value`) constraint between two 2D lines (`e1` and `e2`)."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def symmetric(
|
|
|
|
self,
|
|
|
|
e1: Entity,
|
|
|
|
e2: Entity,
|
|
|
|
e3: Entity = Entity.NONE,
|
|
|
|
wp: Entity = Entity.FREE_IN_3D
|
|
|
|
) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Symmetric constraint between two points.
|
|
|
|
|
|
|
|
| Entity 1 (`e1`) | Entity 2 (`e2`) | Entity 3 (`e3`) | Work plane (`wp`) |
|
|
|
|
|:---------------:|:---------------:|:---------------:|:-----------------:|
|
|
|
|
| [is_point_3d] | [is_point_3d] | [is_work_plane] | [Entity.FREE_IN_3D] |
|
|
|
|
| [is_point_2d] | [is_point_2d] | [is_work_plane] | [Entity.FREE_IN_3D] |
|
|
|
|
| [is_point_2d] | [is_point_2d] | [is_line_2d] | Is not [Entity.FREE_IN_3D] |
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def symmetric_h(self, e1: Entity, e2: Entity, wp: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Symmetric constraint between two 2D points (`e1` and `e2`)
|
|
|
|
with horizontal line on the work plane (`wp` can not be [Entity.FREE_IN_3D]).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def symmetric_v(self, e1: Entity, e2: Entity, wp: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Symmetric constraint between two 2D points (`e1` and `e2`)
|
|
|
|
with vertical line on the work plane (`wp` can not be [Entity.FREE_IN_3D]).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def midpoint(
|
|
|
|
self,
|
|
|
|
e1: Entity,
|
|
|
|
e2: Entity,
|
|
|
|
wp: Entity = Entity.FREE_IN_3D
|
|
|
|
) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Midpoint constraint between a point (`e1`) and
|
|
|
|
a line (`e2`) on work plane (`wp`).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def horizontal(self, e1: Entity, wp: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Horizontal constraint of a 2d point (`e1`) on
|
|
|
|
work plane (`wp` can not be [Entity.FREE_IN_3D]).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def vertical(self, e1: Entity, wp: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Vertical constraint of a 2d point (`e1`) on
|
|
|
|
work plane (`wp` can not be [Entity.FREE_IN_3D]).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def diameter(self, e1: Entity, value: float, wp: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Diameter (`value`) constraint of a circular entities.
|
|
|
|
|
|
|
|
| Entity 1 (`e1`) | Work plane (`wp`) |
|
|
|
|
|:---------------:|:-----------------:|
|
|
|
|
| [is_arc] | Optional |
|
|
|
|
| [is_circle] | Optional |
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def same_orientation(self, e1: Entity, e2: Entity) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Equal orientation constraint between two 3d normals (`e1` and `e2`)."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def angle(self, e1: Entity, e2: Entity, value: float, wp: Entity, inverse: bool = False) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Degrees angle (`value`) constraint between two 2d lines (`e1` and `e2`)
|
|
|
|
on the work plane (`wp` can not be [Entity.FREE_IN_3D]).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def perpendicular(self, e1: Entity, e2: Entity, wp: Entity, inverse: bool = False) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Perpendicular constraint between two 2d lines (`e1` and `e2`)
|
|
|
|
on the work plane (`wp` can not be [Entity.FREE_IN_3D]) with `inverse` option.
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def parallel(self, e1: Entity, e2: Entity, wp: Entity = Entity.FREE_IN_3D) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Parallel constraint between two lines (`e1` and `e2`) on
|
|
|
|
the work plane (`wp`).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def tangent(self, e1: Entity, e2: Entity, wp: Entity = Entity.FREE_IN_3D) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Parallel constraint between two entities (`e1` and `e2`) on the work plane (`wp`).
|
|
|
|
|
|
|
|
| Entity 1 (`e1`) | Entity 2 (`e2`) | Work plane (`wp`) |
|
|
|
|
|:---------------:|:---------------:|:-----------------:|
|
|
|
|
| [is_arc] | [is_line_2d] | Is not [Entity.FREE_IN_3D] |
|
|
|
|
| [is_cubic] | [is_line_3d] | [Entity.FREE_IN_3D] |
|
|
|
|
| [is_arc] | [is_cubic] | Is not [Entity.FREE_IN_3D] |
|
|
|
|
| [is_arc] | [is_arc] | Is not [Entity.FREE_IN_3D] |
|
|
|
|
| [is_cubic] | [is_cubic] | Optional |
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def distance_proj(self, e1: Entity, e2: Entity, value: float) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Projected distance (`value`) constraint between
|
|
|
|
two 3d points (`e1` and `e2`).
|
|
|
|
"""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def dragged(self, e1: Entity, wp: Entity = Entity.FREE_IN_3D) -> None:
|
2020-02-02 13:44:32 +00:00
|
|
|
"""Dragged constraint of a point (`e1`) on the work plane (`wp`)."""
|
2019-05-28 12:00:15 +00:00
|
|
|
...
|