Automatic Unsolved Identification

Automatic Unsolved Identification

ersin_karacoban
Participant Participant
432 Views
6 Replies
Message 1 of 7

Automatic Unsolved Identification

ersin_karacoban
Participant
Participant

Is there a code to automatically identify parts with changed names in the assembly?

 

 

0 Likes
433 Views
6 Replies
Replies (6)
Message 2 of 7

Andrii_Humeniuk
Advisor
Advisor

Hi @ersin_karacoban . You can distinguish your documents using InternalName. Example code:

Dim oDoc As AssemblyDocument = ThisDoc.Document
For Each oRefDoc As Document In oDoc.AllReferencedDocuments
	MessageBox.Show(oRefDoc.InternalName, oRefDoc.DisplayName)
Next

InternalName - a unique static name of the object that does not change, but is set when the document is created.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 7

Michael.Navara
Advisor
Advisor

What does it mean "parts with changed names in the assembly"? It is

  • Renamed occurrence - Node text in assembly tree
  • Changed DisplayName of document - Display name (root node in model tree) is different from file name
  • Renamed file - missing reference
  • ...
0 Likes
Message 4 of 7

ersin_karacoban
Participant
Participant
  • Renamed file - missing reference

 

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor

Hi @ersin_karacoban.  Maybe this example code will give you some ideas.  It is just for checking the top level (or direct) document and file references of a single document, as it is.  But a routine similar to this could be put into a separate custom Function, and called from the main routine, as it iterates through all levels of an assembly.  I am not sure what you were expecting as a result (or feedback) of running a rule like this, bit this example uses two List(Of String) type objects to keep track of only the ones that are 'missing', then shows you the list at the end of both loops.

Sub Main
	Dim oDoc As Document = ThisDoc.Document
	CheckDocuments :
	Dim oList1 As New List(Of String)
	Dim oRDDs As DocumentDescriptorsEnumerator = oDoc.ReferencedDocumentDescriptors
	If oRDDs.Count > 0 Then
		For Each oRDD As DocumentDescriptor In oRDDs
			'If oRDD.ReferenceSuppressed Then
			'If oRDD.ReferenceDisabled Then
			'If oRDD.ReferenceInternalNameDifferent Then
			If oRDD.ReferenceMissing Then
				oList1.Add(oRDD.FullDocumentName)
			End If
		Next 'oRefDoc
	End If
	If oList1.Count > 0 Then
		a = InputListBox("", oList1, "", "DocumentDescriptors Missing References")
	End If
	CheckFiles :
	Dim oList2 As New List(Of String)
	If oDoc.FileSaveCounter > 0 Then
		Dim oRFDs As FileDescriptorsEnumerator = oDoc.File.ReferencedFileDescriptors
		If oRFDs.Count > 0 Then
			For Each oRFD As FileDescriptor In oRFDs
				'If oRFD.ReferenceLocationDifferent Then
				'If oRFD.ReferenceDisabled Then
				'If oRFD.ReferenceInternalNameDifferent Then
				If oRFD.ReferenceMissing Then
					oList2.Add(oRFD.FullFileName)
				End If
			Next 'oRFD
		End If
	End If
	If oList2.Count > 0 Then
		a = InputListBox("", oList2, "", "FileDescriptors Missing References")
	End If
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

ersin_karacoban
Participant
Participant

Actually, I know what I need to do but I can't code it. It will try to open all the parts in the same folder, click "no" when the "unresolved" warning appears, and try the next part. When this cycle is over, if the part with the "unresolved" warning is already in the folder, our problem will be solved.

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

That sounds like you may just need to use Documents.OpenWithOptions method, instead of the Documents.Open method.  Then, just before you call that method to run, you create a new NameValueMap object, and make sure you add an entry into it with the Name = "SkipAllUnresolvedFiles", and the Value = True.  Then supply that NameValueMap as the second (of 3) input being requested by the method.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes