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

server/2025/3/16 23:03:06/

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

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/server/175550.html

相关文章

C 语 言 --- 二 维 数 组 的 应 用

C 语 言 --- 二 维 数 组 的 应 用 第 一 题 - - - 冒 泡 排 序冒 泡 排 序冒 泡 排 序 的 原 理 第 二 题 - - - 回 型 矩 阵特 点 第 三 题 - - - 蛇 形 矩 阵总结 &#x1f4bb;作者简介&#xff1a;曾 与 你 一 样 迷 茫&#xff0c;现 以 经 验 助 你 入 门 C 语 言 &…

RK3588 openssl-3.4.1 编译安装

安装依赖 sudo apt update && sudo apt install build-essential perl libtext-template-perl -y 下载并解压源码 wget https://www.openssl.org/source/openssl-3.4.1.tar.gz tar -xzf openssl-3.4.1.tar.gz && cd openssl-3.4.1 配置编译选项 ./config --…

Node.js 技术原理分析系列5——理解 Node.js 中的 ABI 稳定

Node.js 是一个开源的、跨平台的JavaScript运行时环境&#xff0c;它允许开发者在服务器端运行JavaScript代码。Node.js 是基于Chrome V8引擎构建的&#xff0c;专为高性能、高并发的网络应用而设计&#xff0c;广泛应用于构建服务器端应用程序、网络应用、命令行工具等。 本系…

Python----数据分析(Pandas一:pandas库介绍,pandas操作文件读取和保存)

一、Pandas库 1.1、概念 Pandas是一个开源的、用于数据处理和分析的Python库&#xff0c;特别适合处理表格类数 据。它建立在NumPy数组之上&#xff0c;提供了高效的数据结构和数据分析工具&#xff0c;使得数据操作变得更加简单、便捷和高效。 Pandas 的目标是成为 Python 数据…

【经验分享】SpringBoot集成Websocket开发 之 使用由 Jakarta EE 规范提供的 API开发

在 Spring Boot 中整合、使用 WebSocket WebSocket 是一种基于 TCP 协议的全双工通信协议&#xff0c;它允许客户端和服务器之间建立持久的、双向的通信连接。相比传统的 HTTP 请求 - 响应模式&#xff0c;WebSocket 提供了实时、低延迟的数据传输能力。通过 WebSocket&#x…

React19源码系列之createRoot的执行流程是怎么的?

2024年12月5日&#xff0c;react发布了react19版本。后面一段时间都将学习它的源码&#xff0c;并着手记录。 react官网&#xff1a;react19新特性 https://react.dev/blog/2024/12/05/react-19 在用vite创建react项目的使用&#xff0c;main.tsx主文件都会有以下代码。 //i…

08 | 实现版本号打印功能

提示&#xff1a; 所有体系课见专栏&#xff1a;Go 项目开发极速入门实战课&#xff1b;欢迎加入 云原生 AI 实战 星球&#xff0c;12 高质量体系课、20 高质量实战项目助你在 AI 时代建立技术竞争力&#xff08;聚焦于 Go、云原生、AI Infra&#xff09;&#xff1b;本节课最终…

颠覆语言认知的革命!神经概率语言模型如何突破人类思维边界?

颠覆语言认知的革命&#xff01;神经概率语言模型如何突破人类思维边界&#xff1f; 一、传统模型的世纪困境&#xff1a;当n-gram遇上"月光族难题" 令人震惊的案例&#xff1a;2012年Google语音识别系统将 用户说&#xff1a;“我要还信用卡” 系统识别&#xff…