How to Renumber Itens in the Structured View

How to Renumber Itens in the Structured View

gustavo.cassel
Advocate Advocate
501 Views
6 Replies
Message 1 of 7

How to Renumber Itens in the Structured View

gustavo.cassel
Advocate
Advocate

Hello, i'm trying to renumber the itens in the Strucured View in a Assembly with a VBA Macro.

But with this line of code: 

 

Dim oAsm As AssemblyDocument
Set oAsm = ThisApplication.ActiveDocument
Dim oBOM As BOM
Set oBOM = oAsm.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews("Structured")
oBOMView.Renumber(1, 1)

 

I got an error called "Compile error: Expected : =".

Can someone tell me how i renumber the itens in the structured view of an assembly with VBA?

0 Likes
Accepted solutions (2)
502 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

I think you should be using a "call". like this:

Dim oAsm As AssemblyDocument
Set oAsm = ThisApplication.ActiveDocument
Dim oBOM As BOM
Set oBOM = oAsm.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews("Structured")
call oBOMView.Renumber(1, 1)

 

But I wonder why you write VBa code. Check this blog post: "Is VBA in Inventor obsolete?".

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 7

gustavo.cassel
Advocate
Advocate

I've tryied this before! It continue giving me this error, can you help me?

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

This works as an iLogic rule:

Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument
Dim oBOM As BOM = oAsm.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
Dim oBOMView As BOMView = oBOM.BOMViews("Structured")
oBOMView.Renumber(1, 1)

 (Sorry I did not install VBa so i can't test VBa code)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 7

gustavo.cassel
Advocate
Advocate

I see that this works as a iLogic Rule, but i still need a version of he that works with VBA. The BOMView.Renumber method seems have a syntax error and its not working. If someone knows how to make it works, i'll be happy to know too.

0 Likes
Message 6 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

EDIT: Seen right now, Jelte wrote you exact the same VBA code. Can you post the error message?

As VBA:

 

Private Sub RenumberBOM()

Dim oAsm As AssemblyDocument
Set oAsm = ThisApplication.ActiveDocument
Dim oBOM As BOM
Set oBOM = oAsm.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = False
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews("Structured") '<-- the name is localized !!!

Call oBOMView.Renumber(1, 1)

End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 7

gustavo.cassel
Advocate
Advocate

I don't know why, but this time it works. I've just closed the Inventor and opened it again and it works. I hate this thing.

Thank you guys, you helped me so much!!

0 Likes