Skip to main content
13-Aquamarine
December 6, 2021
Solved

How to collect components at different level in assembly

  • December 6, 2021
  • 3 replies
  • 2671 views

Hello Friends, 

 

I have use ProSolidFeatureVisit() API  to find the component , but it collect component at first level , But I want to find the component at all level in assembly ,Please help me to resolve the issue.

 

Regards,

Kunal  

Best answer by FV_01

You should take a look at UtilVisit.c in the examples. Copy/paste ProUtilAsmTravAction(...)

HIH.

FV_1-1638813310226.png

 

 

3 replies

24-Ruby III
December 6, 2021

A similar question was previously - "Retrieve assembly components on all levels in Creo 2.0": https://community.ptc.com/t5/Customization/Retrieve-assembly-components-on-all-levels-in-Creo-2-0/td-p/14 

13-Aquamarine
December 6, 2021

I have see this post but I am struck in creation of visiting function for this API.

Can you please provide the visiting function for same.

 

Regards,

Kunal

FV_0117-PeridotAnswer
December 6, 2021

You should take a look at UtilVisit.c in the examples. Copy/paste ProUtilAsmTravAction(...)

HIH.

FV_1-1638813310226.png

 

 

RPN
18-Opal
December 6, 2021

You call the visit functions for components, if your component is a PRO_ASSEMBLY you just call your function recursive again.  It’s a little bit like traverse a folder structure. But for sure not the same.

An assembly is like folder, but this folder can appear at the same level or in other levels with the same structure and multiple times. 

 

Sample Tcl Code

 

proc Get_Assy_Names {ASM} {
 # Vist the given assembly by components
 foreach FID [ps_visit type -model $ASM -- COMPONENT] {
 # Get the model name from this feature ID
 set MDL [ps_assy component_name -model $ASM -- $FID ]
 # If the MDL is an assembly, recursive call
 if { [ps_model is_assembly -model $MDL]} {
 Get_Assy_Names $MDL
 }
 }
 return
}

 

BTW: If you export, save the feature ids, you have the component path for each model in the assembly.

1-Visitor
January 3, 2022

Hi Kunal,

 

Use the function ProSolidFeatureVisit() recursively to collect components from all levels.

 

Example:

ProSolidFeatureVisit(Parent_asm, visit_action,filter_action,app_data){

    ProSolidFeatureVisit(child_asm, visit_action, filter_action, app_data)

         {

                       .........logic

          }

}