Inventor Customization

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

Need help with iLogic, Excel and Custom iProperty

675 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Distinguished Contributor
TONELLAL
Posts: 143
Registered: ‎01-17-2010
Message 2 of 8 (663 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: 146
Registered: ‎06-20-2006
Message 3 of 8 (653 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

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: 146
Registered: ‎06-20-2006
Message 4 of 8 (625 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Distinguished Contributor
TONELLAL
Posts: 143
Registered: ‎01-17-2010
Message 5 of 8 (603 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: 146
Registered: ‎06-20-2006
Message 6 of 8 (586 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Distinguished Contributor
TONELLAL
Posts: 143
Registered: ‎01-17-2010
Message 7 of 8 (575 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,263
Registered: ‎06-12-2011
Message 8 of 8 (537 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube