Ilogic BOM Enabled for all child assemblies.

Ilogic BOM Enabled for all child assemblies.

davis.j
Advocate Advocate
709 Views
5 Replies
Message 1 of 6

Ilogic BOM Enabled for all child assemblies.

davis.j
Advocate
Advocate

I've scoured the web and I am at a roadblock. I need help converting the following illogic code so that it applies to all child assemblies (All lower level Assemblies.)

 

I am not skilled at coding so any help would be appreciated. 🙂

 

Sub Main()
	
    Dim oDoc As Document
	oDoc = ThisApplication.ActiveDocument
	
	Dim oBOM As BOM
    oBOM = oDoc.ComponentDefinition.BOM
	
    For Each oDoc In ThisApplication.Documents
        If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			oBOM.StructuredViewEnabled = True
			oBOM.StructuredViewFirstLevelOnly = True
			oBOM.PartsOnlyViewEnabled = True    
        End If
    Next
End Sub

 

 

0 Likes
Accepted solutions (1)
710 Views
5 Replies
Replies (5)
Message 2 of 6

dutt.thakar
Collaborator
Collaborator

@davis.j 

 

Can you please try and see if it works. Make sure your assembly has Default BOM Structure, as this check is not covered in the code. If it has a Reference BOM Structure, it could give errors.

Sub Main()
	
    Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Dim oOcc As ComponentOccurrence

    For Each oOcc In oDef.Occurrences
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Dim oODoc As AssemblyDocument = oOcc.Definition.Document
			Dim oBOM As BOM = oODoc.ComponentDefinition.BOM
			
			oBOM.StructuredViewEnabled = True
			oBOM.StructuredViewFirstLevelOnly = True
			oBOM.PartsOnlyViewEnabled = True    
        End If
    Next
End Sub

Hope this is helpful.

 

If this has answered your question, please accept it as a solution.

 

Regards,

Dutt Thakar

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 6

davis.j
Advocate
Advocate

@dutt.thakar 

Thank you,

 

This worked for all of the child assemblies in each lower level but it did not modify the current open assembly BOM.

I have monkey'd around it seems the following code has worked but I'm not sure if it is written in the proper notation.

 

Sub Main()
	
    Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
	Dim oOcc As ComponentOccurrence

    For Each oOcc In oDef.Occurrences
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Dim oODoc As AssemblyDocument = oOcc.Definition.Document
			Dim oBOM As BOM = oODoc.ComponentDefinition.BOM
			
			oBOM.StructuredViewEnabled = True
			oBOM.StructuredViewFirstLevelOnly = True
			oBOM.PartsOnlyViewEnabled = True    
        End If
    Next
	
	Dim aBOM As BOM
    aBOM = oDoc.ComponentDefinition.BOM
	
	aBOM.StructuredViewEnabled = True
	aBOM.StructuredViewFirstLevelOnly = True
	aBOM.PartsOnlyViewEnabled = True
	
End Sub
0 Likes
Message 4 of 6

dutt.thakar
Collaborator
Collaborator
Accepted solution

@davis.j 

 

yes you have written is correctly. I forgot to add that. You can either write the same first or after changing the child assembly BOM, It won't make any difference.

 

If my code has answered your question, please mark it as a solution.

 

Thanks,

Regards,

Dutt Thakar

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 5 of 6

dutt.thakar
Collaborator
Collaborator

@davis.j 

 

yes you have written it correctly. I forgot to add that. You can either write the same first or after changing the child assembly BOM, It won't make any difference.

 

If my code has answered your question, please mark it as a solution.

 

Thanks,

Regards,

Dutt Thakar

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 6 of 6

dutt.thakar
Collaborator
Collaborator

@davis.j 

Yes you have written it correctly. It won't make any difference if you write first or in last. I actually forgot to add that, thought you only need fir sub assembly levels.

 

If my previous code has answered your question, please accept it as a solution.

 

Regards,

Dutt Thakar

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes