|
今天在模仿一个例子的时候报错出现这个问题,想问下各位大佬如何解决?
https://blog.csdn.net/hisinwang/article/details/79120655?spm=1001.2014.3001.5502 具体用的是这篇帖子里的第一个例子
ProError UserAssembleByDatums(ProAssembly asm_model,
ProSolid comp_model)
{
ProError err;
ProMatrix identity_matrix = {
{ 1.0, 0.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 } };
ProAsmcomp asmcomp;
ProAsmcompconstraint* constraints;
ProAsmcompconstraint constraint;
ProBoolean interact_flag = PRO_B_FALSE;
ProModelitem asm_datum, comp_datum;
ProSelection asm_sel, comp_sel;
ProAsmcomppath comp_path;
ProIdTable c_id_table;
c_id_table [0] = -1;
// 参考特征名称
ProName asm_datums[3];
ProName comp_datums[3];
ProStringToWstring(asm_datums[0], "ASM_FRONT");
ProStringToWstring(asm_datums[1], "ASM_TOP");
ProStringToWstring(asm_datums[2], "ASM_RIGHT");
ProStringToWstring(comp_datums[0], "FRONT");
ProStringToWstring(comp_datums[1], "TOP");
ProStringToWstring(comp_datums[2], "RIGHT");
// 组装
ProAsmcompAssemble(asm_model, comp_model, identity_matrix, &asmcomp);
// 添加约束
ProArrayAlloc(0, sizeof(ProAsmcompconstraint), 1, (ProArray*)&constraints);
for (int i = 0; i < 3; i++)
{
err = ProModelitemByNameInit(asm_model, PRO_SURFACE, asm_datums, &asm_datum);
if (err != PRO_TK_NO_ERROR)
{
interact_flag = PRO_B_TRUE;
continue;
}
err = ProModelitemByNameInit(comp_model, PRO_SURFACE, comp_datums, &comp_datum);
if (err != PRO_TK_NO_ERROR)
{
interact_flag = PRO_B_TRUE;
continue;
}
// 元件路径
err = ProAsmcomppathInit(asm_model, c_id_table, 0, &comp_path);
// 参考
err = ProSelectionAlloc(&comp_path, &asm_datum, &asm_sel);
err = ProSelectionAlloc(NULL, &comp_datum, &comp_sel);
// 约束
err = ProAsmcompconstraintAlloc(&constraint);
err = ProAsmcompconstraintTypeSet(constraint, PRO_ASM_ALIGN);
err = ProAsmcompconstraintAsmreferenceSet(constraint, asm_sel, PRO_DATUM_SIDE_YELLOW);
err = ProAsmcompconstraintCompreferenceSet(constraint, comp_sel, PRO_DATUM_SIDE_YELLOW);
err = ProArrayObjectAdd((ProArray*)&constraints, -1, 1, &constraint);
}
// 设置元件特征的约束
err = ProAsmcompConstraintsSet(NULL, &asmcomp, constraints);
// 重生
ProSolidRegenerate((ProSolid)asmcomp.owner, PRO_REGEN_CAN_FIX);
if (interact_flag)
{
ProAsmcompConstrRedefUI(&asmcomp);
}
// 释放数组空间
ProArrayFree((ProArray*)&constraints);
return PRO_TK_NO_ERROR;
}
// 测试组装
int TestAssembly001(uiCmdCmdId command,
uiCmdValue *p_value,
void *p_push_command_data)
{
ProError err;
// 获取组立档案:ASM0001.ASM
ProMdl mdlAsm;
err = ProMdlInit(L"ASM0001", PRO_MDL_ASSEMBLY, &mdlAsm);
if (PRO_TK_E_NOT_FOUND == err)
{
MessageBoxW(NULL, L"未打开ASM0001.ASM", L"www.icaxdev.com", MB_OK);
return -1;
}
// 获取要组装的档案RT0001.PRT
ProMdl mdlComp;
err = ProMdlInit(L"RT0001", PRO_MDL_PART, &mdlComp);
if (PRO_TK_E_NOT_FOUND == err)
{
MessageBoxW(NULL, L"未打开PRT0001.PRT", L"www.icaxdev.com", MB_OK);
return -1;
}
// 进行组装
UserAssembleByDatums((ProAssembly)mdlAsm, (ProSolid)mdlComp);
return 0;
} |
|