Skip to main content
1-Visitor
May 27, 2013
Question

Hide and show parts

  • May 27, 2013
  • 3 replies
  • 4088 views

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

3 replies

8-Gravel
May 27, 2013

Hello!

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

1-Visitor
May 27, 2013

Try:

ProMdlToModelitem((ProMdl)yourProSolid, theMItem)

and

ProModelitemHide(theMItem)

BR,

Etienne

Emilie1-VisitorAuthor
1-Visitor
May 27, 2013

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

8-Gravel
May 27, 2013

try:

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

Emilie1-VisitorAuthor
1-Visitor
June 11, 2013

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


1-Visitor
July 18, 2018

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?

21-Topaz I
July 18, 2018

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)