Curved Shapes Workbench

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
rolbit
Posts: 25
Joined: Fri Apr 01, 2011 6:15 am
Location: Switzerland

Re: Curved Shapes Workbench

Post by rolbit »

I tried to reproduce your settings, but something is still going wrong. Do you have an idea what it could be?

Thanks,
Roland,
curve shapes 02.png
curve shapes 02.png (172.09 KiB) Viewed 2274 times
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
User avatar
Vincent B
Veteran
Posts: 4733
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: Curved Shapes Workbench

Post by Vincent B »

Something is wrong here in your file. Remake all JoinCurves. ;)
Select in the right order: shape1,shape2, Hullcurve1, Hullcurve2
Attachments
Capture.JPG
Capture.JPG (59.61 KiB) Viewed 2255 times
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Curved Shapes Workbench

Post by Zolko »

christi wrote: Sun Jun 30, 2019 8:06 am Curved Segment interpolates between two 2D shapes and resizes in the bounds of hullcurves
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:

twist.png
twist.png (441.27 KiB) Viewed 2185 times


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 ?
try the Assembly4 workbench for FreCAD — tutorials here and here
jgnsb
Posts: 1
Joined: Sat Oct 24, 2020 3:42 pm

PartDesign?

Post by jgnsb »

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?
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Curved Shapes Workbench

Post by jmaustpc »

Zolko wrote: Wed Oct 28, 2020 12:00 pm , 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:
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.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Curved Shapes Workbench

Post by Zolko »

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
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.

I looked at the code, it has a function reorderPoints() but it would (also) need one reorderEdges()

christi wrote: Tue Jun 11, 2019 6:17 pm I would like to share my new workbench "Curved Shapes".
Ping ! Any thoughts ?
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
christi
Posts: 208
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Curved Shapes Workbench

Post by christi »

Zolko wrote: Thu Oct 29, 2020 11:54 am Ping ! Any thoughts ?
Can you share this part of your design ? I will have a look at this...
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Curved Shapes Workbench

Post by Zolko »

christi wrote: Fri Oct 30, 2020 6:24 pm
Zolko wrote: Thu Oct 29, 2020 11:54 am Ping ! Any thoughts ?
Can you share this part of your design ? I will have a look at this...
It's too big for the forum, but there is a very simplilfied geometry that explains it a lot better: 2 hexagons.

CurvedSegment.png
CurvedSegment.png (277.13 KiB) Viewed 1993 times

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
and in reorderPoles() check whether twistedEdges has ben set, in which case poles are not re-ordered. So, if the user has only simple geometry (lines, arcs, ellipses) and many of them, then the "Twist" parameter will offset these eges by that amount, and if the user has only 1 edge which is a B-spline then the poles are going to be re-ordered. Of course, if someone is so wicked and has straight edges and B-splines in the same curve, and they're all mixed-up, then it won't work.

What do you think ?
Attachments
CurvedSegment.FCStd
(19.24 KiB) Downloaded 44 times
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Curved Shapes Workbench

Post by Zolko »

christi wrote: Fri Oct 30, 2020 6:24 pm
Zolko wrote: Thu Oct 29, 2020 11:54 am Ping ! Any thoughts ?
Can you share this part of your design ? I will have a look at this...
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 
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Curved Shapes Workbench

Post by Zolko »

and the following works for makeRibsInterpolate:

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)
the function should actually be called reorderItems(). This works only for simple geometry. Ideally, this should be called before EdgesToPoints() I think
try the Assembly4 workbench for FreCAD — tutorials here and here
Post Reply