Is there any way to convert a BSPline to a sketch?
It will be also good to know it in python if possible.
BSPline to Sketch
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: BSPline to Sketch
Internally the Draft Draft2Sketch tool uses two methods to convert to Sketch, or to Draft.
Code: Select all
import Draft
Draft.makeSketch(objectslist, autoconstraints=False, addTo=None, delete=False, name="Sketch", radiusPrecision=-1)
Draft.draftify(objectslist, makeblock=False, delete=True)
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: BSPline to Sketch
I am using a macro to generate a BSpline. But I was not able to generate a sketch with that @openBrain
@vocx thanks I will give it a try.
@vocx thanks I will give it a try.
Re: BSPline to Sketch
The macro I am modifying is using these wirePoints to make a BSPline
Making a BSpline with this.
I would like to convert this BSPline to a sketch so I can use/modify it with Part Design Workbench.
With the GUI it was not possible and using this didn't work.
All of this effort is because I have failed using BSplines manually directly in Sketch, I can't make the shape I want, I cant lock its features so I can move it freely on the plane.
The report view has this output
Edit: Adding extra info from here.
I am using the macro given here https://forum.freecadweb.org/viewtopic.php?f=3&t=37604 as a starting point.
Code: Select all
wirePoints.append(FreeCAD.Base.Vector(x,y,0))
Code: Select all
Draft.makeBSpline(wirePoints)
With the GUI it was not possible and using this didn't work.
All of this effort is because I have failed using BSplines manually directly in Sketch, I can't make the shape I want, I cant lock its features so I can move it freely on the plane.
Code: Select all
Draft.makeSketch(wirePoints, autoconstraints=False, addTo=None, delete=False, name="Sketch", radiusPrecision=-1)
Code: Select all
Traceback (most recent call last):
File "/home/lheck/.FreeCAD/Macro/squircle.FCMacro", line 35, in <module>
Draft.makeSketch(wirePoints, autoconstraints=False, addTo=None, delete=False, name="Sketch", radiusPrecision=-1)
File "/usr/share/freecad/Mod/Draft/Draft.py", line 2205, in makeSketch
elif not obj.isDerivedFrom("Part::Feature"):
<class 'AttributeError'>: 'Base.Vector' object has no attribute 'isDerivedFrom'
I am using the macro given here https://forum.freecadweb.org/viewtopic.php?f=3&t=37604 as a starting point.
Re: BSPline to Sketch
It seems that wirePoints is a list of points. You do not pass this to makeSketch(). First, create your BSpline object, and then pass it to makeSketch() to turn it into a Sketch.leoheck wrote: ↑Thu Aug 22, 2019 1:35 pmCode: Select all
Draft.makeSketch(wirePoints, autoconstraints=False, addTo=None, delete=False, name="Sketch", radiusPrecision=-1)
Code: Select all
wirePoints = [FreeCAD.Vector(1,2,0), FreeCAD.Vector(4,5,0), ...]
object = Draft.makeBSpline(wirePoints)
new = Draft.makeSketch(object, autoconstraints=True)
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.