Skip to main content
1-Visitor
May 27, 2013 9:34 AM UTC
Question

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

8-Gravel
May 27, 2013 9:55 AM UTC

Hello!

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

Translate
1-Visitor
May 27, 2013 9:58 AM UTC

Try:

ProMdlToModelitem((ProMdl)yourProSolid, theMItem)

and

ProModelitemHide(theMItem)

BR,

Etienne

Translate
Emilie1-VisitorAuthor
1-Visitor
May 27, 2013 10:07 AM UTC

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

Translate
8-Gravel
May 27, 2013 10:23 AM UTC

try:

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

Translate
Emilie1-VisitorAuthor
1-Visitor
Jun 11, 2013 1:35 PM UTC

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


Translate
1-Visitor
Jul 18, 2018 8:41 AM UTC

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?

Translate
21-Topaz I
Jul 18, 2018 8:59 AM UTC

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)

Translate