C# NX二次开发:在多个体的模型中如何实现拉伸操作布尔减

ops/2025/3/17 9:30:51/

大家好,今天接着上一篇拉伸文章去讲。

UF_MODL_create_extruded1 (view source)

uf_list_p_tobjectsInputList of objects to be extruded.
char *taper_angleInputTaper angle (in degrees).
char *limit [ 2 ]InputLimit of extrusion. This is declared as:
char limit[2]. The first value is the start value of
the extrusion and the second value is the end of the
extrusion (see the example program).
doublepoint [ 3 ]Inputnot used
doubledirection [ 3 ]InputExtrusion axis.
UF_FEATURE_SIGNsignInputThe sign of the operation to be performed.
UF_NULLSIGN = create new target solid
UF_POSITIVE = add to target solid
UF_NEGATIVE = subtract from target solid
UF_UNSIGNED = intersect with target solid
tag_ttarget_bodyInputTarget body to perform Boolean
uf_list_p_t *featuresOutput to UF_*free*List of feature identifiers created. This list
must be freed by calling UF_MODL_delete_list.

可能大家也注意到了这里面多了一个传入目标体的参数,这个时候大家可能以为这就是解决了上面所说的那个问题了,我当时也是这样认为的,可到了使用的时候才知道,你传入的Tag值也不起作用,这个API是有问题的。

上一篇文章讲到这有问题的,现在来讲如果想要实现标题中想要的效果怎么解决。

直接上代码就不来虚的了:

  /// <summary>
    /// 使用NXOPEN来创建拉伸操作并且返回特征的tag值
    /// </summary>
    /// <returns></returns>
    public Tag NXopenCreateExtrude(string endextend, Feature feature, Sketch sketch,Body body)
    {
        NXOpen.Features.Feature nullNXOpen_Features_Feature = null;
        NXOpen.Features.ExtrudeBuilder extrudeBuilder1;
        extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature);
        NXOpen.Section section1;
        section1 = workPart.Sections.CreateSection(0.00095, 0.001, 0.050000000000000003);
        extrudeBuilder1.Section = section1;
        extrudeBuilder1.AllowSelfIntersectingSection(true);
        NXOpen.Unit unit1;
        unit1 = extrudeBuilder1.Draft.FrontDraftAngle.Units;
        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
        NXOpen.Body[] targetBodies1 = new NXOpen.Body[1];
        NXOpen.Body nullNXOpen_Body = null;
        targetBodies1[0] = nullNXOpen_Body;
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies1);
        extrudeBuilder1.Limits.StartExtend.Value.SetFormula("0");
        extrudeBuilder1.Limits.EndExtend.Value.SetFormula(endextend);
        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract;
        NXOpen.Body[] targetBodies2 = new NXOpen.Body[1];
        targetBodies2[0] = nullNXOpen_Body;
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies2);
        NXOpen.GeometricUtilities.SmartVolumeProfileBuilder smartVolumeProfileBuilder1;
        smartVolumeProfileBuilder1 = extrudeBuilder1.SmartVolumeProfile;
        smartVolumeProfileBuilder1.OpenProfileSmartVolumeOption = false;
        smartVolumeProfileBuilder1.CloseProfileRule = NXOpen.GeometricUtilities.SmartVolumeProfileBuilder.CloseProfileRuleType.Fci;
        section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves);
        NXOpen.Features.Feature[] features1 = new NXOpen.Features.Feature[1];
        //NXOpen.Features.SketchFeature sketchFeature1 = ((NXOpen.Features.SketchFeature)workPart.Features.FindObject("SKETCH(490)"));
        features1[0] = feature;
        NXOpen.CurveFeatureRule curveFeatureRule1;
        curveFeatureRule1 = workPart.ScRuleFactory.CreateRuleCurveFeature(features1);
        section1.AllowSelfIntersection(true);
        NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
        rules1[0] = curveFeatureRule1;
        NXOpen.NXObject nullNXOpen_NXObject = null;
        NXOpen.Point3d helpPoint1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
        section1.AddToSection(rules1, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, false);
        NXOpen.Sketch sketch1 = sketch;
        NXOpen.Direction direction1;
        direction1 = workPart.Directions.CreateDirection(sketch1, NXOpen.Sense.Forward, NXOpen.SmartObject.UpdateOption.WithinModeling);
        extrudeBuilder1.Direction = direction1;
        NXOpen.Unit unit2;
        unit2 = extrudeBuilder1.Offset.StartOffset.Units;
        //NXOpen.Expression expression2;
        //expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit2);
        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract;
        NXOpen.Body[] targetBodies3 = new NXOpen.Body[1];
        NXOpen.Body body1 = body;
        targetBodies3[0] = body1;
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies3);
        extrudeBuilder1.ParentFeatureInternal = false;
        NXOpen.Features.Feature feature1;
        feature1 = extrudeBuilder1.CommitFeature();
        NXOpen.Expression expression3 = extrudeBuilder1.Limits.StartExtend.Value;
        NXOpen.Expression expression4 = extrudeBuilder1.Limits.EndExtend.Value;
        extrudeBuilder1.Destroy();
        //workPart.Expressions.Delete(expression2);
        return feature1.Tag;
    }

解决方法是我采用了NXOPEN重新封装了一个方法,然后这些入参都是我试验过的,需要的小伙伴直接拿去用就行了。
实验效果也是达到了我们想要的预期效果,非常nice。

今天要讲的就这么多,我们下篇文章再见。

散会


http://www.ppmy.cn/ops/166452.html

相关文章

Mysql连接---语言连接和图形化界面

语言连接 在已经具备MySQL的基础知识后&#xff0c;需要学习如何进行使用&#xff0c;要用c语言连接mysql&#xff0c;需要使用mysql官网提供的库&#xff0c;用c接口库进行连接。 准备工作&#xff1a; 保证mysql服务有效 在官网上下载合适的mysql connect库 1.安装Connect…

宇树科技再落一子!天羿科技落地深圳,加速机器人创世纪

2025年3月5日&#xff0c;机器人行业龙头宇树科技&#xff08;Unitree&#xff09;在深圳再添新动作——全资子公司深圳天羿科技有限公司正式成立。这家注册资本10万元、法定代表人周昌慧的新公司&#xff0c;聚焦智能机器人研发与销售&#xff0c;标志着宇树科技在华南市场的战…

基于ssm社区报修管理系统(源码+lw+部署文档+讲解),源码可白嫖!

摘要 随着我国经济的高速发展与人们生活水平的日益提高&#xff0c;人们对生活质量的追求也多种多样。尤其在人们生活节奏不断加快的当下&#xff0c;人们更趋向于足不出户解决生活上的问题&#xff0c;线上管理系统展现了其蓬勃生命力和广阔的前景。与此同时&#xff0c;社区…

Android wifi的开关Settings值异常分析

Android wifi的开关Settings值异常分析 文章目录 Android wifi的开关Settings值异常分析一、前言二、异常分析1、adb或者串口获取Settings的wifi开关值2、代码获取wifi开关值3、根据日志分析代码(1)logcat 对应的wifi开启日志的代码①WifiServiceImpl.java② WifiSettingsStore…

精准捕捉各类声音并转换文字的工具

在日常的工作、学习以及娱乐场景中&#xff0c;我们常常有将语音快速转换为文字的需求&#xff0c;比如观看无字幕视频、整理会议录音等。今天要给大家安利一款超实用的软件——TMSpeech。 TMSpeech 是一款完全免费的绿色软件&#xff0c;解压后&#xff0c;只需双击“TMSpeech…

Modbus转换秘籍:力控组态软件的高效应用

Modbus转换秘籍&#xff1a;力控组态软件的高效应用 在工业自动化领域&#xff0c;Modbus协议以其简单、高效的特点被广泛应用。然而&#xff0c;由于不同的历史发展阶段和应用场景&#xff0c;Modbus协议衍生出了多种变种&#xff0c;其中Modbus RTU和Modbus TCP是最为常见的…

如何设置爬虫的延时避免被封禁

在使用爬虫获取数据时&#xff0c;合理设置延时是避免被目标网站封禁的关键策略之一。以下是一些常见的方法和技巧&#xff1a; 一、使用 time.sleep() 设置固定延时 time.sleep() 是 Python 中最常用的延时方法&#xff0c;可以在每次请求之间设置固定的延时&#xff0c;从而…

蓝桥杯15届省C

洛谷P10904挖矿 #include<bits/stdc.h> using namespace std; int n, m; const int N 2000010; int l[N], r[N]; int cnt; int main(){cin >> n >> m;for(int i 1; i < n; i){int x; cin >> x;if(x > 0){r[x];}else if(x < 0){l[-x];}else…