Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have the Ilogic rule below that is working fine in my PC but not in my colleague's one (the same Inventor 2021.3.3 version). I think it is because different versions of Visual Basics or something similar.
I wonder if someone can help me to change the rule to avoid it. The rule is used to add a prefix to the Part numbers of all the components of the assembly.
Sub Main ()
RUsure = MessageBox.Show("This will add the LFE No Prefix to the Part Numbers" _
& vbLf & "" _
& vbLf & "Are you sure you want to do it?", "ADD LFE NO PREFIX ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
' Get all of the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
ThisApplication.SilentOperation = True
' Iterate through the occurrences and print the name.
Dim sPrefix As String
sPrefix = InputBox ("LFE NO:","Set PN surfix", "######")
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
Dim oDoc As PartDocument
'find colon SeparatorPosistion
Dim SeparatorPos As Long
SeparatorPos = InStrRev(oOcc.Name, ":",-1)
'define part number prefix
'set part number for each component
iProperties.Value(oOcc.Name, "Project", "Part Number") = "LFE"&sPrefix & " - " & Left(oOcc.Name,SeparatorPos -1)
Next
End Sub
These are the messages I am getting:
Solved! Go to Solution.