NX二开ufun函数UF_MODL_ask_bounding_box(获取边界坐标)

2023-10-27 21:10

本文主要是介绍NX二开ufun函数UF_MODL_ask_bounding_box(获取边界坐标),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

这个函数用来返回线框和实体类型对象的边界框。
线框对象包括直线,圆弧,样条曲线和圆锥曲线。实体类型对象包括实体 ,面和边。

返回结果如下图,分别返回了曲线和一个block的边界信息:

1、函数结构: 

int UF_MODL_ask_bounding_box (tag_t obj_tag,double bounding_box [6])

2、概述

返回线框和实体类型对象的边界框。 
线框对象包括直线,圆弧,样条曲线和圆锥曲线。实体类型对象包括实体 ,面和边。
根据零件文件中对象的位置,以绝对坐标值返回 边界框值 。

3、实例源码

1)C# 实例源码

using System;
using NXOpen;
using NXOpen.UF;
using NXOpen.Features;public class Program
{// class memberspublic static Session theSession;public static NXOpen.UF.UFSession theUFSession;private static UI theUI = null;public static Part workPart;public static int Main(string[] args){theSession = Session.GetSession();theUFSession = UFSession.GetUFSession();theUI = UI.GetUI();workPart = theSession.Parts.Work;int retValue = 0;try{Tag arc, wcs;UFCurve.Arc arc_coords = new UFCurve.Arc();arc_coords.start_angle = 0.0;arc_coords.end_angle = 3.0;arc_coords.arc_center = new double[3];arc_coords.arc_center[0] = 0.0;arc_coords.arc_center[1] = 0.0;arc_coords.arc_center[2] = 1.0;arc_coords.radius = 2.0;theUFSession.Csys.AskWcs(out wcs);theUFSession.Csys.AskMatrixOfObject(wcs, out arc_coords.matrix_tag);theUFSession.Curve.CreateArc(ref arc_coords, out arc);FeatureSigns sign = 0;double[] corner = new double[3]{0.0, 0.0, 0.0};string[] edgeLen = new string[3] {"100","80","50"};Tag blockTag = Tag.Null;theUFSession.Modl.CreateBlock1(sign, corner, edgeLen, out blockTag);Tag blockBodyTag = Tag.Null;theUFSession.Modl.AskFeatBody(blockTag, out blockBodyTag);double[] boxArc = new double[6];theUFSession.Modl.AskBoundingBox(arc, boxArc);double[] boxBlock = new double[6];theUFSession.Modl.AskBoundingBox(blockBodyTag, boxBlock);}catch (NXOpen.NXException ex){theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());}return retValue;}
}

2)C++实例源码

