Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to make a rule in a top level assembly. This rule should check all part filenames in the assembly. If the part filenames end in "ADV", it should write "ADV" in a new custom iproperty called "Type" in the parts that contain the "ADV".
I tried piecing together different bits of code I found from similar posts on this forum, but I just can't get it to work. I'm not really into coding, so my code is probably bad in many ways.
Here is what I have:
'define the active assembly Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim oFullFileName As String Dim oDoc As Inventor.Document For Each oDoc In oAsmDoc.AllReferencedDocuments oFullFileName = oDoc.FullFileName 'find the postion of the last backslash in the path FNamePos = InStrRev(oFullFileName, "\", -1) 'get the file name with the file extension Name = Right(oFullFileName, Len(oFullFileName) - FNamePos) 'get the file name (without extension) ShortName = Left(Name, Len(Name) -4) Type = Right(ShortName, 3) If Type = "ADV" Then iProperties.Value("Custom", "Type") = "ADV" Else iProperties.Value("Custom", "Type") = "" End If Next
Any help would be appreciated.
Regards,
Tom
Autodesk Inventor Professional 2022
Solved! Go to Solution.