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.
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
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
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.
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.