Revolve confirmation issue

Hello All,
I’d like to share my problem with you and hopefully will find some help. I’ve written an application which simulates manufacturing of bevel gears based on Boolean’s operations. After simulation I receive some number of “microsurfaces” representing a teeth spacing. In the next step the program needs to cut received microsurfaces by a tool created by revolve operation (sheet feature). I’ve notice an issue when a number of “microsurfaces” is high, then the NX cannot confirm a revolve feature (only such error occurs: “System.NullReferenceException” which says me nothing. When this number is low the revolve feature can be confirmed without any error. Below you can find a code. Anybody have an idea what is wrong here? Do you think that memory is overloaded? Do I have any command enables to release it?
Thank you in advance for your help,
Pawel

The code:

int licz1 = 0;

Section section1;
SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
NXObject feature_revolve1 = null;
NXOpen.Features.RevolveBuilder revolveBuilder1 = null;

double IncZ = ((B + 2 * naddatek) / (inter_number-1));

while (licz1 < 10)
{
point3d1.X = 0;
point3d1.Y = 0.5;
point3d1.Z = offsetIN + Z1DIA + (IncZ * Math.Cos(sigma1 * (Math.PI / 180))) * licz;

point3d2.X = 0;
point3d2.Y = Y1DIA + (4 * Math.Cos(sigma1 * (Math.PI / 180))) + ((IncZ) * Math.Sin(sigma1 * (Math.PI / 180)) + (0) * Math.Cos(sigma1 * (Math.PI / 180))) * licz;
point3d2.Z = offsetIN - (4 * Math.Sin(sigma1 * (Math.PI / 180))) + ((IncZ) * Math.Cos(sigma1 * (Math.PI / 180)) - (0) * Math.Sin(sigma1 * (Math.PI / 180))) * licz;

Vector3d vector3d1 = new Vector3d(0, 0, 1);
Point point1 = displayPart.Points.CreatePoint(point3d1);
Point point2 = displayPart.Points.CreatePoint(point3d2);

//Line definition
Curve[] linia = new Curve[1];
linia[0] = displayPart.Curves.CreateLine(point1, point2);
NXObject nxObject1;
nxObject1 = linia[0];

Point3d pointZero = new Point3d(0, 0, 0);

Direction direction1;
direction1 = displayPart.Directions.CreateDirection(pointZero, vector3d1, NXOpen.SmartObject.UpdateOption.WithinModeling);

//Axis creation
Point nullPoint = null;
Axis axis1;
axis1 = displayPart.Axes.CreateAxis(nullPoint, direction1, SmartObject.UpdateOption.WithinModeling);

//RevolveBulidier

NXOpen.Features.Feature nullFeature1 = null;
revolveBuilder1 = displayPart.Features.CreateRevolveBuilder(nullFeature1);

//Section

section1 = displayPart.Sections.CreateSection(0.02, 0.02, 0.02);

revolveBuilder1.Section = section1;
revolveBuilder1.Axis = axis1;
revolveBuilder1.Tolerance = 0.02;
section1.DistanceTolerance = 0.02;
section1.ChainingTolerance = 0.02;

//Line assignment
CurveDumbRule curveDumbRule1;
curveDumbRule1 = displayPart.ScRuleFactory.CreateRuleCurveDumb(linia);

section1.AllowSelfIntersection(true);

rules1[0] = curveDumbRule1;
NXObject nullNXObject = null;

//Selection
section1.AddToSection(rules1, nxObject1, nullNXObject, nullNXObject, point3d1, NXOpen.Section.Mode.Create, false);

revolveBuilder1.Axis = axis1;

//Sheet Body selection
revolveBuilder1.FeatureOptions.BodyType = NXOpen.GeometricUtilities.FeatureOptions.BodyStyle.Sheet;
revolveBuilder1.Section = section1;

//Ustawienia
revolveBuilder1.Limits.StartExtend.Value.RightHandSide = "0";
revolveBuilder1.Limits.EndExtend.Value.RightHandSide = "360";
revolveBuilder1.ParentFeatureInternal = false;

licz1++;

try
{
feature_revolve1 = revolveBuilder1.CommitFeature();
}
catch
{
continue;
}

break;
};

The System.NullReferenceException might actually be useful; which lines of code are indicated in the message when the error is thrown?

How small are these "microsurfaces"? If they are below the modeling distance tolerance, they might be ignored by NX. A good starting point for the modeling tolerance is 10X smaller than the geometry you are working with.

Hello again,

Following line of code is thrown as an error:
feature_revolve1 = revolveBuilder1.CommitFeature();

Think it would be helpful to describe the sequence of the program:
1)“Cutting simulation” – the gear (solid cone) is “cut” by the cutter head (solid) in the iterative process using subtract function.

2)Extracting of surfaces from the cut teeth spacing using the following code:

foreach (NXOpen.Body body in workPart.Bodies)
{
Face[] faces = body.GetFaces();
Face[] faces_copy = new Face[faces.Length];
bool[] added = new bool[faces.Length];
NXObject[] nxObject_Faces = new NXObject[faces.Length];
NXOpen.Features.ExtractFaceBuilder[] extractFaceBuilder1 = new NXOpen.Features.ExtractFaceBuilder[faces.Length];
NXOpen.Features.Feature[] nullFeature_features = new NXOpen.Features.Feature[faces.Length];

for (i = 0; i < faces.Length; i++)
{
extractFaceBuilder1[i] = workPart.Features.CreateExtractFaceBuilder(nullFeature_features[i]);
extractFaceBuilder1[i].FaceOption = NXOpen.Features.ExtractFaceBuilder.FaceOptionType.SingleFace;
added[i] = extractFaceBuilder1[i].ObjectToExtract.Add(faces[i]);
nxObject_Faces[i] = extractFaceBuilder1[i].Commit();
extractFaceBuilder1[i].Destroy();
}

3)Tool creation – a sheet cone which is used to do the following intersections along the tooth.

Here the error occurs! (the code was shown on the last post).

4)Intersection of the extracted surfaces using the above tool.

5) … rest of the code

The cutting simulation can be prepared with different number of steps what in result gives different number of “microsurfaces”. I noticed that the revolveBuilder1.CommitFeature() command works when the number of microsurfaces is below 1500. Above this number the revolveBuilder cannot be confirmed…

P.S. Area and minimum dimension of the smallest “microsurface” are sometimes smaller in case when the revolveBuilder1.CommitFeature()command works…

I don't know the limitations on the number of bodies allowed for a single command, but I suspect you have found it.