kherman
Military
- Jan 21, 2014
- 20
I am using the CurveCurvatureAnalysisBuilder in code and want to get the minimum radius that this builder creates.
I can get the builder to do the analysis and if I run my code and go into NX, the result is there in the 3D view.
The issue is that I can not figure out the method calls that are needed to get the actual result.
commit() returns null.
post commit allows this method to return a result:
builder.getCommittedObjects(); // this is an array of 1 CurveCurvatureAnalysis object.
Here is my method that does the work so far:
[pre]
private Double ascertainMinRadius(Edge edge) throws NXException, RemoteException {
nxopen.Session theSession = (nxopen.Session)nxopen.SessionFactory.get("Session");
nxopen.Part workPart = theSession.parts().work();
CurveCurvatureAnalysisBuilder builder =
workPart.analysisManager().analysisObjects().createCurveCurvatureAnalysisBuilder(null);
try {
builder.combRange().start().expression().setRightHandSide("0");
builder.combRange().start().expression().setRightHandSide("0");
builder.combRange().center().expression().setRightHandSide("50");
builder.combRange().center().expression().setRightHandSide("50");
builder.combRange().end().expression().setRightHandSide("100");
builder.combRange().end().expression().setRightHandSide("100");
builder.combOptions().setAnalysisType(nxopen.geometricutilities.CombOptionsBuilder.AnalysisTypes.RADIUS);
builder.combRange().start().expression().setRightHandSide("0");
builder.combRange().start().setParameterUsed(false);
builder.combRange().center().expression().setRightHandSide("50");
builder.combRange().center().setParameterUsed(false);
builder.combRange().end().expression().setRightHandSide("100");
builder.combRange().end().setParameterUsed(false);
builder.setReverseDirection(1);
EdgeTangentRule edgeTangentRule = workPart.scRuleFactory().createRuleEdgeTangent(edge, null, true, 0.5, false, false);
nxopen.SelectionIntentRule [] rules1 = new nxopen.SelectionIntentRule[1];
rules1[0] = edgeTangentRule;
builder.selectedCurves().replaceRules(rules1, false);
builder.combRange().start().update(nxopen.geometricutilities.OnPathDimensionBuilder.UpdateReason.PATH);
builder.combRange().end().update(nxopen.geometricutilities.OnPathDimensionBuilder.UpdateReason.PATH);
builder.combOptions().setMinimumLabelEnabled(true);
builder.combOptions().setAnalysisType(nxopen.geometricutilities.CombOptionsBuilder.AnalysisTypes.CURVATURE);
builder.combOptions().setScaleFactor(1.04);
builder.combOptions().setDensity(10000); // 10,000 max value. This is the highest accuracy.
builder.combOptions().setIntermediateDensity(0); // this does nothing but setting anyway (with high density, this should be low, like 0 or 1)
builder.commit(); // return null.
nxopen.NXObject [] objects1 = builder.getCommittedObjects();
for (NXObject nxObject : objects1) {
CurveCurvatureAnalysis curveCurvatureAnalysis = (CurveCurvatureAnalysis) nxObject;
String name = curveCurvatureAnalysis.name();
}
// WHAT DO I DO HERE?
// WHAT DO I DO HERE?
// WHAT DO I DO HERE?
} finally {
builder.destroy();
}
return 1e-6;
[/pre]
I can get the builder to do the analysis and if I run my code and go into NX, the result is there in the 3D view.
The issue is that I can not figure out the method calls that are needed to get the actual result.
commit() returns null.
post commit allows this method to return a result:
builder.getCommittedObjects(); // this is an array of 1 CurveCurvatureAnalysis object.
Here is my method that does the work so far:
[pre]
private Double ascertainMinRadius(Edge edge) throws NXException, RemoteException {
nxopen.Session theSession = (nxopen.Session)nxopen.SessionFactory.get("Session");
nxopen.Part workPart = theSession.parts().work();
CurveCurvatureAnalysisBuilder builder =
workPart.analysisManager().analysisObjects().createCurveCurvatureAnalysisBuilder(null);
try {
builder.combRange().start().expression().setRightHandSide("0");
builder.combRange().start().expression().setRightHandSide("0");
builder.combRange().center().expression().setRightHandSide("50");
builder.combRange().center().expression().setRightHandSide("50");
builder.combRange().end().expression().setRightHandSide("100");
builder.combRange().end().expression().setRightHandSide("100");
builder.combOptions().setAnalysisType(nxopen.geometricutilities.CombOptionsBuilder.AnalysisTypes.RADIUS);
builder.combRange().start().expression().setRightHandSide("0");
builder.combRange().start().setParameterUsed(false);
builder.combRange().center().expression().setRightHandSide("50");
builder.combRange().center().setParameterUsed(false);
builder.combRange().end().expression().setRightHandSide("100");
builder.combRange().end().setParameterUsed(false);
builder.setReverseDirection(1);
EdgeTangentRule edgeTangentRule = workPart.scRuleFactory().createRuleEdgeTangent(edge, null, true, 0.5, false, false);
nxopen.SelectionIntentRule [] rules1 = new nxopen.SelectionIntentRule[1];
rules1[0] = edgeTangentRule;
builder.selectedCurves().replaceRules(rules1, false);
builder.combRange().start().update(nxopen.geometricutilities.OnPathDimensionBuilder.UpdateReason.PATH);
builder.combRange().end().update(nxopen.geometricutilities.OnPathDimensionBuilder.UpdateReason.PATH);
builder.combOptions().setMinimumLabelEnabled(true);
builder.combOptions().setAnalysisType(nxopen.geometricutilities.CombOptionsBuilder.AnalysisTypes.CURVATURE);
builder.combOptions().setScaleFactor(1.04);
builder.combOptions().setDensity(10000); // 10,000 max value. This is the highest accuracy.
builder.combOptions().setIntermediateDensity(0); // this does nothing but setting anyway (with high density, this should be low, like 0 or 1)
builder.commit(); // return null.
nxopen.NXObject [] objects1 = builder.getCommittedObjects();
for (NXObject nxObject : objects1) {
CurveCurvatureAnalysis curveCurvatureAnalysis = (CurveCurvatureAnalysis) nxObject;
String name = curveCurvatureAnalysis.name();
}
// WHAT DO I DO HERE?
// WHAT DO I DO HERE?
// WHAT DO I DO HERE?
} finally {
builder.destroy();
}
return 1e-6;
[/pre]