New feature: Part Offset2D

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
User avatar
DeepSOIC
Posts: 7145
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: New feature: Part Offset2D

Postby DeepSOIC » Mon Oct 03, 2016 9:08 pm

I have experimented a little bit with circles.
When I move the circle within the sketch, the offset follows. However if I move the sketch itself, the offset is moved by twice the amount.
Same thing with Draft, except there is no way to move Draft Circle internally.
Screening Placement off Part Offset2d by making compound from the sketch/circle doesn't fix the problem. However, absorbing the placement with .transformShape method seems to fix this problem.

Furthermore, if I make the sketch circle on XZ plane, the offset result is on XY plane.

The problem is very specific to circles. Rectangle and ellipse work fine for me. So I would call it an OCC bug for now.
realthunder
Posts: 1230
Joined: Tue Jan 03, 2017 10:55 am

Re: New feature: Part Offset2D

Postby realthunder » Tue Jan 03, 2017 4:20 pm

I was able to locate and fix the circle bug in OCC. In case anyone need it, I include the patch below. The patch is against OCC 7.1.0. The bug affects circles having a transformed supporting plane. Since OCE hasn't caught up with OCC 7, I think FreeCAD shall host a fork of the OCC.

Unfortunately, there are other bugs in OCC makeOffset. And after spending days trying to hunt down the problem, I conclude that OCC makeOffset is just beyond help, with my knowledge at least. After searching around for alternatives to do 2D offset, I found the wonderful ClipperLib. And it turns out, FreeCAD already has this library! What do you know! I have submitted a pull request regarding this.

Code: Select all

diff --git a/src/BRepFill/BRepFill_OffsetWire.cxx b/src/BRepFill/BRepFill_OffsetWire.cxx
index 5cc63bd..2540e5a 100755
--- a/src/BRepFill/BRepFill_OffsetWire.cxx
+++ b/src/BRepFill/BRepFill_OffsetWire.cxx
@@ -293,12 +293,17 @@ static Standard_Boolean KPartCircle
       OC = new Geom2d_OffsetCurve( G2dT, anOffset);
     }
     Handle(Geom_Surface) aSurf = BRep_Tool::Surface(mySpine);
+    if (!L.IsIdentity()) {
+        Handle(Geom_Geometry) aCopy = aSurf->Transformed(L.Inverted().Transformation());
+        aSurf = Handle(Geom_Surface)(static_cast<Geom_Surface*>(aCopy.get()));
+    }
     Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
-    myShape = BRepLib_MakeEdge(OC, aPlane, f, l);
+    myShape = BRepLib_MakeEdge(OC, aSurf, f, l);
     BRepLib::BuildCurve3d(TopoDS::Edge(myShape));
-    
+
     myShape.Orientation(E.Orientation());
     myShape.Location(L);
+
     if (fabs(Alt) > gp::Resolution()) {
       BRepAdaptor_Surface S(mySpine,0);
       gp_Ax1 Nor = S.Plane().Axis();
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
DeepSOIC
Posts: 7145
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: New feature: Part Offset2D

Postby DeepSOIC » Wed Mar 29, 2017 12:36 am

Wiki page!
Part Offset2D
User avatar
sgrogan
Posts: 5458
Joined: Wed Oct 22, 2014 5:02 pm

Re: New feature: Part Offset2D

Postby sgrogan » Wed Mar 29, 2017 9:11 pm

DeepSOIC wrote:Wiki page!
Thanks DeepSOIC, very good Wiki page! Excellent explanation of the modes and their limitations.
paullee
Posts: 1826
Joined: Wed May 04, 2016 3:58 pm

Re: New feature: Part Offset2D

Postby paullee » Fri Feb 08, 2019 1:18 am

Hi, just so late testing this feature now :)

Noted if there is several wire in a sketch, it only process the '1st' wire right? ... Wiki - "...There can be multiple wires in one object, not necessarily coplanar..."

Thinking if / how an offset to the shown pattern is possible or supported in future?

BTW, note in this example, only 'pipe' setting works, 'skin' setting return only 2 'broken' edges..... play around with this feature, sometime FC crash.

Also, it return exception below in 0.18_pre - FreeCAD_0.18.15780.glibc2.17-x86_64.AppImage on Fedora 29 :-

Code: Select all

Exception (Fri Feb  8 09:08:17 2019): makeOffset2D: wires are nonplanar or noncoplanar  
Exception (Fri Feb  8 09:08:20 2019): makeOffset2D: wires are nonplanar or noncoplanar  
Exception (Fri Feb  8 09:08:21 2019): makeOffset2D: wires are nonplanar or noncoplanar  
Exception (Fri Feb  8 09:08:22 2019): makeOffset2D: wires are nonplanar or noncoplanar  
Exception (Fri Feb  8 09:08:25 2019): makeOffset2D: wires are nonplanar or noncoplanar  
Screenshot from 2019-02-08 09-08-30.png
Screenshot from 2019-02-08 09-08-30.png (181.89 KiB) Viewed 450 times
Screenshot from 2019-02-08 09-10-19.png
Screenshot from 2019-02-08 09-10-19.png (217.05 KiB) Viewed 450 times
Attachments
Test_ Offset2D_ Sketch.FCStd
(5.52 KiB) Downloaded 18 times
freedman
Posts: 1023
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New feature: Part Offset2D

Postby freedman » Tue Feb 12, 2019 3:47 pm

Is there a way to copy and paste the newly created offset sketch, so I can use it in Part Design, I tried and it won't work, yet! That looks very useful.
Thanks