Nice, very small differences on the curved (cylindrical) face
Development of a Curved Surface
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: Development of a Curved Surface
- Attachments
-
- Flat_faces.FCStd
- (67.09 KiB) Downloaded 38 times
Re: Development of a Curved Surface
Thanks for the comparison.
I wanted to check against the mesh method, but my self-compiled FC doesn't have this functionality.
I wanted to check against the mesh method, but my self-compiled FC doesn't have this functionality.
Re: Development of a Curved Surface
Thanks Guys, will look at them tomorrow.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Development of a Curved Surface
I know some pipe welders that love to make paper templets for cutting fitment.
Thanks all.
Thanks all.
Re: Development of a Curved Surface
This one should work on cones too :microelly2 wrote: ↑Mon Apr 13, 2020 1:49 pm Nice to have this already.
If we adopt this to conic surfaces the most common developable surfaces can be flattend.
Code: Select all
import FreeCAD
import FreeCADGui
import Part
def nurbs_flat_cylinder(face):
l1 = face.Surface.uIso(face.ParameterRange[0])
e1 = l1.toShape(*face.ParameterRange[2:])
c1 = face.Surface.vIso(face.ParameterRange[2])
t1 = c1.tangent(c1.FirstParameter)[0]
l = c1.length()
e2 = e1.copy()
e2.translate(t1*l)
rs = Part.makeRuledSurface(e1,e2)
bs = rs.Surface
bs.exchangeUV()
bs.setUKnots(face.ParameterRange[0:2])
return bs
def nurbs_flat_cone(face):
c1 = face.Surface.vIso(face.ParameterRange[2])
c2 = face.Surface.vIso(face.ParameterRange[3])
h = c1.value(c1.FirstParameter).distanceToPoint(c2.value(c2.FirstParameter))
c1.Center = FreeCAD.Vector(0,0,0)
c2.Center = FreeCAD.Vector(0,0,0)
c2.Radius = c1.Radius + h
e1 = c1.toShape()
e2 = c2.toShape()
rs = Part.makeRuledSurface(e1,e2)
bs = rs.Surface
bs.setVKnots(face.ParameterRange[2:])
return bs
def flatten_face(face):
if isinstance(face.Surface, Part.Cylinder):
flat_face = nurbs_flat_cylinder(face)
elif isinstance(face.Surface, Part.Cone):
flat_face = nurbs_flat_cone(face)
else:
return None
cos = [face.curveOnSurface(e) for e in face.Edges]
edges = [c[0].toShape(flat_face, c[1], c[2]) for c in cos]
wires = [Part.Wire(el) for el in Part.sortEdges(edges)]
f = Part.Face(wires)
f.validate()
if f.isValid():
return f
else:
return Part.Compound(wires)
sel = FreeCADGui.Selection.getSelectionEx()
face = sel[0].SubObjects[0]
flat_face = flatten_face(face)
if flat_face:
Part.show(flat_face)
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Development of a Curved Surface
There is still an error in your script ?!
here is my one
Code: Select all
sel = FreeCADGui.Selection.getSelectionEx()
face = sel[0].SubObjects[0]
f=face.toNurbs().Face1
sf=f.Surface
startA=f.valueAt(0,0)
apex=face.Surface.Apex
r0=(startA-apex).Length
r=face.Surface.Radius
import math
def uv2p(u,v):
devp=FreeCAD.Vector((r0+v)*math.cos(r/r0*u),(r0+v)*math.sin(r/r0*u))
return devp
col=[]
for e in face.Edges:
print (e)
pts=e.discretize(100)
ptsn=[]
for p in pts:
try:
[u,v]=sf.parameter(p)
#print(u,v,p)
ptsn += [uv2p(u,v)]
#ptsn += [FreeCAD.Vector(u,v)]
except:
print ("error",p)
try:
pol=Part.makePolygon(ptsn)
Part.show(pol)
print (pol.Length)
col += [pol]
except:
col += [e]
#Part.show(Part.Compound(col))
Re: Development of a Curved Surface
Oops, you're right. I need to rework it.
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Development of a Curved Surface
Very nice! This one seems to work very well for me in a couple tests I made, one with a cone cut from a cylinder, the other with a sphere cut from a cone. Any way to include support for a face made by cutting something from a sphere?
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Development of a Curved Surface
You cannot develope a sphere. Only faces with gaussian curvature zero can be developed. For such faces you only can split them into small segmets and make some deformation: example - the shell of an orangeTheMarkster wrote: ↑Mon Apr 13, 2020 5:38 pm Any way to include support for a face made by cutting something from a sphere?