I'm trying to create a drawing template with an embedded form, iLogic code and an external excel spreadsheet for Inventor 2013. The form has 1 mult-value parameter that contains a drawing type description such as Assembly Drawing or Part Drawing.
The excel spreadsheet has two columns, a drawing description and a column that contains numbers. The speadsheet is an external file.
I wish to create an internal iLogic rule within the drawing file that reads the multi-value data selection from the form, opens the spreadsheet, looks in the first column for a drawing description that matches the value as selected from the form and looks to pickup the appropriate number data from the second column. The number value from the second column is then read back into the drawing file into a Custom iProperty.
I've spend a couple of hours pounding the keys, but to no avail. I'm really lost on this one!
Could someone please lend some assistance so that I can get the code to work?
Thank you in advance for your assistance!
Create a multivalue parameter named Description.
Create an Excel file :
Rule #1 :
'Read the multivalues from Excel, on Sheet1, values from A2 to A4 (only the values, not the column title)MultiValue.List("Description")=GoExcel.CellValues("c:\temp\classeur1.xlsx", "Feuil1", "A2", "A4")
'Get the line number in the Excel file where the column "Description" = the Inventor parameter "Description"
LineNumber=GoExcel.FindRow("c:\temp\classeur1.xlsx", "Sheet", "Description", "=", Parameter("Description"))
'On the found line, get the column named "PartNumber" and send it to the iproperty "Part Number"
iProperties.Value("Project", "Part Number")=GoExcel.CurrentRowValue("PartNumber")
To use it :launch the rule #1 once, just to update multivalues.
Then modify the parameter Description from Inventor and launche the Rule #2 to find the corresponding value and send it to the iProperty.
Hope this help !
Thank you Tonellal for your quick reply. I shall give it a go when I return back to the office tommorow morning.
I see that you've written two rules instead of 1 rule. I hadn't thought of that. Quite honestly, most of the Excel Snippets looked like good candidates for inclusion in the rule(s). I was also thinking that lots of lines of codes would be needed.
You've definitely shown me that my assumptions were just plain wrong.
Thanks for your assistance!
I'm unable to run the code as typed. There may be something wrong with the Excel installation. Please see attached files.
Do you have the eror on Rule1 or Rule 2 ?
On the Rule 2, I suppose you have corrected the comments ? On the screenshot they are on your code.
The Error Code snap-shot I provided seems to indicate prolems in trying to connect to MS Excel. How do I eliminate the error code?
I believe the error occurs with both rules. Certainly Rule 1 for sure.
Yes, it seems to be a library registration error... I've checked my Excel, the only libraries activated in the programming interface are VBA, Excel 12.0 Object Library, OLE Automation et Office 12.0 Object library.
I cannot do more...
Can I know which version of Excel you have installed? In addition, does Excel lib works well if you accessing in other languages such as VBA, .NET? It may be helpful to diagnose what happened.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register