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

Retrieve Model from Feature using VBA API

BF_10197348
4-Participant

Retrieve Model from Feature using VBA API

Hello, 

I am currently building a VBA application to automate a few things in my creo daily workflow and unfortunately I am stuck because I am not able to retrieve a model type variable from a componente type feature variable. I am thinking about model descriptors. I can create it but I am struggling trying assign it to the model. The idea is to reach the model by reading the model descriptor present in the correspondent feature variable. 

thank you in advance! 

2 REPLIES 2

Thank you for your question.
I encourage you to bring more details and context to your initial inquiry. This will make it easier for you to receive meaningful help from other Community members.
Regards,
Andra
RPN
17-Peridot
17-Peridot
(To:BF_10197348)

I’m not a VBA guru and not a VBA fan, but:

 

From the reference doc.

 

The important functions for assemblies are those that operate on the components of an assembly. The object IpfcComponentFeat, which is an instance of IpfcFeature is defined for that purpose. Each assembly component is treated as a variety of feature, and the integer identifier of the component is also the feature identifier.

 

Now if your feature in an assembly is from type Component, then …

 

The property IpfcComponentFeat.ModelDescr returns the model descriptor of the component part or subassembly.

 

I don’t understand that the wording is different to Toolkit, but this may part of the VBA game.

 

For the type it can be only Part or Assembly (Sub)


And I would NOT use this property.

The property IpfcComponentFeat.CompType returns the type of the assembly component. The component type identifies the purpose of the component in a manufacturing assembly.

 

You have to ask the solid about the type, if there is no function for this, compare the extension prt vs asm. 

Note: A solid has sub classes like sheet metal, skeleton….


Only my 2 Cents :

 

 

set model [ps_model current]
# Get Component ID's
 set CompIDs [ps_visit type -model $model component]
 foreach CompID $CompIDs         {
  # get component name
  set CompName [ps_assy component_name  -model $model $CompID]
  # get the extension
  set ext [ps_model ext -model $CompName]
  switch $ext {
   PRT        {
      # proceed if Solid parts
    }
   ASM      {
     # proceed if Assemblies
    }
   default {
         error "Unknow extension '$ext' in assy '$model' found"
    }                                           
  }
}

 

 

Top Tags