I wanted to share a little trick.
A friend asked me if it was possible to flatten a face.
His version of SolidWorks didn't offer this feature.
This is a thin sheet of metal that is bent around a center block : He wanted to get the shape of this flattened face, to cut it to shape before bending it.
Here is how I did it:
I discretized the profile curve with distance method :
Code: Select all
bspline.discretize(Distance = 0.2)
Code: Select all
# pts are the discretized points
# dis is the discretization distance
params = []
for i in range(len(pts)):
params.append(1.0 * i * dis)
Code: Select all
bs = Part.BSplineCurve()
bs.interpolate(Points = pts, Parameters = params)
Then I extruded the resulting curve : The extruding operation also creates a curvilinear parametrization in the V direction.
So the parameters of this surface match realworld units.
Then I made the boolean operations to give the surface its final shape : And it is now simply a matter of taking the 2d curves of all the edges of this face and "apply" them an a plane :
Code: Select all
#face is the face highlighted above
edges = face.Edges
# the list of 2D curves
curves2d = []
for e in edges:
curves2d.append(face.curveOnSurface(e))
# apply the 2D curves on a plane
plane = Part.Plane()
for c in curves2d:
Part.show(c[0].toShape(plane))
Chris