| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Provides functions to create Arc objects by using 3 points.""" |
| | |
| | |
| | |
| |
|
| | |
| | |
| | import math |
| |
|
| | import FreeCAD as App |
| | import Part |
| | from draftmake import make_circle |
| | from draftutils import utils |
| | from draftutils.messages import _err |
| | from draftutils.translate import translate |
| |
|
| |
|
| | def make_arc_3points(points, placement=None, face=False, support=None, primitive=False): |
| | """Draw a circular arc defined by three points on the circumference. |
| | |
| | Parameters |
| | ---------- |
| | points: list of Base::Vector3 |
| | A list that must be three points. |
| | |
| | placement: Base::Placement, optional |
| | It is adjusted to match the geometry of the created edge. |
| | The Z axis of the adjusted placement will be parallel to the |
| | (negative) edge axis. Its Base will match the edge center. |
| | |
| | face: bool, optional |
| | It defaults to `False`. |
| | If it is `True` it will create a face in the closed arc. |
| | Otherwise only the circumference edge will be shown. |
| | |
| | support: App::PropertyLinkSubList, optional |
| | It defaults to `None`. |
| | It is a list containing tuples to define the attachment |
| | of the new object. |
| | |
| | This parameter sets the `Support` property but it only really |
| | affects the position of the new object if its `MapMode` is |
| | set to other than `'Deactivated'`. |
| | |
| | primitive: bool, optional |
| | It defaults to `False`. If it is `True`, it will create a Part |
| | primitive instead of a Draft object. |
| | In this case, `placement`, `face` and `support` are ignored. |
| | |
| | Returns |
| | ------- |
| | Part::Part2DObject or Part::Feature |
| | The new arc object. |
| | Normally it returns a parametric Draft object (`Part::Part2DObject`). |
| | If `primitive` is `True`, it returns a basic `Part::Feature`. |
| | |
| | None |
| | Returns `None` if there is a problem and the object cannot be created. |
| | """ |
| | _name = "make_arc_3points" |
| |
|
| | try: |
| | utils.type_check([(points, (list, tuple))], name=_name) |
| | except TypeError: |
| | _err(translate("draft", "Points:") + " {}".format(points)) |
| | _err(translate("draft", "Wrong input: must be a list or tuple of 3 points exactly.")) |
| | return None |
| |
|
| | if len(points) != 3: |
| | _err(translate("draft", "Points:") + " {}".format(points)) |
| | _err(translate("draft", "Wrong input: must be list or tuple of 3 points exactly.")) |
| | return None |
| |
|
| | p1, p2, p3 = points |
| |
|
| | try: |
| | utils.type_check([(p1, App.Vector), (p2, App.Vector), (p3, App.Vector)], name=_name) |
| | except TypeError: |
| | _err(translate("draft", "Wrong input: incorrect type of points.")) |
| | return None |
| |
|
| | if placement is not None: |
| | try: |
| | utils.type_check([(placement, App.Placement)], name=_name) |
| | except TypeError: |
| | _err(translate("draft", "Placement:") + " {}".format(placement)) |
| | _err(translate("draft", "Wrong input: incorrect type of placement.")) |
| | return None |
| |
|
| | try: |
| | edge = Part.Arc(p1, p2, p3).toShape() |
| | except Part.OCCError as error: |
| | _err(translate("draft", "Cannot generate shape:") + " " + "{}".format(error)) |
| | return None |
| |
|
| | if primitive: |
| | obj = App.ActiveDocument.addObject("Part::Feature", "Arc") |
| | obj.Shape = edge |
| | return obj |
| |
|
| | return make_circle.make_circle(edge, placement=placement, face=face, support=support) |
| |
|
| |
|
| | |
| |
|