03-29-2022
08:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-29-2022
08:03 AM
We can stick with the AllReferencedDocuments route, if we populate the Description iProperty from the Document's file name. Here is a fairly simple example iLogic code that will do that task. I separated the main process out into its own Sub routine, and I am also using a Try...Catch block within that to help handle/avoid the potential errors. It is sometimes possible that not every referenced document is a regular Inventor Part or Assembly document.
Sub Main
oDoc = ThisDoc.Document
WriteFileNameToDescription(oDoc)
If oDoc.AllReferencedDocuments.Count = 0 Then Exit Sub
For Each oRefDoc As Document In oDoc.AllReferencedDocuments
WriteFileNameToDescription(oRefDoc)
Next
End Sub
Sub WriteFileNameToDescription(oDoc As Document)
Try
'gets file name, without path, and without file extension
oFileName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
oDescProp = oDoc.PropertySets.Item("Design Tracking Properties").Item("Description")
If oDescProp.Value <> oFileName Then oDescProp.Value = oFileName
Catch oEx As Exception
MsgBox(oEx.Message & vbCrLf & oEx.StackTrace, vbExclamation, "")
'Logger.Error(oEx.Message & vbCrLf & oEx.StackTrace)
End Try
End Sub
Wesley Crihfield
(Not an Autodesk Employee)