这个函数用来返回线框和实体类型对象的边界框。
线框对象包括直线,圆弧,样条曲线和圆锥曲线。实体类型对象包括实体 ,面和边。
返回结果如下图,分别返回了曲线和一个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 members
public 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);
}