前言
本系列文章主要讲解NXOpen UF API(简称ufun函数)的使用,之前看教学视频大都建议用ufun进行开发,这里西门子官方还专门给了一套系列文章来讲,说明官方也是特别推崇ufun。
本人从事二开也有一段时间了,我的二开启蒙师父就特别喜欢用NXOpen API,用他的话来说“年少不知nxopen好,错把ufun当成宝”,其实就我个人而言,还是喜欢NXOPEN+ufun联合开发。
一、小节概要
本实例实现了长方体边倒圆,主要知识点如下:
1、创建长方体 theUfSession.Modl.CreateBlock1
2、边倒圆 theUfSession.Modl.CreateBlend
二、需求分析
1、效果图
2、需求分解
1、创建长方体
2、创建边倒圆
三、程序分析
1、源码所在目录
UGOPEN\SampleNXOpenApplications\.NET\NXOpenExamples\EX_Modl_CreateBlend
2、主要功能分析
1、创建长方体
Tag block_feature_tag;
string[] edge_lengths = { "1.0", "2.0", "3.0" };
theUfSession.Assem.SetWorkPart(UFPart);
corner_point[0] = 0.0;
corner_point[1] = 0.0;
corner_point[2] = 0.0;
theUfSession.Modl.CreateBlock1(FeatureSigns.Nullsign, corner_point, edge_lengths, out block_feature_tag );
2、创建边倒圆
ArrayList arr_list2 = new ArrayList();
for(int i=0; i < ecount; i++)
{
Tag edge; /* edge object */
int vcount; /* count of vertices in edge */
/* Get the edge (list item) and check return code. */
theUfSession.Modl.AskListItem(list1,i,out edge);
/* Get the edge vertices. Check return code. */
theUfSession.Modl.AskEdgeVerts(edge,pt1, pt2, out vcount);
if(System.Math.Abs(System.Math.Abs(pt1[2] - pt2[2]) - 3.0) < 0.001)
{
arr_list2.Add(edge);
}
}
list2 = (Tag [])arr_list2.ToArray(typeof(Tag));
theUfSession.Modl.CreateBlend("0.009246", list2, allow_smooth, allow_cliff, allow_notch, vrb_tol, out blend1);