Curved Shapes Workbench
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Curved Shapes Workbench
I tried to reproduce your settings, but something is still going wrong. Do you have an idea what it could be?
Thanks,
Roland, OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22670 (Git)
Build type: Release
Branch: master
Hash: 12155f4aab09047c5697db0c1b3cf93b02edda03
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
Thanks,
Roland, OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22670 (Git)
Build type: Release
Branch: master
Hash: 12155f4aab09047c5697db0c1b3cf93b02edda03
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
- Attachments
-
- curved shape rbi.FCStd
- (134.56 KiB) Downloaded 58 times
Re: Curved Shapes Workbench
Something is wrong here in your file. Remake all JoinCurves.
Select in the right order: shape1,shape2, Hullcurve1, Hullcurve2
Select in the right order: shape1,shape2, Hullcurve1, Hullcurve2
- Attachments
-
- Capture.JPG (59.61 KiB) Viewed 2255 times
Re: Curved Shapes Workbench
I tried to use the "Curved Segment" tool to make a smooth surface between 2 flanges of the fuselage of a FW190 that I'm modeling, but unfortunately the curves (that I draw as sketches on top of imported drawings) don't begin at the same segments: Edge1 of 1 flange is at the bottom, while it's the side on the other. The resulting interpolation is thus twisted:
That's when I discovered the "Twist" parameter, thinking that it could very handily correct this, but it doesn't do anything at all. The "Twist Reverse" parameter does screw-up the result, but changing "Twist" has no influence whatsoever.
Is this a bug ?
Is there another way to correct the twist in support edges ?
PartDesign?
I've done some searching to look for an answer, so I hope I didn't miss something. Has anyone ported Curved Shapes to use the PartDesign vs Part API?
Re: Curved Shapes Workbench
This is just from my memory so accuracy is not guaranteed! We used to have a similar issue in Part WB with I think it was Rules surface and Loft where the two edges had the opposite orientation. A very long time ago there was an update in I think it was OCCT but could have been FreeCAD, that stopped this twist automatically on creation. I am talking about something like FreeCAD 0.12/0.13 I think, certainly a long time ago.
Anyway before that update, to fix the problem we would use Part_ReverseShapes on one of the edges/lines to reverse it and then the twist would be removed.
That worked to flip an edge/line, but I think it would not work in your case since you have wires/sketches, but anyway I thought I would mention it in case it is of any interest.
You would know far better than I if/how to do this next suggestion, but you can reorder the edges in a wire in Python.
Edit:- after further reflection, I don't think either of my ideas has relevance here in this case.
Re: Curved Shapes Workbench
Sketches are seen from the outside world as having edges, so the problem is not there. The problem is that I need to re-order the edges of the resulting shape, while in the code the "Twist" parameter re-orders the poles of curves. For edges, there are 2 poles, and re-ordering them means that they are reversed, each edge individually, but with the same ordering.jmaustpc wrote: ↑Thu Oct 29, 2020 1:21 am Anyway before that update, to fix the problem we would use Part_ReverseShapes on one of the edges/lines to reverse it and then the twist would be removed.
That worked to flip an edge/line, but I think it would not work in your case since you have wires/sketches
I looked at the code, it has a function reorderPoints() but it would (also) need one reorderEdges()
Ping ! Any thoughts ?
Re: Curved Shapes Workbench
It's too big for the forum, but there is a very simplilfied geometry that explains it a lot better: 2 hexagons.
Reading your code, I think that the problem comes from the idea that you only deal with B-splines, and when necessary you convert curves to B-splines, And you do that for every edge. So if you have 1 curve which is a B-spline its good, but what happens if you have 2 curves ?
Code: Select all
curve2 = edge2.Curve.toBSpline(edge2.FirstParameter, edge2.LastParameter)
...
poles2 = reorderPoints(curve2.getPoles(), fp.Twist, fp.TwistReverse)
What one should do I think is that if there are several edges, then the "Twist" parameter should be seen as an int, and the edges of the second curve (Shape2) should be offset by this amount. If each curve has only 1 edge, then di the current trick.
Code: Select all
twistedEdges = False
if len(fp.Shape1.Shape.Edges)>1 and len(fp.Shape2.Shape.Edges)>1
Shape2_new = reorderEdges(fp.Shape2.Shape, fp.Twist, fp.TwistReverse)
twistedEdges = True
What do you think ?
- Attachments
-
- CurvedSegment.FCStd
- (19.24 KiB) Downloaded 44 times
Re: Curved Shapes Workbench
For the hexagonal contours (makeRibsSameShape) this works:
Code: Select all
edges = []
curves = []
# if there are several edges:
if len(fp.Shape1.Shape.Edges)>1 and len(fp.Shape2.Shape.Edges)>1:
profile1 = fp.Shape1.Shape.Edges
profile2 = reorderEdges( fp.Shape2.Shape.Edges, fp.Twist, fp.TwistReverse )
multi_edges = True
else :
profile1 = fp.Shape1.Shape.Edges
profile2 = fp.Shape2.Shape.Edges
multi_edges = False
for e in range(0, len(profile1)):
edge1 = profile1[e]
edge2 = profile2[e]
curve1 = edge1.Curve.toBSpline(edge1.FirstParameter, edge1.LastParameter)
curve2 = edge2.Curve.toBSpline(edge2.FirstParameter, edge2.LastParameter)
poles1 = curve1.getPoles()
if multi_edges:
poles2 = curve2.getPoles()
else:
poles2 = reorderPoints(curve2.getPoles(), fp.Twist, fp.TwistReverse)
...
def reorderEdges(edges, twist, reverse):
nr = len(edges)
if nr >= 2:
start = min( nr, int(twist) )
newedges = []
if reverse:
for i in range(start, -1, -1):
newedges.append(edges[i])
for i in range(nr - 1, start, -1):
newedges.append(edges[i])
else:
for i in range(start, nr):
newedges.append(edges[i])
for i in range(0, start):
newedges.append(edges[i])
return newedges
Re: Curved Shapes Workbench
and the following works for makeRibsInterpolate:
the function should actually be called reorderItems(). This works only for simple geometry. Ideally, this should be called before EdgesToPoints() I think
Code: Select all
pointslist1 = EdgesToPoints(fp.Shape1.Shape, int(nr_edges / len1), int(fp.InterpolationPoints))
#pointslist2 = EdgesToPoints(fp.Shape2.Shape, int(nr_edges / len2), int(fp.InterpolationPoints))
pointslist_t = EdgesToPoints(fp.Shape2.Shape, int(nr_edges / len2), int(fp.InterpolationPoints))
pointslist2 = reorderEdges(pointslist_t, fp.Twist, fp.TwistReverse)