iLogic paint colour

iLogic paint colour

Anonymous
Not applicable
536 Views
6 Replies
Message 1 of 7

iLogic paint colour

Anonymous
Not applicable

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
 

 

0 Likes
537 Views
6 Replies
Replies (6)
Message 2 of 7

MechMachineMan
Advisor
Advisor

Do any Inventor related excel features work on his computer?

 

Can he do the BOM export from an assembly to excel and have it function properly?

 

In the assembly, can he still access the spreadsheet for the representations with excel without it throwing an error?

 

If they don't then it's an excel related error. If he has Office 365, if he does not have a local install, that would be why it's causing issues. If he does have a local install then it's a slightly deeper issue. You should be able to find more info on it on the forums recently.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 7

bradeneuropeArthur
Mentor
Mentor

Check the following requirements for inventor 2019:

 

SpreadsheetFull local install of Microsoft® Excel 2010, 2013 or 2016 for iFeatures, iParts, iAssemblies, Global BOM, Parts Lists, Revision Tables, spreadsheet-driven designs and Studio animation of Positional Representations.

64-bit Microsoft Office is required to export Access 2007, dBase IV, Text and CSV formats.

Office 365 subscribers must ensure they have a local installation of Microsoft Excel 2016.

Windows Excel Starter®, OpenOffice®, and browser-based Office 365 applications are not supported.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 7

Anonymous
Not applicable

Sorry, I guess I had to give more details, I am using Inventor Professional 2016 as well as my collegue, however I am using 2007 Microsoft Suite and my collegue is using the 2016 Microsoft Suite (if I remember properly)

0 Likes
Message 5 of 7

Anonymous
Not applicable

I guess you are right, I had to use the "UseLibXML" set to 1 in my Environnement Variable for my Excel-related features to work. However, I tried to reinstall my Office Suite (2007) and it repair it as well and it still doesn't work. I guess I will have to try to remove completely the suite from my computer, reboot, run CCleaner to clear any possible remaining files and do it once more. I don't understand how this could have happened overnight though. Thursday it was working fine, I closed my computer (because I don't work on Fridays) and reopened it on Monday and ta-dam, it isn't working properly anymore.

 

thank you for your reply, I will try to get back to you as soon as possible, in hope that it works this time!

0 Likes
Message 6 of 7

Anonymous
Not applicable

Alrighty, I tried to repair my installation of Microsoft Office's suite, I tried to uninstall/run CCleaner/reinstall also, both of these options resulted in the same outcome; I can't open the files or anything from within Inventor. This seems super weird as I didn't do anything wrong (haven't installed anything in a while or uninstalled for that matter)

Formatting my computer is almost guaranteed to be a "no go" as it takes a considerable amount of time that we do not have right now. However, I can do most of the functions you named if I add the "UseLibXML" environnement variable in my computer... so it's a workaround for the basic things like threaded holes operations, but since most of our assembly are Excel driven, I can't do most of the stuff I need to do.

 

Any ideas on what could I do or try ? I am starting to think to move to my colleague's version of Office, although I don't think it would correct the issue I am having right now.

0 Likes
Message 7 of 7

Anonymous
Not applicable

Also, if I open manually my Excel application, the files WILL open from Inventor into the Excel. However, the threaded functions (for example) will still not work (I do believe it is because it is ran internally instead of externally like my linkage between Excel and Inventor to control the parts dimensions).

0 Likes