I would like to hide and show automatically the parts of a model using Pro/Toolkit. I don't want to have the user clicking to select them.
In fact I have an array of solids that are in my model : ProSolid* solidList; I can also have access to the asm component path of each part.
I saw the function ProModelitemUnhide and ProModelitemHide but, if I understood well, in order to use it I have to have the modelitem of my parts...
How do I get the modelitem of a part?
How can I hide/show parts?
Oops, In fact I have solids :
here is what I do considering the fat that solid is a ProSolid I already have :
err = ProMdlToModelitem(solid, &model_item);
if(err != PRO_TK_NO_ERROR)
printf("error %i in ProMdlToModelitem .\n",err);
err = ProModelitemHide(&model_item);
if(err != PRO_TK_NO_ERROR)
printf("error %i in ProModelitemHide.\n",err);
ProWindowRefresh (-1); //-1 pour current window
but then I get error -18 (means PRO_TK_INVALID_TYPE) in ProModelitemHide...
In fact I only manage to hide /show something when this thing is a feature.
But this is going to "low" in the hierarchy for me because I don't want to hide/show lines used for the drawing, I only want the pieces of part..
Do you have any idea?
In case someone is interested in this :
Here is what I finally do :
I visit the displayed solids with ProSolidDispCompVisit.
In the ProSolidDispCompVisitAction I visit all the features of the solids that are an assembly with ProSolidFeatVisit. This will visit all the parts, assembly but also lines and I only want features that are assembly or parts so I use
err = ProMdlTypeGet(Mdl, &MdlType);
in order to know what this feature is (thank you Lars 🙂 )
And then I can hide show this feature with
I have a problem about the function ProModelitemHide
but the function ProModelitemHide STILL return 'PRO_TK_INVALID_TYPE'
i dont know how to slove it, is there anyone can help me?
I think here the problem is that only particular modelitems could used to be hidden.
So you can convert a part to modelitem but I think the idea here is to be used for some parameter stuff - because it use a modelitem as input.
Here we need to take the component feature which contains the model and to hide it.
... err=ProModelitemHide((ProModelitem *) &comp_feature); ...
So the question is how to get a component feature which corresponds to a model handle:
- you have visit the assembly (ProSolidFeatVisit)and in the filter function you have to check for (ProFeatType.h
cast the feature to ProAsmcomp and use ProAsmcompMdlMdlnameGet to get the name of the component and compare the name with the name of the model (ProMdlNameGet)
I pointed to the old way using the ProSolidFeatVisit...
currently is the function ProSolidDispCompVisit - advantage here is that you do not need a filter which should check if it is a component feature and second if it is visible or not (ProFeatureVisibilityGet)
So when you call this function for the assembly (respectively recursively if you have more then one level deep - means subassemblies) then you can use the ProSolidDispCompVisit/FilterAction) so to have a handle of solid where you can take the name to compare. What is here more difficult you have an ProAsmcomppath where you have to constuct the component feature handle. If the assembly is flat - means no subassemblies - in this case you need to use p_path->owner and p_path->comp_id_table
So some think like:
ProFeatureInit(p_path->owner , p_path->comp_id_table,&comp_feature);
But if you have a subassembly - in this case to init the feature from the subassembly - you need to past the subassembly model handle as ProAppData to the ProSolidDispCompVisit (in the recursive call) funciton and then construct the handle - some thing like:
ProFeatureInit((ProMdl) app_data , p_path->comp_id_table[p_path->table_num-1],&comp_feature);
Therefore I think the more easy approach here is to use the ProSolidFeatVisit because you have in the visit funcion a feature handle!