Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
JimStrenk
Posts: 147
Registered: ‎06-20-2006
Message 1 of 8 (748 Views)

Need help with iLogic, Excel and Custom iProperty

748 Views, 7 Replies
11-13-2012 07:31 PM

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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Mentor
TONELLAL
Posts: 162
Registered: ‎01-17-2010
Message 2 of 8 (736 Views)

Re: Need help with iLogic, Excel and Custom iProperty

11-14-2012 09:29 AM 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 !

 

Distinguished Contributor
JimStrenk
Posts: 147
Registered: ‎06-20-2006
Message 3 of 8 (726 Views)

Re: Need help with iLogic, Excel and Custom iProperty

11-14-2012 07:03 PM 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Distinguished Contributor
JimStrenk
Posts: 147
Registered: ‎06-20-2006
Message 4 of 8 (698 Views)

Re: Need help with iLogic, Excel and Custom iProperty

11-18-2012 09:08 PM 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Mentor
TONELLAL
Posts: 162
Registered: ‎01-17-2010
Message 5 of 8 (676 Views)

Re: Need help with iLogic, Excel and Custom iProperty

11-19-2012 12:49 AM 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.

Distinguished Contributor
JimStrenk
Posts: 147
Registered: ‎06-20-2006
Message 6 of 8 (659 Views)

Re: Need help with iLogic, Excel and Custom iProperty

11-19-2012 09:34 PM 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Mentor
TONELLAL
Posts: 162
Registered: ‎01-17-2010
Message 7 of 8 (648 Views)

Re: Need help with iLogic, Excel and Custom iProperty

11-20-2012 07:32 AM 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...

ADN Support Specialist
xiaodong.liang
Posts: 1,335
Registered: ‎06-12-2011
Message 8 of 8 (610 Views)

Re: Need help with iLogic, Excel and Custom iProperty

12-26-2012 03:21 AM 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.



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.