Hi bernd
I found this discussion on a script using makeFillet
mario
Part Fillet in python
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Part Fillet in python
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Part Fillet in python
Thats true for the GUI extrusion and works well. Could this option be set in python as well ? It would be the easiest soulution.jmaustpc wrote:But you don't need to make it a face, if you set the option to make solid "true" then Part Extrude will create a solid from the wire. ...
I did not know about the correct order. I'm gone check that as well.jreinhardt wrote:From what I read on the topological data scripting page the recommended procedure is to create a wire from edges straight edges and cirles. To create a wire, the edges have to be passed to the constructor in the correct order. ...
Re: Part Fillet in python
May be one of you guys could bring light in my darkness or point me to some documentation. I'm using the simple Topo example.
That one is copied for Topological Data Scripting and some nice solid is created.
The following only includes one circle in the shape and therefore the wire is not closed. I checked the correct order. It should be fine?!
The draft version is a closed wire created by the upgrade tool. Again only one circle is included.
That one is copied for Topological Data Scripting and some nice solid is created.
Code: Select all
from FreeCAD import Vector
import Part
V1 = Vector(0,10,0)
V2 = Vector(30,10,0)
V3 = Vector(30,-10,0)
V4 = Vector(0,-10,0)
VC1 = Vector(-10,0,0)
VC2 = Vector(40,0,0)
C1 = Part.Arc(V1,VC1,V4)
C2 = Part.Arc(V2,VC2,V3)
L1 = Part.Line(V1,V2)
L2 = Part.Line(V4,V3)
S1 = Part.Shape([C1,C2,L1,L2])
W = Part.Wire(S1.Edges)
F = Part.Face(W)
P = F.extrude(Vector(0,0,10))
Part.show(P)
Code: Select all
from FreeCAD import Vector
import Part
V1 = Vector(0,10,0)
V2 = Vector(30,10,0)
V3 = Vector(30,-10,0)
V4 = Vector(0,-10,0)
VC1 = Vector(-10,0,0)
VC2 = Vector(40,0,0)
r = 10
C1 = Part.makeCircle(r, V1, V4)
C2 = Part.makeCircle(r, V3, V2)
L1 = Part.Line(V2,V1)
L2 = Part.Line(V4,V3)
S1 = Part.Shape([C1,L2,C2,L1])
W = Part.Wire(S1.Edges)
F = Part.Face(W)
P = F.extrude(Vector(0,0,10))
Part.show(P)
The draft version is a closed wire created by the upgrade tool. Again only one circle is included.
Code: Select all
from FreeCAD import Vector
import Draft
V1 = Vector(0,10,0)
V2 = Vector(30,10,0)
V3 = Vector(30,-10,0)
V4 = Vector(0,-10,0)
VC3 = Vector(0,0,0)
VC4 = Vector(30,0,0)
pl=FreeCAD.Placement()
pl.Base = VC3
C1 = Draft.makeCircle(r,placement=pl,startangle=90,endangle=270)
pl.Base = VC4
C2 = Draft.makeCircle(r,placement=pl,startangle=270,endangle=90)
L1 = Draft.makeLine(V1,V2)
L2 = Draft.makeLine(V4,V3)
W = Draft.upgrade([C1,C2,L1,L2], delete=True)
#P = W.extrude(Vector(0,0,10)) # direct extrusion of the wire misses one circle
#F = Draft.upgrade(W, delete=True) # upgrade to a face does not work
#P = F.extrude(Vector(0,0,10))
-
- Posts: 329
- Joined: Mon Sep 09, 2013 6:08 pm
Re: Part Fillet in python
In your second example you are mixing Line and makeCircle, which I believe is not a good idea (but I have not checked in detail). Also the signature of makeCircle is different: first the radius, then the center, then the normal of the plane in which the circle is drawn and then start and end angle.
This is a working version of the second example:
This is a working version of the second example:
Code: Select all
from FreeCAD import Vector
import Part
V1 = Vector(0,10,0)
V2 = Vector(30,10,0)
V3 = Vector(30,-10,0)
V4 = Vector(0,-10,0)
VC1 = Vector(0,0,0)
VC2 = Vector(30,0,0)
normal = Vector(0,0,1)
r = 10
C1 = Part.makeCircle(r,VC1,normal,90,270)
C2 = Part.makeCircle(r,VC2,normal,270,90)
L1 = Part.makeLine(V1,V2)
L2 = Part.makeLine(V3,V4)
W = Part.Wire([L1,C1,L2,C2])
F = Part.Face(W)
P = F.extrude(Vector(0,0,10))
Part.show(P)
Re: Part Fillet in python
I ran your script up to the line that fails, (i.e. removed the failed line), then used the GUI tool to extrude, then copied the output from the Python window into the script. Then ran the script again and it worked. You will of course have to refine the script, but this shows that it works in principle. I don't know enough about the subject to offer further detailed advise.bernd wrote:Thats true for the GUI extrusion and works well. Could this option be set in python as well ? It would be the easiest soulution.jmaustpc wrote:But you don't need to make it a face, if you set the option to make solid "true" then Part Extrude will create a solid from the wire. ...
Jim
Re: Part Fillet in python
It would be easier. But i don't think that such a change would be wise. It makes sense in the GUI to tip somebody (working on feature level) that he may want to get a solid. But somebody working on shape level should really understand the shape types. Calling "Part.Face(wire)" is not that hard.bernd wrote:Thats true for the GUI extrusion and works well. Could this option be set in python as well ? It would be the easiest solution.jmaustpc wrote:But you don't need to make it a face, if you set the option to make solid "true" then Part Extrude will create a solid from the wire. ...