Solved
How to get all the child elements of a model
- May 23, 2018
- 1 reply
- 3803 views
Attach the used model and code.
If the subelement of the model is an assembly, you want to recursively call the function to perform a specific task.
Levels 1 and 2 work safely.

At level 3 or higher, the function is infinite.

UgAsmCompVisit_c does not help me.
It is not appropriate for us to fetch information from the session model.(ProSessionMdlList)
Therefore, ProSelect attempts to visit the sub-elements of the selected model.
Help.. plz...
ProError checkDependenciesToList(ProMdl mdl , char name[80], char value[80]) //저장된 mdllistarray_to_add의 &주소값을 읽는다
{
ProError status;
int deps_counteps_count,iDeps=0,deps_count;
ProModel* deps;
ProModelitem mdlitem;
int result;
ProMdl sub_mdl;
char var[80],var2[10],tr[80],tr2[80],c_name_[80];
ProParamvalue pval;
ProParameter param;
wchar_t p_value[80];
ProName p_name,mdl_name;
strcpy(tr, name);
strcpy(tr2, value);
//ProWstringToString(var,name);
ProStringToWstring(p_value,value);
ProStringToWstring(p_name,name);
status = ProParamvalueSet(&pval,p_value,PRO_PARAM_STRING);
ProMdlNameGet(mdl,mdl_name);
ProWstringToString(c_name_,mdl_name);
TestDialog(c_name_);
status = ProMdlDependenciesList (mdl, &deps, &deps_count);
if (status == PRO_TK_NO_ERROR && deps_count > 0)
{
for (iDeps = 0; iDeps < deps_count; iDeps++)
{
ProWstringToString(var2 , deps[iDeps].type);
if(!strcmp(var2,"PRT"))
{
status = ProMdlInit(deps [iDeps].name, PRO_MDL_PART, &sub_mdl);
status = ProMdlToModelitem(sub_mdl,&mdlitem);
status = ProParameterCreate(&mdlitem,p_name,&pval,¶m);
}
else if(!strcmp(var2,"ASM"))
{
status = ProMdlInit(deps [iDeps].name, PRO_MDL_ASSEMBLY, &sub_mdl);
status = ProMdlToModelitem(sub_mdl,&mdlitem);
status = ProParameterCreate(&mdlitem,p_name,&pval,¶m);
status = ProModelitemMdlGet(&mdlitem, &sub_mdl);
checkDependenciesToList(sub_mdl ,tr,tr2);
}
}
}
return 0;
}
ProError Test()
{
ProMdl *mdl_arr,mdl;
ProModelitem mdlitem;
ProSelection *proselect;
ProError status;
ProName name;
ProParamvalue pval;
ProParameter param;
int selectcount, mdl_arr_size;
char c_name[80],c_value[80];
wchar_t value[80];
status = ProSelect("prt_or_asm",1,NULL,NULL,NULL,NULL,&proselect,&selectcount);
if(status == PRO_TK_NO_ERROR)
{
status = ProSelectionModelitemGet(proselect[0],&mdlitem);
status = ProModelitemMdlGet(&mdlitem, &mdl);
ProMessageDisplay(MSGFIL, (char *)"USER %0s", (char *)"Enter the parameter name: " );
ProMessageStringRead(32,name);
ProMessageDisplay(MSGFIL, (char *)"USER %0s", (char *)"Enter the parameter value: " );
ProMessageStringRead(32,value);
ProWstringToString(c_name, name);
ProWstringToString(c_value, value);
status = ProParamvalueSet(&pval,value,PRO_PARAM_STRING);
status = ProParameterCreate(&mdlitem,name,&pval,¶m);
checkDependenciesToList(mdl,c_name, c_value);
/*
ProArraySizeGet((ProArray*)mdl_arr,&mdl_arr_size);
itoa(mdl_arr_size,c,10);
TestDialog(c);
*/
TestDialog("Done");
}
}
