iLogic paint colour

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I have created an iLogic rule to be ran every time the parts opens and closes.
The rule was designed to colour the parts based on a multivalue variable called TypePiece and an excel file.
The excel file has to always be at the same directory level as our .ipj and it contains in cells B1 to B11 the values designated by the possible values of the multicell TypePiece (for example in cell A2 it is "Principale" and in B2 we put the colour for our main parts of an assembly).
The code has been working for a while now, but my collegue changed his version of Excel to an higher version than mine and since then everything has been acting up weird. I even deleted all of the "Couleurs.xlsx" we created and recreated them today and tried to ran the code again (he didn't open them up, so it should still work flawlessly as it was for the past 3 months)... however, it still acts up strangely.
Below is the code and the error that it returns (every time the parts opens/closes and 1 out of 2 times I manually run the iLogic rule)
I'm hoping to receive some help here as its driving me nuts and I tried everything I knew as far as coding goes... Thank you !
Here is the error and its "More info" tab and the iLogic rule I used to run down below:
Le serveur a généré une exception. (Exception de HRESULT : 0x80010105 (RPC_E_SERVERFAULT))
System.Runtime.InteropServices.COMException (0x80010105): Le serveur a généré une exception. (Exception de HRESULT : 0x80010105 (RPC_E_SERVERFAULT))
à Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
à iLogic.GoExcel.SetCurrentSheet(String fileName, String sheetName)
à LmiRuleScript.Main()
à Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
à iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
SyntaxEditor Code Snippet
'set a reference to the FileLocations object. IPJ = ThisApplication.FileLocations.FileLocationsFile 'get the location of the last backslash seperator FNamePos = InStrRev(IPJ, "\", -1) 'get the project file name with the file extension IPJ_Name = Right(IPJ, Len(IPJ) - FNamePos) 'get the project name (without extension) IPJ_ShortName = Left(IPJ_Name, Len(IPJ_Name) - 4) 'get the path of the folder containing the project file IPJ_Folder_Location1 = Left(IPJ, Len(IPJ) - Len(IPJ_Name)) & "Couleurs.xlsx" IPJ_Folder_Location = Right(IPJ_Folder_Location1, Len(IPJ_Folder_Location1)-1) If Left(IPJ_Folder_Location1,1) = "Z" Then GoExcel.Open("Z" & IPJ_Folder_Location, "Feuil1") Else GoExcel.Open("C" & IPJ_Folder_Location, "Feuil1") End If Try Select Case Parameter("TypePiece") Case "Principale" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B2") Case "GalvPeint" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B3") Case "Securite" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B4") Case "Grillage" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B5") Case "Usinage" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B6") Case "TraySol" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B7") Case "Autre1" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B8") Case "Autre2" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B9") Case "Autre3" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B10") Case "Autre4" iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = GoExcel.CellValue("B11") End Select Catch iProperties.Value(ThisDoc.Document, "Custom", "Couleur") = "Aucune" End Try Coloring = iProperties.Value(ThisDoc.Document, "Custom", "Couleur") Select Case Coloring Case "Aucune" OldColor = iProperties.Material iProperties.Material = "BRFV" iProperties.Material = OldColor Case Else iProperties.PartColor = iProperties.Value(ThisDoc.Document, "Custom", "Couleur") End Select iLogicVb.UpdateWhenDone = True ThisApplication.ActiveView.Fit