Hi @diegojacobs. If you have the setting called "Autoproject part origin on sketch create" turned on within your Application Options > Sketch tab, that point should automatically appear for you, but I don't recall if that applies to when you 'redefine' a sketch. It is a very handy setting though. @dalton98 was right about that SketchPoint loosing its reference though after redefining the sketch, because it was created by projection. Can you tell if there is still a SketchPoint in the sketch after you have redefined the sketch? If so, you may just need to re-constrain that point. If not, then you would need to re-project the WorkPoint to the Sketch, which will create a new SketchPoint that will have a 'Fixed' constraint. If you have to re-create the SketchPoint, then you will also most likely have to re-create the constraint between it and the other geometry in the sketch. However, if the SketchPoint still exists, and you just ensure it is in the proper location and add a Fixed constraint to it again, the constraint(s) between it and the other sketch geometry will most likely be preserved, and OK.
I just created some geometry similar to yours in a new part document and tried to simulate what you are doing. When I redefine the sketch manually, everything works just fine. Cut works, & sketch stays fully constrained. But when I set a different work plane by code it becomes unconstrained, due to the origin point loosing its reference. I found a way to fix this with the code below:
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oOriginPoint As WorkPoint = oPDef.WorkPoints.Item(1)
Dim oYZPlane As WorkPlane = oPDef.WorkPlanes.Item("YZ Plane")
Dim oXYPlane As WorkPlane = oPDef.WorkPlanes.Item("XY Plane")
Dim oSketch As PlanarSketch = oPDef.Sketches.Item("Sketch8")
'ReDefine Sketch
If oSketch.PlanarEntity Is oYZPlane Then
oSketch.PlanarEntity = oXYPlane
ElseIf oSketch.PlanarEntity Is oXYPlane Then
oSketch.PlanarEntity = oYZPlane
End If
'Find SketchPoint that represents Origin Point
Dim oOriginSP As SketchPoint
If oSketch.SketchPoints.Count > 1 Then
For Each oSP As SketchPoint In oSketch.SketchPoints
If oSP.ReferencedEntity Is oOriginPoint Then
oOriginSP = oSP
End If
Next
If IsNothing(oOriginSP) Then
For Each oSP As SketchPoint In oSketch.SketchPoints
If oSP.Geometry.X = 0 And oSP.Geometry.Y = 0 Then
oOriginSP = oSP
End If
Next
End If
End If
'if found, make sure it is fully constrained
If oOriginSP IsNot Nothing Then
If oOriginSP.ConstraintStatus <> ConstraintStatusEnum.kFullyConstrainedConstraintStatus Then
oSketch.GeometricConstraints.AddGround(oOriginSP)
End If
Else 'sketch point representing origin or origin location was never found
MsgBox("Origin SketchPoint was not found.",,"")
End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)