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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

How to collect components at different level in assembly

KB_9753804
12-Amethyst

How to collect components at different level in assembly

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  

1 ACCEPTED SOLUTION

Accepted Solutions
FV
17-Peridot
17-Peridot
(To:KB_9753804)

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

HIH.

FV_1-1638813310226.png

 

 

View solution in original post

5 REPLIES 5

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 

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
17-Peridot
17-Peridot
(To:KB_9753804)

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

HIH.

FV_1-1638813310226.png

 

 

RPN
17-Peridot
17-Peridot
(To:KB_9753804)

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.

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

          }

}

Top Tags