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

相关文章

MySQL中COALESCE函数示例详解

《MySQL中COALESCE函数示例详解》COALESCE是一个功能强大且常用的SQL函数,主要用来处理NULL值和实现灵活的值选择策略,能够使查询逻辑更清晰、简洁,:本文主要介绍MySQL中C... 目录语法示例1. 替换 NULL 值2. 用于字段默认值3. 多列优先级4. 结合聚合函数注意事项总结C

Win32下C++实现快速获取硬盘分区信息

《Win32下C++实现快速获取硬盘分区信息》这篇文章主要为大家详细介绍了Win32下C++如何实现快速获取硬盘分区信息,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 实现代码CDiskDriveUtils.h#pragma once #include <wtypesbase

Android如何获取当前CPU频率和占用率

《Android如何获取当前CPU频率和占用率》最近在优化App的性能,需要获取当前CPU视频频率和占用率,所以本文小编就来和大家总结一下如何在Android中获取当前CPU频率和占用率吧... 最近在优化 App 的性能,需要获取当前 CPU视频频率和占用率,通过查询资料,大致思路如下:目前没有标准的

Java8需要知道的4个函数式接口简单教程

《Java8需要知道的4个函数式接口简单教程》:本文主要介绍Java8中引入的函数式接口,包括Consumer、Supplier、Predicate和Function,以及它们的用法和特点,文中... 目录什么是函数是接口?Consumer接口定义核心特点注意事项常见用法1.基本用法2.结合andThen链

MySQL 日期时间格式化函数 DATE_FORMAT() 的使用示例详解

《MySQL日期时间格式化函数DATE_FORMAT()的使用示例详解》`DATE_FORMAT()`是MySQL中用于格式化日期时间的函数,本文详细介绍了其语法、格式化字符串的含义以及常见日期... 目录一、DATE_FORMAT()语法二、格式化字符串详解三、常见日期时间格式组合四、业务场景五、总结一、

golang获取prometheus数据(prometheus/client_golang包)

《golang获取prometheus数据(prometheus/client_golang包)》本文主要介绍了使用Go语言的prometheus/client_golang包来获取Prometheu... 目录1. 创建链接1.1 语法1.2 完整示例2. 简单查询2.1 语法2.2 完整示例3. 范围值

golang panic 函数用法示例详解

《golangpanic函数用法示例详解》在Go语言中,panic用于触发不可恢复的错误,终止函数执行并逐层向上触发defer,最终若未被recover捕获,程序会崩溃,recover用于在def... 目录1. panic 的作用2. 基本用法3. recover 的使用规则4. 错误处理建议5. 常见错

javaScript在表单提交时获取表单数据的示例代码

《javaScript在表单提交时获取表单数据的示例代码》本文介绍了五种在JavaScript中获取表单数据的方法:使用FormData对象、手动提取表单数据、使用querySelector获取单个字... 方法 1:使用 FormData 对象FormData 是一个方便的内置对象,用于获取表单中的键值

Python itertools中accumulate函数用法及使用运用详细讲解

《Pythonitertools中accumulate函数用法及使用运用详细讲解》:本文主要介绍Python的itertools库中的accumulate函数,该函数可以计算累积和或通过指定函数... 目录1.1前言:1.2定义:1.3衍生用法:1.3Leetcode的实际运用:总结 1.1前言:本文将详

如何利用Java获取当天的开始和结束时间

《如何利用Java获取当天的开始和结束时间》:本文主要介绍如何使用Java8的LocalDate和LocalDateTime类获取指定日期的开始和结束时间,展示了如何通过这些类进行日期和时间的处... 目录前言1. Java日期时间API概述2. 获取当天的开始和结束时间代码解析运行结果3. 总结前言在J