Issue trimming lines in a sketch

Issue trimming lines in a sketch

Anonymous
Not applicable
1,242 Views
4 Replies
Message 1 of 5

Issue trimming lines in a sketch

Anonymous
Not applicable

Hello,

 

I have script which creates a sketch curve based on my chosen sketch plane's intersection with a body, I am then programmatically intersecting this sketch curve with straight line segments along its length; this all works fine, but I end up with some strange results in the next step where I trim the lines such that their endpoints are coincident with the sketch curve previously created.  What I expect/want to happen is the trim operation (set to trim the lines at their start and end points) will trim the line up to the point where the sketch curve and the line segment intersect.  This does in fact happen with some of the lines, however several of the line segments are not trimmed as expected, instead it is as if one of the intersection points is not registering.  I've checked to see that everything is 2D on the active sketch plane and it is and have used SketchCurve intersections method to see if it was picking up both intersection points, which it is not in some cases -- I've also checked to see if I can reproduce the behavior in the UI and it also occurs there.  Images are attached to demonstrate what I am trying to explain.

 

Pre-trim.pngPost-trim_bot.pngUI Based Trim (green circle is where cursor is placed).jpgUI Based Trim (expected result).jpg

if bodySelected.name == 'Mandible':
        planeOffsetValue = adsk.core.ValueInput.createByReal(6)
    else:
        planeOffsetValue = adsk.core.ValueInput.createByReal(0)
        
    planeInput.setByOffset(rootComponent.yZConstructionPlane, planeOffsetValue)
    
    # Generate sketch plane and create new sketch
    profilePlane = planes.add(planeInput)
    profileSketch = sketches.add(profilePlane)
    
    # Create a collection to hold the spline fit points
    points = adsk.core.ObjectCollection.create()
    
    # Create a sketch curve from the intersection of the selected body with the previously created sketch plane
    bodyOutline = profileSketch.projectCutEdges(rootComponent.bRepBodies.itemByName(bodySelected.name))

The code snippet above demos the creation of the SketchCurve via projected cut

 

 else:
        segments = int(sketchX)     
        for index in range(1, segments - 1):
            fibLine_StartPoint = adsk.core.Point3D.create(boundsMin.x + index, boundsMin.y - 1, 0)
            fibLine_EndPoint = adsk.core.Point3D.create(boundsMin.x + index, boundsMax.y + 1, 0)
            fibLine = profileSketch.sketchCurves.sketchLines.addByTwoPoints(fibLine_StartPoint, fibLine_EndPoint)
            
            # Trim the line
            fibLine.trim(fibLine_StartPoint)

and this code snippet shows how the lines are generated and trimmed

 

Thank you for any and all help,

 

Dylan

 

 

0 Likes
Accepted solutions (1)
1,243 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni

Can you provide the model where this is happening?  I've tried to reproduce it with some models I have and it's working as expected.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 5

Anonymous
Not applicable

Model attached -- thanks for the reply

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni
Accepted solution

It appears to be a geometry specific problem.  I can reproduce the problem with your model and have filed a bug against the Trim command.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks for the help Brian

0 Likes