///
/// 通过始末值创建拉伸
///
/// 被拉伸曲线
/// 起始值
/// 终止值
/// 创建的拉伸实体
public void CreateExtrudeSheetByValues(Curve e_curve, double s_value, double e_value, out Body e_body)
{
try
{
NXOpen.Features.Feature nullFeatures_Feature = null;
NXOpen.Features.ExtrudeBuilder extrudeBuilder1;
extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullFeatures_Feature);
Section section1;
section1 = workPart.Sections.CreateSection();
extrudeBuilder1.Section = section1;
extrudeBuilder1.AllowSelfIntersectingSection(true);
extrudeBuilder1.DistanceTolerance = 0.0254;
extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
extrudeBuilder1.FeatureOptions.BodyType = NXOpen.GeometricUtilities.FeatureOptions.BodyStyle.Sheet;
extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = s_value.ToString();
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = e_value.ToString();
section1.DistanceTolerance = 0.0254;
section1.ChainingTolerance = 0.02413;
section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves);
Curve[] curves1 = new Curve[1] { e_curve };
CurveDumbRule curveDumbRule1;
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves1);
section1.AllowSelfIntersection(true);
SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
rules1[0] = curveDumbRule1;
NXObject nullNXObject = null;
Point3d helpPoint1 = new Point3d();
section1.AddToSection(rules1, e_curve, nullNXObject, nullNXObject, helpPoint1, NXOpen.Section.Mode.Create, false);
Point3d origin1 = new Point3d(0, 0, 0);
Vector3d vector1 = new Vector3d(0.0, 0.0, 1.0);
Direction direction1;
direction1 = workPart.Directions.CreateDirection(origin1, vector1, NXOpen.SmartObject.UpdateOption.WithinModeling);
extrudeBuilder1.Direction = direction1;
Extrude feature1;
feature1 = (Extrude)extrudeBuilder1.CommitFeature();
e_body = feature1.GetBodies()[0];
extrudeBuilder1.Destroy();
}
catch (Exception ex)
{
e_body = null;
MessageBox.Show(ex.ToString());
}
}
欢迎加入我的UGNX二次开发Q群:282343540