AnsweredAssumed Answered

Unable to figure out debugging issues

Question asked by Harold Black on Apr 12, 2018
Latest reply on Apr 12, 2018 by Harold Black

I've been working on some code that creates rectangles that approximates a curve, basically discretizing a spline. For the most part my code works. Some issues I have outlined below.


1.     Some widths of the rectangles are not constant. I have debugged and still can't see where the problem is.

2.     Sometimes a vertical line is extended past a horizontal line, even though I have a test to see if an extended operation is needed. When I run the code again, there are no extended line problems.

3.     Not really an issue but I would like to figure out a way to change my conditional tests in the CreateEndSegment function to allow floating point calculations. I've tried this before but the logical statements didn't work for me.



Outline of how the code works.


1.     A spline is selected and the endpoints found. The spacing is found with this and the number of piles (rectangles).

2.     A copy of this spline is created for each pile. The reason for this is that I need to draw a tangent line to the spline local to each rectangle.

3.     In the For loop, I create the vertical lines and trim them below the spline (which is why I need the long horizontal line). I save the endpoints.

4.     I check to see if the sketch segment I'm looping through is of the type SPLINE. If it is, I perform a trim operation on the copied spline so that only the portion in the current region is kept. I save the endpoints of the spline to a variable SplinePoints.

5.     A line is created and constrained to be tangent to the spline segment. A point is created and constrained to be coincident to both the tangent line and the spline segment. I get the y coordinate of the point called TanY.

6.     I run various checks to determine the following.


          1) Is the tangent point higher than both of the spline segment endpoints. If yes, draw the short horizontal line starting from the lesser y value of the spline segment endpoints.

          2) Is the tangent point lower than both of the spline segment endpoints. If yes, draw the short horizontal line using TanY as the y value.

          3) Is the tangent point between the spline segment endpoints. If yes, find which spline segment endpoint is lower and draw the short horizontal line segment starting from there.


7.     After a short horizontal line is drawn, the correct vertical line (swPileSeg) is selected depending on what case I tested into. The line is then extended.

8.     Since there maybe be another horizontal line drawn below the previous one, I need to check to see if the endpoint of swPileSeg is greater than the next SplinePoint (2*i+1). If it is greater, I need to extend the line again.

9.     Lastly, I delete the construction geometry i.e. spline segments, tangent line, and tangent point.


I have posted on this forum before on other issues with my code that I have fixed. I'm hoping to figure the rest of these issues out. I've supplied the code and the test file I'm using. I'm using SolidWorks 2018.