cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Hide and show parts

Emilie
1-Newbie

Hide and show parts

Hello All,

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?

or

How can I hide/show parts?

Thank you

Emilie

11 REPLIES 11
LarsZiegler
5-Regular Member
(To:Emilie)

Hello!

Use the function ProMdlToModelitem to get a Modelitem from a Model.

earnal
1-Newbie
(To:Emilie)

Try:

ProMdlToModelitem((ProMdl)yourProSolid, theMItem)

and

ProModelitemHide(theMItem)

BR,

Etienne

Emilie
1-Newbie
(To:earnal)

Oops, In fact I have solids :

here is what I do considering the fat that solid is a ProSolid I already have :

ProError err;

ProModelitem model_item;

err = ProMdlToModelitem(solid, &model_item);

if(err != PRO_TK_NO_ERROR)

{

printf("error %i in ProMdlToModelitem .\n",err);

}

else

{

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...

LarsZiegler
5-Regular Member
(To:Emilie)

try:

err = ProMdlToModelitem( ProSolidToMdl(solid), &model_item);

I get the same error. It seems that the model item is not well set.

Do I have to initialize it before with a special way?

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?

Emilie
1-Newbie
(To:Emilie)

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

ProAsmcompMdlGet(feature, &Mdl);

err = ProMdlTypeGet(Mdl, &MdlType);

in order to know what this feature is (thank you Lars 🙂 )

And then I can hide show this feature with

ProModelitemHide(feature)

and

ProModelitemUnhide(feature)

Emilie


timy
8-Gravel
(To:Emilie)

HI,

 

I have a problem about the function ProModelitemHide

 

----

err=ProMdlToModelitem(asm_prt_data[i].prt_handle,&p_mdl_item_prt);
err=ProModelitemHide(&p_mdl_item_prt);

---

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

PRO_FEAT_COMPONENT   1000)

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[0]

So some think like:

ProFeatureInit(p_path->owner , p_path->comp_id_table[0],&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!

Much appreciate!!!!

 

Top Tags