#include <stdio.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_csys.h>
#include <uf_defs.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{if (irc){char    messg[133];printf("%s, line %d:  %s\n", file, line, call);(UF_get_fail_message(irc, messg)) ?printf("    returned a %d\n", irc) :printf("    returned error %d:  %s\n", irc, messg);}return(irc);
}
static void do_ugopen_api(void)
{char *part_name = "bound";tag_t part, arc_id, wcs_tag;double box[6];UF_CURVE_arc_t arc_coords;/* Fill out the data structure */arc_coords.start_angle = 0.0;arc_coords.end_angle = 270.0 * DEGRA;arc_coords.arc_center[0] = 0.0;arc_coords.arc_center[1] = 0.0;arc_coords.arc_center[2] = 1.0;arc_coords.radius = 2.0;UF_PART_new(part_name, UF_PART_ENGLISH, &part);UF_CSYS_ask_wcs( &wcs_tag );UF_CSYS_ask_matrix_of_object( wcs_tag,&arc_coords.matrix_tag );/* Create arc */UF_CURVE_create_arc(&arc_coords,&arc_id);/* Ask bounding box of arc */UF_MODL_ask_bounding_box(arc_id,box);/* Print bounding box values */printf("\nMinimum x value: %f\n", box[0]);printf("Maximum x value: %f\n", box[3]);printf("Minimum y value: %f\n", box[1]);printf("Maximum y value: %f\n", box[4]);printf("Minimum z value: %f\n", box[2]);printf("Maximum z value: %f\n", box[5]);
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{if (!UF_CALL(UF_initialize())){do_ugopen_api();UF_CALL(UF_terminate());}
}
int ufusr_ask_unload(void)
{return (UF_UNLOAD_IMMEDIATELY);
}

这篇关于NX二开ufun函数UF_MODL_ask_bounding_box(获取边界坐标)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/288408

相关文章

Python版本信息获取方法详解与实战

《Python版本信息获取方法详解与实战》在Python开发中,获取Python版本号是调试、兼容性检查和版本控制的重要基础操作,本文详细介绍了如何使用sys和platform模块获取Python的主... 目录1. python版本号获取基础2. 使用sys模块获取版本信息2.1 sys模块概述2.1.1

Python函数作用域与闭包举例深度解析

《Python函数作用域与闭包举例深度解析》Python函数的作用域规则和闭包是编程中的关键概念,它们决定了变量的访问和生命周期,:本文主要介绍Python函数作用域与闭包的相关资料,文中通过代码... 目录1. 基础作用域访问示例1:访问全局变量示例2:访问外层函数变量2. 闭包基础示例3:简单闭包示例4

Python中isinstance()函数原理解释及详细用法示例

《Python中isinstance()函数原理解释及详细用法示例》isinstance()是Python内置的一个非常有用的函数,用于检查一个对象是否属于指定的类型或类型元组中的某一个类型,它是Py... 目录python中isinstance()函数原理解释及详细用法指南一、isinstance()函数

python中的高阶函数示例详解

《python中的高阶函数示例详解》在Python中,高阶函数是指接受函数作为参数或返回函数作为结果的函数,下面:本文主要介绍python中高阶函数的相关资料,文中通过代码介绍的非常详细,需要的朋... 目录1.定义2.map函数3.filter函数4.reduce函数5.sorted函数6.自定义高阶函数

Java发送SNMP至交换机获取交换机状态实现方式

《Java发送SNMP至交换机获取交换机状态实现方式》文章介绍使用SNMP4J库(2.7.0)通过RCF1213-MIB协议获取交换机单/多路状态,需开启SNMP支持,重点对比SNMPv1、v2c、v... 目录交换机协议SNMP库获取交换机单路状态获取交换机多路状态总结交换机协议这里使用的交换机协议为常

Python中的sort方法、sorted函数与lambda表达式及用法详解

《Python中的sort方法、sorted函数与lambda表达式及用法详解》文章对比了Python中list.sort()与sorted()函数的区别,指出sort()原地排序返回None,sor... 目录1. sort()方法1.1 sort()方法1.2 基本语法和参数A. reverse参数B.

MyBatis/MyBatis-Plus同事务循环调用存储过程获取主键重复问题分析及解决

《MyBatis/MyBatis-Plus同事务循环调用存储过程获取主键重复问题分析及解决》MyBatis默认开启一级缓存,同一事务中循环调用查询方法时会重复使用缓存数据,导致获取的序列主键值均为1,... 目录问题原因解决办法如果是存储过程总结问题myBATis有如下代码获取序列作为主键IdMappe

C#使用iText获取PDF的trailer数据的代码示例

《C#使用iText获取PDF的trailer数据的代码示例》开发程序debug的时候,看到了PDF有个trailer数据,挺有意思,于是考虑用代码把它读出来,那么就用到我们常用的iText框架了,所... 目录引言iText 核心概念C# 代码示例步骤 1: 确保已安装 iText步骤 2: C# 代码程

Spring Boot中获取IOC容器的多种方式

《SpringBoot中获取IOC容器的多种方式》本文主要介绍了SpringBoot中获取IOC容器的多种方式,包括直接注入、实现ApplicationContextAware接口、通过Spring... 目录1. 直接注入ApplicationContext2. 实现ApplicationContextA

Python函数的基本用法、返回值特性、全局变量修改及异常处理技巧

《Python函数的基本用法、返回值特性、全局变量修改及异常处理技巧》本文将通过实际代码示例,深入讲解Python函数的基本用法、返回值特性、全局变量修改以及异常处理技巧,感兴趣的朋友跟随小编一起看看... 目录一、python函数定义与调用1.1 基本函数定义1.2 函数调用二、函数返回值详解2.1 有返