Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Macro to expand nested Product into parts?

Macro to expand nested Product into parts?

Macro to expand nested Product into parts?


I am looking for a macro to help me expand hundreds of products into their parts. To be clear, what I have is a single product(Product A) which contains hundreds of products and parts, each of those products then contains a large number of parts or sometimes further nested products. I want to pull all of the individual parts out from the nested products so that Product A only contains CATParts. Retaining the positioning of the parts may be sometimes needed as well.

Does such a macro exist out there somewhere? Or can somebody help me to create one?

Thank you,

RE: Macro to expand nested Product into parts?


Do all of these parts have unique namea?

RE: Macro to expand nested Product into parts?


yes they do.

RE: Macro to expand nested Product into parts?

Depending on how they were modeled, here is a a few steps:
1.Create a new product
2.Click Insert
3.Click Existing Component
4.Navigate to folder that the design is saved in.
5.Sort by Type and select every part in the folder
6.Click Open and it should load every part you have selected into the new product you created.

RE: Macro to expand nested Product into parts?

7 open source product
8 read position matrix of all elements
9 apply position matrix to element in new product

Eric N.
indocti discant et ament meminisse periti

RE: Macro to expand nested Product into parts?

I wish it would be that easy. Unfortunately, that will not work as in the folder there are many times more parts and products that are not loaded into my product.

RE: Macro to expand nested Product into parts?

Save Management the top product into a new folder with all of its parts and perform the steps.

RE: Macro to expand nested Product into parts?

Here is the macro you wanted:

Sub CATMain()
dim prd: set prd = CATIA.ActiveDocument.Product
dim sel: set sel = CATIA.ActiveDocument.Selection
sel.Search "CATPrtSearch.PartFeature,all"
dim i, prt, instance, coords(11)
i = sel.Count
do while i > 0
if sel.Item(i).LeafProduct.Parent.Parent.Name < > prd.Name then
set instance = prd.Products.AddComponent(sel.Item(i).Value.Parent.Product)
instance.Name = sel.Item(i).LeafProduct.Name
sel.Item(i).LeafProduct.Position.GetComponents coords
instance.Position.SetComponents coords

set instance = sel.Item(i).LeafProduct
sel.Remove i
sel.Add instance
sel.Remove i
end if
i = i - 1
End Sub

RE: Macro to expand nested Product into parts?

Great. Thank you :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


White Paper - Reliability Verification for AI and ML Processors
Artificial intelligence and machine learning are seeing growing adoption in a wide range of applications. ICs used for AI/ML applications are characterized by large parallel processing computation units, high power dissipation, and complex circuitry that can deliver maximum performance within a strict power budget. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close