Update Root Product - VBA

Nebojsa Milic

Update Root Product - VBA

Hello,

I'm trying to write a code that will update Root Product from wherever i'm positioned in tree.

For example I am working in Part which is at level 4 in tree structure.

Here is my code that doesn't do anything:

 

Sub Update_master_assy()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim RootProd As Product
Set RootProd = productDocument1.Product

RootProd.Update        'This line doesn't work

End Sub

When 
No luck when changing: Settings > Infrastructure-> Part Infrastructure and Mechanical Design->Assembly Design

 

Anyone know the solution?

Fernando Petre

RE: Update Root Product - VBA
(in response to Nebojsa Milic)

What if you will select the root product and run the update command?

Best regards

Fernando

Nebojsa Milic

RE: Update Root Product - VBA
(in response to Fernando Petre)

If you meant like this:

 

Sub Update_master_assy()

Dim productDocument1 As Document

Set productDocument1 = CATIA.ActiveDocument

Dim RootProd As Product
Set RootProd = productDocument1.Product

Dim selection1 As selection
Set selection1 = productDocument1.selection

selection1.Add RootProd

RootProd.Update

'CATIA.Startcommand "Update All"

End Sub

 

It still doesn't work..

V!nc3nt N9, Engineer

RE: Update Root Product - VBA
(in response to Nebojsa Milic)

Could it be that your settings is set to Automatic Update? Maybe try setting it to Manual and then run the macro.

Attachments

  • 2021-06-24_172719.jpg (93k)
  • 2021-06-24_172822.jpg (76.6k)
Edited By:
V!nc3nt N9[Subscriber Members] @ Jun 24, 2021 - 05:31 PM (Asia/Singapore)

Nebojsa Milic

RE: Update Root Product - VBA
(in response to V!nc3nt N9, Engineer)

I have tried all the combinations... Automatic part and assembly, manual part and assembly, automatic part but not assembly and vice versa

V!nc3nt N9, Engineer

RE: Update Root Product - VBA
(in response to Nebojsa Milic)

I copied your code and pasted into a new module and it worked for me. But mine was a simple CATProuct with 3 levels.

Theoretically it should work no matter how many levels.

Perhaps you can try exploring running a code that loops into each member in the Specification Tree and do an update.

COE : Forums : Looping through Product's Tree

http://www.coe.org/p/fo/et/thread=15608

Nebojsa Milic

RE: Update Root Product - VBA
(in response to V!nc3nt N9, Engineer)

Well I have think about it earlier but it could be too slow maybe? What do you think?
Anyways, does anyone knows the solution for this problem?