Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java: CurveCurvatureAnalysisBuilder - get the min bend radius

Status
Not open for further replies.

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]
 
Replies continue below

Recommended for you

As far as I can see, this builder object doesn't give you the minumum radius.

I couldn't find an NXOpen.UF function to do this, either, though I vaguely recall that there is one.

If there are no suitable functions, you'll have to write your own. Just calculate the radius of curvature at a large nunber of points along the curve.
 
I did go down the route you mentioned but performance was bad.

So, I did more digging and stumbled upon the answer (awesome documentation for NX, right).

[pre] UFSession ufs = (UFSession)SessionFactory.get("UFSession");
UFModlGeneral modlGeneral = ufs.modlGeneral();

minRadius = Double.MAX_VALUE;

for(int i = 0; i < samples; i++) {
double sample = i/(samples-1.0);
AskCurvePropsData curveProps = modlGeneral.askCurveProps(edge.tag(), sample);
minRadius = Math.min(minRadius, curveProps.radOfCur);
}[/pre]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor