Detect a phantom inside a phantom

Detect a phantom inside a phantom

Remy-intl
Advocate Advocate
598 Views
5 Replies
Message 1 of 6

Detect a phantom inside a phantom

Remy-intl
Advocate
Advocate

Hello. 

 

Our ERP bug if we put a phantom assembly in a phantom assembly...

Is it possible to control this from ilogic?

How to run a rule in the top assembly and check in all levels of all assemblies below.

 

Thanks a lot.

0 Likes
599 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor

try this:

Public Sub main
	Dim a As Inventor.Application = ThisApplication
	Dim b As Inventor.AssemblyDocument = a.ActiveDocument
	Dim c As Inventor.AssemblyComponentDefinition
	
	End Sub
	
	Public Sub Loopi (a As Inventor.AssemblyDocument)
		Dim b As Inventor.ComponentDefinition = a.ComponentDefinition
		Dim occs As Inventor.ComboBoxDefinition = b.Occurrences
		Dim occ As Inventor.ComponentOccurrence
		
		Dim occdoc As Inventor.AssemblyDocument'.Document
		
		For Each occ As Inventor.ComponentOccurrence In occs
			occdoc = occ.Definition.Document
			If occdoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
				MsgBox(occ.BOMStructure)
				Loopi(occdoc)
				End If
			Next
	
		End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 6

Remy-intl
Advocate
Advocate

Hello,

 

Thanks for your time.

I have an error on ligne 15. Do you have any idea?

 

Thanks.

 

0 Likes
Message 4 of 6

bradeneuropeArthur
Mentor
Mentor
Public Sub main
	Dim a As Inventor.Application = ThisApplication
	Dim b As Inventor.AssemblyDocument = a.ActiveDocument
	Dim c As Inventor.AssemblyComponentDefinition
	
	End Sub
	
	Public Sub Loopi (a As Inventor.AssemblyDocument)
		Dim b As Inventor.ComponentDefinition = a.ComponentDefinition
		Dim occs As Inventor.ComponentDefinition = b.Occurrences
		Dim occ As Inventor.ComponentOccurrence
		
		Dim occdoc As Inventor.AssemblyDocument'.Document
		
		For Each occ As Inventor.ComponentOccurrence In occs
			occdoc = occ.Definition.Document
			If occdoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
				MsgBox(occ.BOMStructure)
				Loopi(occdoc)
				End If
			Next
	
		End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 6

dutt.thakar
Collaborator
Collaborator

@Remy-intl 

 

I would like to update the code provided by @bradeneuropeArthur . See below, this will show you the assembly name and the corresponding BOM structure in the message box.

 

 

Public Sub Main
	Dim a As Inventor.Application = ThisApplication
	Dim b As Inventor.AssemblyDocument = a.ActiveDocument
	Dim c As Inventor.AssemblyComponentDefinition
	Call Loopi(b)
	End Sub
	
	Public Sub Loopi (a As Inventor.AssemblyDocument)
		Dim b As Inventor.ComponentDefinition = a.ComponentDefinition
		Dim occs As Inventor.ComponentOccurrences = b.Occurrences
		Dim occ As Inventor.ComponentOccurrence
		
		'.Document
		
		For Each occ In occs
			
			If occ.DefinitionDocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
				Dim occdoc As Inventor.AssemblyDocument
				occdoc = occ.Definition.Document
				MsgBox(System.IO.Path.GetFileName(occdoc.FullFileName) & "----" & occ.BOMStructure.ToString)
				Loopi(occdoc)
				End If
			Next
	
		End Sub

 Hope this will help.

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


Regards,
Dutt Thakar
LinkedIn
Message 6 of 6

bradeneuropeArthur
Mentor
Mentor

@dutt.thakar 

Good addition/modification!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes