Skip to main content
18-Opal
May 4, 2018
Solved

Is there a function that loads a list of models?

  • May 4, 2018
  • 1 reply
  • 4617 views

You can use ProSessionMdlList () to get all the objects that exist in the session.


Can I get a list of selected items rather than a list of all the objects that exist in the session?
For example, if prt is selected, only prt is imported; if asm is selected, sub-components are imported.

 

thankㄴ

Best answer by RolandRaytchev

Hi ,

I am not sure if you correctly understand the goal here but will comment so far I understood it.

- if you have a model which is not loaded in session , there is no funciton in Toolkit to found out which models are depended to it.

-the dependencies is mostly in one direction from top -> subassemblies - and components. 

- so when you load a component in session( let sey using ProMdlLoad or ProMdlRetrieve) - Creo parametric will try to load all dependend components which are required for the display in Creo Parametric.

-When you have a model in session you can use the function  ProMdlDependenciesDataList()

The function ProMdlDependenciesDataList() provides an array of ProMdl handles to the models in memory upon which a specified model depends. One model depends on another if its contents reference that model in some way. For example, an assembly depends on the models that form its components, and a drawing model depends on the solid models contained in it. Sometimes, two models can be mutually dependent, such as when a model feature
references a geometry item in a parent assembly. Clean the dependencies in the
database using the function ProMdlDependenciesCleanup() to get an accurate list of dependencies for an object in the Creo Parametric workspace.
Use the function ProMdlDependenciesCleanup() to clean the dependencies for an object in the Creo Parametric workspace.

- you can use the function ProMdlErase()
• ProMdlEraseNotDisplayed()
• ProMdlEraseAll()

To erase model from session.

So for example you can do some test by loading a model then analyses it with the function ProMdlDependenciesDataList() and write the information about the dependencies to a file and remove all files from session. For the next time you will have already outside the session an information about a model and its dependencies.

 

 

1 reply

21-Topaz I
May 4, 2018

Hi ,

I am not sure if you correctly understand the goal here but will comment so far I understood it.

- if you have a model which is not loaded in session , there is no funciton in Toolkit to found out which models are depended to it.

-the dependencies is mostly in one direction from top -> subassemblies - and components. 

- so when you load a component in session( let sey using ProMdlLoad or ProMdlRetrieve) - Creo parametric will try to load all dependend components which are required for the display in Creo Parametric.

-When you have a model in session you can use the function  ProMdlDependenciesDataList()

The function ProMdlDependenciesDataList() provides an array of ProMdl handles to the models in memory upon which a specified model depends. One model depends on another if its contents reference that model in some way. For example, an assembly depends on the models that form its components, and a drawing model depends on the solid models contained in it. Sometimes, two models can be mutually dependent, such as when a model feature
references a geometry item in a parent assembly. Clean the dependencies in the
database using the function ProMdlDependenciesCleanup() to get an accurate list of dependencies for an object in the Creo Parametric workspace.
Use the function ProMdlDependenciesCleanup() to clean the dependencies for an object in the Creo Parametric workspace.

- you can use the function ProMdlErase()
• ProMdlEraseNotDisplayed()
• ProMdlEraseAll()

To erase model from session.

So for example you can do some test by loading a model then analyses it with the function ProMdlDependenciesDataList() and write the information about the dependencies to a file and remove all files from session. For the next time you will have already outside the session an information about a model and its dependencies.

 

 

CHASEONHO18-OpalAuthor
18-Opal
May 17, 2018

@RolandRaytchev

ProMdlDependenciesDataList return one level component

if asemmbly file include another assembly as component file didn't find two level component

iif i select top assembly i want return all components

i can't find that api

any suggestion? 

thanks

21-Topaz I
May 17, 2018

Yes , this is one level api. But remember an assembly is also one level. If you consider  the feature tree. So a component  (ProAsmcomp) is a feature from type  (PRO_FEAT_COMPONENT). So also if you for example visit and assembly in this case to be able to find all copoments and subcomponents in all level -  you need to check the type of the model and if it is itself an assembly (in this case subassembly) you have to visit it recursively . This appraoch belongs to the basis of Pro/TOOLKIT  when we handle some assemlies. Ok there is also the ProAsmcomppath where you can also specify some deph of structure (maximum 25 levels) for some selections and other objects but we can not used it for the search.

So the solution in your case is also simple. You need to do the search recursively which does not required to much addtional code - so the code should be some thing like this below:

...
int checkDependenciesToList(ProMdl mdl , ProMdl **mdllistarray_to_add)
{int deps_counteps_count,iDeps;
 ProMdlfileType *filetypes;
 ProMdlnameShortdata* deps;
 int result;
 ProMdl sub_mdl;

 status = ProMdlDependenciesDataList (mdl, &deps, &filetypes, &deps_count);
 
if (status == PRO_TK_NO_ERROR && deps_count > 0)
 {
 
 for (iDeps = 0; iDeps < deps_count; iDeps ++)
 { //printing some infos
 PTTestSPrintf (path_line, " - %s.%s",
 ProWstringToString (var, deps [iDeps].name),
 		 ProWstringToString (var2, deps [iDeps].type));
 	 PTTestResfileWrite (path_line);
 status= ProMdlnameInit(deps [iDeps].name, filetypes[iDeps], &sub_mdl);	
	//add the model to array
	ProArrayObjectAdd((ProArray*)mdllistarray_to_add, PRO_VALUE_UNUSED, 1, &sub_mdl);	
 if( filetypes[iDeps]== PRO_ASSEMBLY) checkDependenciesToList(sub_mdl , mdllistarray_to_add);
//this is an assembly and need to call recursively checkDependenciesToList } //end of the loop of the models one level ProArrayFree ((ProArray*)&deps); } return PRO_TK_NO_ERROR; } ...

: