Hello, code ninjas. I was wondering if someone here may have a better approach what I am doing (that sometimes produces errors as well).

Task is getting rid of incisions of an object outline. Basically making the lines smooth from a certain size.

This is my current approach - applying an outside contour, breaking it apart and then applying same size inside contour and thus getting a clean path. But it seems a little inefficient and sometimes produces errors (when small details are too close to one another). May there be some other, more efficient way to do this?

Thanks in advance!

Edit: The sample is a rectangle just for clarity, in reality we are dealing with all sorts of random shapes, so it cannot just be replaced.

Edit 2: Looks like I am using the same method that Shelby came up with here: https://forum.oberonplace.com/showpost.php?p=6874&postcount=3 so chances of there being something better do not seem that great. But, perhaps, something has changed over time. Aiming at 2018 at the moment, but this may justify a later version if it offers something new.

How about examining the curve and identifying the cusp nodes that are the "sharp points" of those incisions? Perhaps by using the angles of the control points of the two segments that involve that node?

Here's something you could look at:

Subtest_it()
Dim s As Shape
Dim noderangeThis AsNew NodeRange
Set s = ActiveShape
examine_curve_and_identify_sharp_point_nodes s.Curve, 5, noderangeThis
noderangeThis.Delete
Refresh
EndSubFunctionexamine_curve_and_identify_sharp_point_nodes(ByVal SourceCurve As Curve, ByVal CPAngleTolerance AsDouble, ByRef SharpPointNodeRange As NodeRange) AsBooleanDim nodeThis As Node
Dim lngNodeIndex_subpath_getting AsLongDim subPathThis As SubPath
OnErrorGoTo ErrHandler
ForEach subPathThis In SourceCurve.SubPaths
If subPathThis.Closed ThenFor lngNodeIndex_subpath_getting =1To subPathThis.Nodes.Count
Set nodeThis = subPathThis.Nodes(lngNodeIndex_subpath_getting)
If nodeThis.Type = cdrCuspNode ThenIf nodeThis.Segment.Type = cdrLineSegment And nodeThis.NextSegment.Type = cdrLineSegment ThenIf AnglesAreClose(nodeThis.Segment.EndingControlPointAngle, nodeThis.NextSegment.StartingControlPointAngle, CPAngleTolerance) Then
SharpPointNodeRange.Add nodeThis
EndIfEndIfEndIfNext lngNodeIndex_subpath_getting
EndIfNext subPathThis
ExitFunc:
ExitFunctionErrHandler:
MsgBox "Error occurred: "& Err.Description & vbCrLf & vbCrLf &"examine_curve_and_identify_sharp_point_nodes()", vbExclamation
Resume ExitFunc
EndFunctionPublicFunctionAnglesAreClose(ByRef Angle_A AsDouble, ByRef Angle_B AsDouble, ByRef Tolerance AsDouble) AsBooleanIf Abs(Angle_A - Angle_B) < Tolerance Then
AnglesAreClose =TrueElseIf (Angle_A >=0And Angle_A <= Tolerance) And (Angle_B <=360And Angle_B >=360- Tolerance) ThenIf Angle_A + (360- Angle_B) < Tolerance Then
AnglesAreClose =TrueEndIfElseIf (Angle_A <=360And Angle_A >=360- Tolerance) And (Angle_B >=0And Angle_B <= Tolerance) ThenIf (360- Angle_A) + Angle_B < Tolerance Then
AnglesAreClose =TrueEndIfEndIfEndIfEndIfEndFunction

I'm glad to hear that it might help you solve your problem!

Thanks for your kind words about the code, too. I started with code from a couple of other projects, and then modified it as necessary.

So, only a little bit of new code; mostly removing other code that was not necessary here. I might have missed a few things, e.g., I don't need to have "Public" in the one function.