| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Provides functions to create BSpline objects.""" |
| | |
| | |
| | |
| |
|
| | |
| | |
| | import FreeCAD as App |
| | import draftutils.utils as utils |
| | import draftutils.gui_utils as gui_utils |
| |
|
| | from draftutils.translate import translate |
| | from draftobjects.bspline import BSpline |
| |
|
| | if App.GuiUp: |
| | from draftviewproviders.view_bspline import ViewProviderBSpline |
| |
|
| |
|
| | def make_bspline(pointslist, closed=False, placement=None, face=None, support=None): |
| | """make_bspline(pointslist, [closed], [placement]) |
| | |
| | Creates a B-Spline object from the given list of vectors. |
| | |
| | Parameters |
| | ---------- |
| | pointlist : [Base.Vector] |
| | List of points to create the polyline. |
| | Instead of a pointslist, you can also pass a Part Wire. |
| | TODO: Change the name so! |
| | |
| | closed : bool |
| | If closed is True or first and last points are identical, |
| | the created BSpline will be closed. |
| | |
| | placement : Base.Placement |
| | If a placement is given, it is used. |
| | |
| | face : Bool |
| | If face is False, the rectangle is shown as a wireframe, |
| | otherwise as a face. |
| | |
| | support : |
| | TODO: Describe |
| | """ |
| | if not App.ActiveDocument: |
| | App.Console.PrintError("No active document. Aborting\n") |
| | return |
| | if not isinstance(pointslist, list): |
| | nlist = [] |
| | for v in pointslist.Vertexes: |
| | nlist.append(v.Point) |
| | pointslist = nlist |
| | if len(pointslist) < 2: |
| | _err = "Draft.make_bspline: not enough points" |
| | App.Console.PrintError(translate("draft", _err) + "\n") |
| | return |
| | if pointslist[0] == pointslist[-1]: |
| | if len(pointslist) > 2: |
| | closed = True |
| | pointslist.pop() |
| | _err = "Draft.make_bspline: Equal endpoints forced closed" |
| | App.Console.PrintWarning(translate("Draft", _err) + _err + "\n") |
| | else: |
| | |
| | _err = "Draft.make_bspline: Invalid pointslist" |
| | App.Console.PrintError(translate("Draft", _err) + "\n") |
| | return |
| | |
| | if placement: |
| | utils.type_check([(placement, App.Placement)], "make_bspline") |
| | if len(pointslist) == 2: |
| | fname = "Line" |
| | else: |
| | fname = "BSpline" |
| | obj = App.ActiveDocument.addObject("Part::FeaturePython", fname) |
| | obj.addExtension("Part::AttachExtensionPython") |
| | BSpline(obj) |
| | obj.Closed = closed |
| | obj.Points = pointslist |
| | obj.AttachmentSupport = support |
| | if face is not None: |
| | obj.MakeFace = face |
| | if placement: |
| | obj.Placement = placement |
| | if App.GuiUp: |
| | ViewProviderBSpline(obj.ViewObject) |
| | gui_utils.format_object(obj) |
| | gui_utils.select(obj) |
| |
|
| | return obj |
| |
|
| |
|
| | makeBSpline = make_bspline |
| |
|
| | |
| |
|