swaldon
Computer
- Sep 30, 2011
- 4
I'm having some trouble using the NXOpen libraries in .NET to force a constraint to flip to its alternate solution in a sketch. I'm using NX 7.5.
In code, I'm passing various dimensions to a vertical dimension constraint in a sketch. Sometimes the values are positive, and sometimes they are negative. When the sign changes, I need to do an "Alternate Solution" on the vertical constraint because NX doesn't adjust the model based upon sign.
After I have my part open, I execute the following code:
However, the UseAlternateSolution function fails giving an "Unable to create alternate solution" error message. When I use the alternate solution tool interactively inside NX, the constraint changes without any issue. I've also tried using the type "SketchDimensionalConstraint" instead of the "SketchHelpedDimensionalConstraint", but got the same result.
Does anyone know how to switch a constraint to its alternate solution using the NXOpen API?
Thanks.
In code, I'm passing various dimensions to a vertical dimension constraint in a sketch. Sometimes the values are positive, and sometimes they are negative. When the sign changes, I need to do an "Alternate Solution" on the vertical constraint because NX doesn't adjust the model based upon sign.
After I have my part open, I execute the following code:
Code:
Dim TheSketch As NXOpen.Sketch = Session.Parts.Work.Sketches.FindObject("Sketch1") 'My sketch is named inside the part file.
Dim VertConstraint As NXOpen.SketchHelpedDimensionalConstraint = CType(TheSketch.FindObject("DimensionalConstraint Rise"), NXOpen.SketchHelpedDimensionalConstraint) 'This successfully returns the correct vertical dimensional constraint. The expression name tied to the constraint is "Rise"
Try
VertConstraint.UseAlternateSolution() 'this fails
Catch ex As NXOpen.NXException
MsgBox(ex.Message)
End Try
However, the UseAlternateSolution function fails giving an "Unable to create alternate solution" error message. When I use the alternate solution tool interactively inside NX, the constraint changes without any issue. I've also tried using the type "SketchDimensionalConstraint" instead of the "SketchHelpedDimensionalConstraint", but got the same result.
Does anyone know how to switch a constraint to its alternate solution using the NXOpen API?
Thanks.