02-14-2023
08:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-14-2023
08:06 PM
After testing again I found the issue with the above code. It worked find with occurrences having filenames in one column but was failing if the filename did not exist in that column. A remedy for that would be just an "If Not Row = -1 " statement. However an easier method would be to eliminate needing to check the filename. This is achieved by stabilizing the occurrence Name with a generic name such as "Volute" and "Bellhousing". This is then a reference to find this correct occurrence in the assembly. Once you find this occurrence you can swap the FullFileName very easily.
Updated Rule.
Dim AsmDoc As AssemblyDocument = ThisDoc.Document
Dim CompDef As AssemblyComponentDefinition = AsmDoc.ComponentDefinition
Dim ExcelFileLocation As String = "********\End Suction Pump Drawings\Pumps\Pump Layout Spreadsheet Test.xlsx"
'Automatic setting of Pump Model.
MultiValue.List("PumpModel") = GoExcel.CellValues(ExcelFileLocation, "Sheet1", "A2", "A10")
'Intial List creation to ensure list is not blank on creation.
If PumpModel = "" Then : PumpModel = MultiValue.List("PumpModel").Item(0) : End If
Dim PumpModelRow As Integer = GoExcel.FindRow(ExcelFileLocation, "Sheet1", "Pump Model", "=", PumpModel)
For Each Occ As ComponentOccurrence In CompDef.Occurrences
Dim Path As String = System.IO.Path.GetDirectoryName(Occ.Definition.Document.FullFileName)
Select Case Occ.Name
Case "Volute"
Try
Occ.Replace(Path & "\" & GoExcel.CurrentRowValue("Volute"), False)
Catch
End Try
Case "Bellhousing"
Try
Occ.Replace(Path & "\" & GoExcel.CurrentRowValue("Bellhousing"), False)
Catch
End Try
End Select
Next
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan
Or if this helped you, please, click (like)
Regards
Alan