UG二次开发装配阵列
UF_initialize();
char msg[111];
//定义循环曲线
std::vector<tag_t> lineNum;
Line *line1=NULL;
Line *line2=NULL;
Session *theSession = Session::GetSession();
Part *displayPart(theSession->Parts()->Display());
Part *workPart(theSession->Parts()->Work());
/////链先取方式
//std::vector<TaggedObject*>objects1 = this->selection0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
//line1 = dynamic_cast<Line*>(objects1[0]);
//lineNum.push_back(line1->Tag());
///*Point3d p11(0.0, 0.0, 0.0);*/
//Point3d p12(0.0, 0.0, 0.0);
//Point3d p21(0.0, 0.0, 0.0);
////Point3d p22(0.0, 0.0, 0.0);
//for(int i=0;i<objects1.size()-1;i++)
//{
// for(int j=0;i<objects1.size()-1;j++)
// {
// line2 = dynamic_cast<Line*>(objects1[j]);
// p12=line1->EndPoint();
// p21=line2->StartPoint(); ////p12=p21
// if((p12.X==p21.X)&&(p12.Y==p21.Y)&&(p12.Z==p21.Z))
// {
// NXObject *nullNXObject(NULL);
// MeasureAngleBuilder *measureAngleBuilder1;
// measureAngleBuilder1 = workPart->MeasureManager()->CreateMeasureAngleBuilder(nullNXObject);
// measureAngleBuilder1->Object1()->SetValue(line1);
// measureAngleBuilder1->Object2()->SetValue(line2);
// Unit *nullUnit(NULL);
// MeasureAngle *measureAngle1;
// measureAngle1 = workPart->MeasureManager()->NewAngle(nullUnit, line1, MeasureManager::EndpointTypeStartPoint, line2, MeasureManager::EndpointTypeEndPoint, true, false);
// //Measure *measure1;
// //measure1 = measureAngle1->CreateFeature(); //只需得到值不创建
// double ang1; //单个定义法
// ang1 = measureAngle1->Value(); //获取测量的值
// std::vector<double> ang2; //数组定义法
// ang2.push_back(measureAngle1->Value()); //数组定义法
// sprintf(msg,"%g",ang2[0]); ///sprintf(msg,"%g",ang1);
// uc1601(msg,1);
// delete measureAngle1;
// measureAngleBuilder1->Destroy();
// lineNum.push_back(line2->Tag());
// line1 = line2;
// break;
// }
// }
//}
tag_t num1; //数量1
tag_t num2; //数量2
tag_t dis1; //距离1
tag_t dis2; //距离2
UF_MODL_create_exp_tag("num1=2",&num1); //注意这里参数输入需要以表达式形式
UF_MODL_create_exp_tag("num2=2",&num2); //注意这里参数输入需要以表达式形式
UF_MODL_create_exp_tag("dis1=100",&dis1); //创建表达式
UF_MODL_create_exp_tag("dis2=100",&dis2); //创建表达式
////////////////////////定义参数//////////////////////
UF_ASSEM_mc_array_data_t array_data;
tag_t partTag = 49244;
tag_t directTag1 = 49269; //方向1
tag_t directTag2 = 69278; //方向2
array_data.array_subtype = UF_ASSEM_linear_array; //UF_ASSEM_circular_array
array_data.master_component = partTag;
array_data.template_component = NULL_TAG;
/*tag_t arrayNum[2]={4,NULL};*/
array_data.dimensions[0] = num1;
array_data.dimensions[1] = num2;
//tag_t arrayDirect[2]={69278,NULL};
array_data.axis_definitions[0] = directTag1;
array_data.axis_definitions[1] = directTag2;
array_data.offsets[0] = dis1;
array_data.offsets[1] = dis2;
array_data.array_name = "partname1";
tag_t partArray_tag;
////////////////////////定义参数//////////////////////
UF_ASSEM_create_mc_array(&array_data,&partArray_tag);
//UF_free(array_data.array_name); ///When this value is returned from an enquiry function, it is动态分配时 dynamically allocated, and must be freed with UF_free.这里不需要
UF_terminate();