通过 Creo Parametric TOOLKIT 使用三个平面创建坐标系
参考以下示例代码:ProElement csysFeatTree;
proErr = ProElementAlloc(PRO_E_FEATURE_TREE, &csysFeatTree);
//PRO_E_FEATURE_TYPE
ProElement featureTypeElem;
proErr = ProElementAlloc(PRO_E_FEATURE_TYPE, &featureTypeElem);
proErr = ProElementIntegerSet(featureTypeElem, PRO_FEAT_CSYS);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, featureTypeElem);
//PRO_E_STD_FEATURE_NAME
ProElement featureNameElem;
proErr = ProElementAlloc(PRO_E_STD_FEATURE_NAME, &featureNameElem);
proErr = ProElementWstringSet(featureNameElem, L"TEST_CSYS");
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, featureNameElem);
//PRO_E_CSYS_ORIGIN_CONSTRS
ProElement csysOriginConstrsElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTRS, &csysOriginConstrsElem);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOriginConstrsElem);
//PRO_E_CSYS_ORIGIN_CONSTRS
//|--PRO_E_CSYS_ORIGIN_CONSTR
ProElement csysOriginConstrElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR, &csysOriginConstrElem);
proErr = ProElemtreeElementAdd(csysOriginConstrsElem, NULL, csysOriginConstrElem);
//PRO_E_CSYS_ORIGIN_CONSTRS
//|--PRO_E_CSYS_ORIGIN_CONSTR
// |--PRO_E_CSYS_ORIGIN_CONSTR_REF
ProElement csysOriginConstrRefElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIGIN_CONSTR_REF, &csysOriginConstrRefElem);
ProSelection *sels = NULL;
int nSels = 0;
proErr = ProSelect(
"datum",
1,
NULL,
NULL,
NULL,
NULL,
&sels,
&nSels);
if (nSels < 1)
{
return proErr;
}
ProReference csysOriginConstrRef;
proErr = ProSelectionToReference(sels, &csysOriginConstrRef);
proErr = ProElementReferenceSet(csysOriginConstrRefElem, csysOriginConstrRef);
proErr = ProElemtreeElementAdd(csysOriginConstrElem, NULL, csysOriginConstrRefElem);
//PRO_E_CSYS_OFFSET_TYPE
ProElement csysOffsetTypeElem;
proErr = ProElementAlloc(PRO_E_CSYS_OFFSET_TYPE, &csysOffsetTypeElem);
proErr = ProElementIntegerSet(csysOffsetTypeElem, PRO_CSYS_OFFSET_CARTESIAN);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOffsetTypeElem);
//PRO_E_CSYS_ONSURF_TYPE
ProElement csysOnsurfTypeElem;
proErr = ProElementAlloc(PRO_E_CSYS_ONSURF_TYPE, &csysOnsurfTypeElem);
proErr = ProElementIntegerSet(csysOnsurfTypeElem, PRO_CSYS_ONSURF_LINEAR);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOnsurfTypeElem);
//PRO_E_CSYS_DIM_CONSTRS
ProElement csysDimConstrsElem;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTRS, &csysDimConstrsElem);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysDimConstrsElem);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
ProElement csysDimConstrElem1;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR, &csysDimConstrElem1);
proErr = ProElemtreeElementAdd(csysDimConstrsElem, NULL, csysDimConstrElem1);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
// |--PRO_E_CSYS_DIM_CONSTR_REF
ProElement csysDimConstrRefElem1;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR_REF, &csysDimConstrRefElem1);
proErr = ProSelect(
"datum",
1,
NULL,
NULL,
NULL,
NULL,
&sels,
&nSels);
if (nSels < 1)
{
return proErr;
}
ProReference csysDimConstrRef1;
proErr = ProSelectionToReference(sels, &csysDimConstrRef1);
proErr = ProElementReferenceSet(csysDimConstrRefElem1, csysDimConstrRef1);
proErr = ProElemtreeElementAdd(csysDimConstrElem1, NULL, csysDimConstrRefElem1);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
// |--PRO_E_CSYS_DIM_CONSTR_TYPE
ProElement csysDimConstrTypeElem1;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR_TYPE, &csysDimConstrTypeElem1);
proErr = ProElementIntegerSet(csysDimConstrTypeElem1, PRO_CSYS_DIM_CONSTR_TYPE_OFFSET);
proErr = ProElemtreeElementAdd(csysDimConstrElem1, NULL, csysDimConstrTypeElem1);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
// |--PRO_E_CSYS_DIM_CONSTR_VAL
ProElement csysDimConstrValElem1;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR_VAL, &csysDimConstrValElem1);
proErr = ProElementDoubleSet(csysDimConstrValElem1, -100.0);
proErr = ProElemtreeElementAdd(csysDimConstrElem1, NULL, csysDimConstrValElem1);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
ProElement csysDimConstrElem2;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR, &csysDimConstrElem2);
proErr = ProElemtreeElementAdd(csysDimConstrsElem, NULL, csysDimConstrElem2);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
// |--PRO_E_CSYS_DIM_CONSTR_REF
ProElement csysDimConstrRefElem2;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR_REF, &csysDimConstrRefElem2);
proErr = ProSelect(
"datum",
1,
NULL,
NULL,
NULL,
NULL,
&sels,
&nSels);
if (nSels < 1)
{
return proErr;
}
ProReference csysDimConstrRef2;
proErr = ProSelectionToReference(sels, &csysDimConstrRef2);
proErr = ProElementReferenceSet(csysDimConstrRefElem2, csysDimConstrRef2);
proErr = ProElemtreeElementAdd(csysDimConstrElem2, NULL, csysDimConstrRefElem2);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
// |--PRO_E_CSYS_DIM_CONSTR_TYPE
ProElement csysDimConstrTypeElem2;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR_TYPE, &csysDimConstrTypeElem2);
proErr = ProElementIntegerSet(csysDimConstrTypeElem2, PRO_CSYS_DIM_CONSTR_TYPE_OFFSET);
proErr = ProElemtreeElementAdd(csysDimConstrElem2, NULL, csysDimConstrTypeElem2);
//PRO_E_CSYS_DIM_CONSTRS
//|--PRO_E_CSYS_DIM_CONSTR
// |--PRO_E_CSYS_DIM_CONSTR_VAL
ProElement csysDimConstrValElem2;
proErr = ProElementAlloc(PRO_E_CSYS_DIM_CONSTR_VAL, &csysDimConstrValElem2);
proErr = ProElementDoubleSet(csysDimConstrValElem2, 200.0);
proErr = ProElemtreeElementAdd(csysDimConstrElem2, NULL, csysDimConstrValElem2);
//PRO_E_CSYS_NORMAL_TO_SCREEN
ProElement csysNormalToScreenElem;
proErr = ProElementAlloc(PRO_E_CSYS_NORMAL_TO_SCREEN, &csysNormalToScreenElem);
proErr = ProElementIntegerSet(csysNormalToScreenElem, PRO_CSYS_ORIENTMOVES_NRMSCRN_NO);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysNormalToScreenElem);
//PRO_E_CSYS_ORIENT_BY_METHOD
ProElement csysOrientByMethodElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENT_BY_METHOD, &csysOrientByMethodElem);
proErr = ProElementIntegerSet(csysOrientByMethodElem, PRO_CSYS_ORIENT_BY_SEL_REFS);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientByMethodElem);
//PRO_E_CSYS_ORIENTSELAXIS1_REF
ProElement csysOrientSelAxis1RefElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS1_REF, &csysOrientSelAxis1RefElem);
proErr = ProElementReferenceSet(csysOrientSelAxis1RefElem, csysOriginConstrRef);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis1RefElem);
//PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT
ProElement csysOrientSelAxis1RefOptElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS1_REF_OPT, &csysOrientSelAxis1RefOptElem);
proErr = ProElementIntegerSet(csysOrientSelAxis1RefOptElem, PRO_CSYS_DIRCSYSREF_OPT_ORIGIN);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis1RefOptElem);
//PRO_E_CSYS_ORIENTSELAXIS1_OPT
ProElement csysOrientSelAxis1OptElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS1_OPT, &csysOrientSelAxis1OptElem);
proErr = ProElementIntegerSet(csysOrientSelAxis1OptElem, PRO_CSYS_ORIENTMOVE_AXIS_OPT_Z);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis1OptElem);
//PRO_E_CSYS_ORIENTSELAXIS1_FLIP
ProElement csysOrientSelAxis1FlipElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS1_FLIP, &csysOrientSelAxis1FlipElem);
proErr = ProElementIntegerSet(csysOrientSelAxis1FlipElem, PRO_CSYS_ORIENTSELAXIS_FLIP_NO);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis1FlipElem);
//PRO_E_CSYS_ORIENTSELAXIS2_REF
ProElement csysOrientSelAxis2RefElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS2_REF, &csysOrientSelAxis2RefElem);
proErr = ProElementReferenceSet(csysOrientSelAxis2RefElem, csysDimConstrRef1);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis2RefElem);
//PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT
ProElement csysOrientSelAxis2RefOptElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS2_REF_OPT, &csysOrientSelAxis2RefOptElem);
proErr = ProElementIntegerSet(csysOrientSelAxis2RefOptElem, PRO_CSYS_DIRCSYSREF_OPT_ORIGIN);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis2RefOptElem);
//PRO_E_CSYS_ORIENTSELAXIS2_OPT
ProElement csysOrientSelAxis2OptElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS2_OPT, &csysOrientSelAxis2OptElem);
proErr = ProElementIntegerSet(csysOrientSelAxis2OptElem, PRO_CSYS_ORIENTMOVE_AXIS_OPT_X);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis2OptElem);
//PRO_E_CSYS_ORIENTSELAXIS2_FLIP
ProElement csysOrientSelAxis2FlipElem;
proErr = ProElementAlloc(PRO_E_CSYS_ORIENTSELAXIS2_FLIP, &csysOrientSelAxis2FlipElem);
proErr = ProElementIntegerSet(csysOrientSelAxis2FlipElem, PRO_CSYS_ORIENTSELAXIS_FLIP_NO);
proErr = ProElemtreeElementAdd(csysFeatTree, NULL, csysOrientSelAxis2FlipElem);
ProMdl curMdl;
proErr = ProMdlCurrentGet(&curMdl);
ProModelitem curMdlModelItem;
proErr = ProMdlToModelitem(curMdl, &curMdlModelItem);
ProSelection curMdlSel;
proErr = ProSelectionAlloc(NULL, &curMdlModelItem, &curMdlSel);
ProFeatureCreateOptions *featCreationOpts = NULL;
proErr = ProArrayAlloc(1, sizeof(ProFeatureCreateOptions), 1, reinterpret_cast<ProArray *>(&featCreationOpts));
featCreationOpts = PRO_FEAT_CR_NO_OPTS;
ProErrorlist errorList;
ProFeature csysFeature;
proErr = ProFeatureWithoptionsCreate(
curMdlSel,
csysFeatTree,
featCreationOpts,
PRO_REGEN_NO_FLAGS,
&csysFeature,
&errorList);部分代码回复可见
**** Hidden Message *****
6666666。这是C语言? 大师兄 发表于 2017-5-27 12:39
6666666。这是C语言?
:lol 大师兄 发表于 2017-5-27 12:39
6666666。这是C语言?
大师兄一直都在研究二次开发? Yangss 发表于 2017-5-27 15:26
大师兄一直都在研究二次开发?
没研究,编程略懂。 好东西,谢谢分享。 谢谢分享。 呵呵。看看。。。。。。
好东西,谢谢分享 谢谢楼主分享