Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help with iLogic, Excel and Custom iProperty

7 REPLIES 7
Reply
Message 1 of 8
JimStrenk
1359 Views, 7 Replies

Need help with iLogic, Excel and Custom iProperty

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!

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013, 2014, 2015,2016, 2017

Other than THAT, Mrs. Lincoln, how was the play??
7 REPLIES 7
Message 2 of 8
TONELLAL
in reply to: JimStrenk

Create a multivalue parameter named Description.

Create an Excel file  :

DescriptionPartNumber
Part1A
Part2B
Part3C

 

Rules :

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")

Rule #2
'
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 !

 

Message 3 of 8
JimStrenk
in reply to: TONELLAL

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!

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013, 2014, 2015,2016, 2017

Other than THAT, Mrs. Lincoln, how was the play??
Message 4 of 8
JimStrenk
in reply to: TONELLAL

I'm unable to run the code as typed.  There may be something wrong with the Excel installation.  Please see attached files.

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013, 2014, 2015,2016, 2017

Other than THAT, Mrs. Lincoln, how was the play??
Message 5 of 8
TONELLAL
in reply to: JimStrenk

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.

Message 6 of 8
JimStrenk
in reply to: TONELLAL

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.

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013, 2014, 2015,2016, 2017

Other than THAT, Mrs. Lincoln, how was the play??
Message 7 of 8
TONELLAL
in reply to: JimStrenk

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...

Message 8 of 8
xiaodong_liang
in reply to: JimStrenk

Hi,

 

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report