| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Provides functions to produce a mirrored object. |
| | |
| | It just creates a `Part::Mirroring` object, and sets the appropriate |
| | `Source` and `Normal` properties. |
| | """ |
| | |
| | |
| | |
| |
|
| | |
| | |
| | import FreeCAD as App |
| | import WorkingPlane |
| |
|
| | from draftutils import gui_utils |
| | from draftutils import utils |
| | from draftutils.messages import _err |
| | from draftutils.translate import translate |
| |
|
| | if App.GuiUp: |
| | import FreeCADGui as Gui |
| |
|
| |
|
| | def mirror(objlist, p1, p2): |
| | """Create a mirror object from the provided list and line. |
| | |
| | It creates a `Part::Mirroring` object from the given `objlist` using |
| | a plane that is defined by the two given points `p1` and `p2`, |
| | and the Draft working plane normal. |
| | |
| | Parameters |
| | ---------- |
| | objlist: single object or a list of objects |
| | A single object or a list of objects. |
| | |
| | p1: Base::Vector3 |
| | Point 1 of the mirror plane. It is also used as the `Placement.Base` |
| | of the resulting object. |
| | |
| | p2: Base::Vector3 |
| | Point 2 of the mirror plane. |
| | |
| | Returns |
| | ------- |
| | None |
| | If the operation fails. |
| | |
| | list |
| | List of `Part::Mirroring` objects, or a single one |
| | depending on the input `objlist`. |
| | |
| | To Do |
| | ----- |
| | Implement a mirror tool specific to the workbench that does not |
| | just use `Part::Mirroring`. It should create a derived object, |
| | that is, it should work similar to `Draft.offset`. |
| | """ |
| |
|
| | if not objlist: |
| | _err(translate("draft", "No object given")) |
| | return |
| |
|
| | if p1 == p2: |
| | _err(translate("draft", "The two points are coincident")) |
| | return |
| |
|
| | if not isinstance(objlist, list): |
| | objlist = [objlist] |
| |
|
| | norm = WorkingPlane.get_working_plane(update=False).axis |
| | pnorm = p2.sub(p1).cross(norm).normalize() |
| |
|
| | result = [] |
| |
|
| | for obj in objlist: |
| | mir = App.ActiveDocument.addObject("Part::Mirroring", "Mirror") |
| | mir.Label = obj.Label + " (" + translate("draft", "mirrored") + ")" |
| | mir.Source = obj |
| | mir.Base = p1 |
| | mir.Normal = pnorm |
| | gui_utils.format_object(mir, obj) |
| | result.append(mir) |
| |
|
| | if len(result) == 1: |
| | result = result[0] |
| | gui_utils.select(result) |
| |
|
| | return result |
| |
|
| |
|
| | |
| |
|