iLogic to Automate Duplicate Part Search

iLogic to Automate Duplicate Part Search

estringer
Advocate Advocate
789 Views
5 Replies
Message 1 of 6

iLogic to Automate Duplicate Part Search

estringer
Advocate
Advocate

I was wondering if anyone knows of any iLogic/code to automate the duplicate part search function within Inventor? I would like to be able to set it up so that Assemblies are opened up and then the search can be run against them automatically. 

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

WCrihfield
Mentor
Mentor

I'm not sure I know what 'duplicate search' you're talking about.  I noticed that one of the 'Tags' on your post was "Vault".  Are you using Vault?  Is it possible this functionality is only be available through Vault then?  The only duplicate check process I can think of right now, outside of Vault, is the setting within the Project file, under the 'Options' node, called "Using Unique File Names" (Yes or No setting).  When this is set to Yes, then when you open an assembly, if there are multiple files within your design project workspace with the same file name, it will raise a prompt screen letting you know, and asking you to choose which file is the correct one.  This usually happens as the assembly file is attempting to open though, not after the assembly is already opened.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

J-Camper
Advisor
Advisor

Along with @WCrihfield I'm also not sure what you mean by "duplicate part search function within Inventor". 

 

You can count how many times each document occurs in an assembly, if that is what you want.  Something like this will collect documents based on how many occurrences of it exist in an assembly:

Sub Main
	If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	Dim AsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	
	Dim singlesCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Dim multiCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	For Each RefDoc As Document In AsmDoc.AllReferencedDocuments
		If AsmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(RefDoc).Count = 1
			singlesCol.Add(RefDoc)
		Else If AsmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(RefDoc).Count > 1
			multiCol.Add(RefDoc)
		End If
	Next
	
	MessageBox.Show(singlesCol.Count & "  Documents within this Assembly Have a single Occurrence." & vbCrLf & vbCrLf & _
					multiCol.Count & "  Documents within this Assembly Have multiple Occurrences.", "Document Quantities")
	
End Sub

 

Let me know if you have questions or if this has nothing to do with what you want.

0 Likes
Message 4 of 6

estringer
Advocate
Advocate

@WCrihfield , @J-Camper In Vault 2020.2 the functionality to check for duplicate parts while working within Inventor was added, see video. (https://www.youtube.com/watch?v=XcCU17zTSoU). I was wondering if there is a way to initiate this function with iLogic and then use a form of auto-numbering to assign part numbers based on this? I know this sounds more like a Vault question now. A Vault/Inventor forum may be a good idea.

0 Likes
Message 5 of 6

J-Camper
Advisor
Advisor

@estringer,

 

I see.  Well I can't help very much, I only have access to Vault Basic, which doesn't have that feature.

 

As far as initiating the command, you could use CommandManager with the name of that Vault Add-in Feature, but this approach has limitations.  Any time you call a command this way, and it requires more User Input than "Yes", the iLogic code will get paused until the called command is completed by the user.  Which would mean the naming part of your request could not be accomplished that way, within Inventor iLogic.

 

Here is how you can call the command:

 

Dim cmdManager As CommandManager = ThisApplication.CommandManager

Dim cmdDuplicates As ControlDefinition = cmdManager.ControlDefinitions.Item("VaultFindDuplicates")

cmdDuplicates.Execute

 

 

I can't test any further.

0 Likes
Message 6 of 6

estringer
Advocate
Advocate

Thank you for looking into this and thank you for the code option.

0 Likes