[NXOpen C++] UG二次开发,通过CylinderBuilder类,创建一个简单的圆柱

使用UFun函数创建圆柱的方法,请看此篇:https://blog.csdn.net/WangPaiFeiXingYuan/article/details/89508949

说明:通过CylinderBuilder类,创建一个简单的圆柱

测试代码:

//创建圆柱
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace NXOpen;

extern "C" DllExport int ufusr_ask_unload()
{
	return (int)Session::LibraryUnloadOptionImmediately;
}

extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
{
	Session *theSession = Session::GetSession();  //获得会话
	Part *workPart(theSession->Parts()->Work());  //获得工作部件 

	Features::Feature *null_cylinder_feature(NULL);  //定义特征类
	Features::CylinderBuilder *cylinderBulider0;  //CylinderBuilder 定义圆柱创建类
	cylinderBulider0 = workPart->Features()->CreateCylinderBuilder(null_cylinder_feature); //用于创建null_cylinder_feature
	Point3d origin(10,10,10);//定义一个点
	Vector3d vec(0,0,1);//定义一个方向
	cylinderBulider0->SetOrigin(origin);//设置起点
	cylinderBulider0->SetDirection(vec);//设置方向
	cylinderBulider0->Diameter()->SetRightHandSide("10");  //直径10
	cylinderBulider0->Height()->SetRightHandSide("20");    //高度20
	cylinderBulider0->CommitFeature();  //创建特征
	cylinderBulider0->Destroy();    //类销毁
}

效果演示:[NXOpen C++] UG二次开发,通过CylinderBuilder类,创建一个简单的圆柱_第1张图片

你可能感兴趣的:(UG二次开发)