Creo二次开发-Toolkit使用元素树创建特征

1.使用元素数创建基准面-参考面

ProSelection* ref_surf;
ProReference reference;
int nsel = -1,offset_value=100;
status = ProSelect("surface", 1, NULL, NULL, NULL, NULL, &ref_surf, &nsel);

ProElement elem_tree,elem_type,elem_consts,elem_const,elem_const_type,elem_const_ref,elem_const_offest;
status = ProElementAlloc(PRO_E_FEATURE_TREE, &elem_tree);
status = ProElementAlloc(PRO_E_FEATURE_TYPE, &elem_type);
status = ProElementAlloc(PRO_E_DTMPLN_CONSTRAINTS, &elem_consts);
status = ProElementAlloc(PRO_E_DTMPLN_CONSTRAINT, &elem_const);
status = ProElementAlloc(PRO_E_DTMPLN_CONSTR_TYPE, &elem_const_type);
status = ProElementAlloc(PRO_E_DTMPLN_CONSTR_REF, &elem_const_ref);
status = ProElementAlloc(PRO_E_DTMPLN_CONSTR_REF_OFFSET, &elem_const_offest);

status = ProElementIntegerSet(elem_type, PRO_FEAT_DATUM);
status = ProElementIntegerSet(elem_const_type, PRO_DTMPLN_OFFS);
status = ProSelectionToReference(ref_surf[0], &reference);
status = ProElementReferenceSet(elem_const_ref, reference);
status = ProElementDecimalsSet(elem_const_offest, 3);
status = ProElementDoubleSet(elem_const_offest, offset_value);

status = ProElemtreeElementAdd(elem_tree, NULL, elem_type);
status = ProElemtreeElementAdd(elem_tree, NULL, elem_consts);
status = ProElemtreeElementAdd(elem_consts, NULL, elem_const);
status = ProElemtreeElementAdd(elem_const,NULL, elem_const_type);
status = ProElemtreeElementAdd(elem_const, NULL, elem_const_ref);
status = ProElemtreeElementAdd(elem_const, NULL, elem_const_offest);

ProAsmcomppath path;
ProModelitem item;
ProSelection mdl_sel;
ProSelectionAsmcomppathGet(ref_surf[0], &path);
ProMdlToModelitem(path.owner, &item);
status = ProSelectionAlloc(NULL, &item, &mdl_sel);

ProFeatureCreateOptions *opts=0;
ProFeature feature;
ProErrorlist errors;

status = ProArrayAlloc(1, sizeof(ProFeatureCreateOptions), 1, (ProArray*)&opts);
status = ProFeatureWithoptionsCreate(mdl_sel, elem_tree, opts, PRO_REGEN_NO_FLAGS, &feature, &errors);

2.使用元素树创建坐标系-参考3个基准面

ProElement elem_tree, elem_type,elem_name, elem_constrs, elem_constr1, elem_constr2, elem_constr3, elem_constr_ref1
	,elem_constr_ref2, elem_constr_ref3;
status = ProElementAlloc(PRO_E_FEATURE_TREE, &elem_tree);
status = ProElementAlloc(PRO_E_FEATURE_TYPE, &elem_type);
status = ProElementAlloc(PRO_E_STD_FEATURE_NAME, &elem_name);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTRS, &elem_constrs);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR, &elem_constr1);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR, &elem_constr2);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR, &elem_constr3);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR_REF, &elem_constr_ref1);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR_REF, &elem_constr_ref2);
status = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR_REF, &elem_constr_ref3);

status = ProElementIntegerSet(elem_type, PRO_FEAT_CSYS);
status = ProElementWstringSet(elem_name, L"MY_CS0");

ProSelection* sels;
ProReference ref1,ref2,ref3;
int n_sel;
status = ProSelect("surface", 3, NULL, NULL, NULL, NULL, &sels, &n_sel);
if (status != PRO_TK_NO_ERROR) {
	return;
}
status = ProSelectionToReference(sels[0], &ref1);
status = ProSelectionToReference(sels[1], &ref2);
status = ProSelectionToReference(sels[2], &ref3);

status = ProElementReferenceSet(elem_constr_ref1, ref1);
status = ProElementReferenceSet(elem_constr_ref2, ref2);
status = ProElementReferenceSet(elem_constr_ref3, ref3);

status = ProElemtreeElementAdd(elem_constr1, NULL, elem_constr_ref1);
status = ProElemtreeElementAdd(elem_constr2, NULL, elem_constr_ref2);
status = ProElemtreeElementAdd(elem_constr3, NULL, elem_constr_ref3);


ProElement* constrs;
ProArrayAlloc(0, sizeof(ProElement), 3, (ProArray*)&constrs);
status = ProArrayObjectAdd((ProArray*)(&constrs), PRO_VALUE_UNUSED, 1, &elem_constr1);
status = ProArrayObjectAdd((ProArray*)(&constrs), PRO_VALUE_UNUSED, 1, &elem_constr2);
status = ProArrayObjectAdd((ProArray*)(&constrs), PRO_VALUE_UNUSED, 1, &elem_constr3);
status = ProElementArraySet(elem_constrs, NULL, constrs);

status = ProElemtreeElementAdd(elem_tree, NULL, elem_type);
status = ProElemtreeElementAdd(elem_tree, NULL, elem_name);
status = ProElemtreeElementAdd(elem_tree, NULL, elem_constrs);

ProAsmcomppath path;
ProModelitem item;
ProSelection mdl_sel;
ProSelectionAsmcomppathGet(sels[0], &path);
ProMdlToModelitem(path.owner, &item);
status = ProSelectionAlloc(NULL, &item, &mdl_sel);

ProFeatureCreateOptions* opts = 0;
ProFeature feature;
ProErrorlist errors;

status = ProArrayAlloc(1, sizeof(ProFeatureCreateOptions), 1, (ProArray*)&opts);
status = ProFeatureWithoptionsCreate(mdl_sel, elem_tree, opts, PRO_REGEN_NO_FLAGS, &feature, &errors);

3.使用元素树创建坐标系-参考点

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值