Inventor Customization

Inventor Customization

Reply
Mentor
TONELLAL
Posts: 162
Registered: ‎01-17-2010
Message 11 of 20 (504 Views)

Re: Open embedded XL sheet with iLogic

11-15-2012 01:06 AM in reply to: mehatfie

Why "embedded file" instead of "linked" file ? Because it is easy to manage :

-you have only 1 file : the ipt. If you need to copy, move, rename,... the file, you don't have to know if there is another file to modify too. If you have a linked file, you cannot rename it or the ipt, if the folder is renamed the linked does not function any more, etc. With only 1 file it is much easier.

-each ipt file has its own parameters sheet. If you have a linked file you have to copy and rename the xls file for each ipt file. With an embedded file you don't have to manage this

-all needed information to use the ipt is in the ipt. No links managed by Windows.

-impossible to modify the xls file if you are not in the ipt file. The only person who can modify it is the Inventor user. If you have an external file, evrybody can modify it and so corrupt the ipt.

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 12 of 20 (500 Views)

Re: Open embedded XL sheet with iLogic

11-15-2012 06:22 AM in reply to: TONELLAL

Hi TONELLAL,

 

You do make some good points.

 

I'm not sure what your end goal is, or why the need to open the file. Does the user need to enter some values into the excel file for parametric reasons?

 

If so, a work around method would be to use parameters. If there is still a need to have the excel sheet rather than using parameters alone, you can link the parameters to cells in the excel sheet.

 

Using parameters (either by themselves or connected to a cell in the spreadsheet) you would be able to display the values in a form and have the users edit the form instead, which woul in turn be editting the spreadsheet.

 

Regards

Mitch

Mentor
TONELLAL
Posts: 162
Registered: ‎01-17-2010
Message 13 of 20 (496 Views)

Re: Open embedded XL sheet with iLogic

11-15-2012 07:01 AM in reply to: mehatfie

Hi Mitch,

The workaround is :

-create a new file, based on a template containing geometry

-open the xl sheet to choose values. This sheet is very complicated, with links between Excel sheets, Excel search in tables, etc.

-depending of selected values, all neede parameters are sent on a sheet.

-this sheet is red by iLogic with GoExcel... to fill Inventor parameters.

 

How to open the sheet by iLogic ?

I made an iLogic form, which can launch several rules using buttons. One of this rules should be "Open the parameters sheet".

 

Best regards,

Alain

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 14 of 20 (493 Views)

Re: Open embedded XL sheet with iLogic

11-15-2012 07:23 AM in reply to: TONELLAL

TONELLAL,

 

As I explained a few posts back with some code, if you want to be able to open the excel sheet from within iLogic, you have to research how to "Add Reference" to excel through iLogic.

 

If you open the VBA Editor (Tools Tab > VBA Editor), click the "Tools" tab again in this screen, and then "References..." you'll access this ability to add references if you were programming directly in the VBA Editor. There should be a library called "Microsoft Excel...... Object Library." 

 

This is what you'd need to add in order to begin using the code I gave (although there is still a little more to the code), but must figure out how to do this and "Add Reference" in iLogic. As I'm not exactly sure how this works.

 

As a different root, I would suggest switching to programming directly in the VBA Editor, as it makes it much easier to add these references to other libraries. When I was programming my big iLogic program, I wanted to keep everything in iLogic instead of using the VBA Editor... it turned out to be a lot more work than it should have been I believe.

 

Regards

Mitch

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 15 of 20 (488 Views)

Re: Open embedded XL sheet with iLogic

11-15-2012 12:35 PM in reply to: TONELLAL

Hi TONELLAL,

 

I finally got it to work!

 

The following code will open the first item embedded in the document (I'm assuming you only have one):

 

Imports Inventor.OLEDocumentTypeEnum

ExcelApp = CreateObject("Excel.Application")

Dim ExcelFile As ReferencedOLEFileDescriptor
ExcelFile = ThisDoc.Document.ReferencedOLEFileDescriptors.Item(1)

ExcelFile.Activate(kEditOpenOLEVerb, ExcelApp)

 

 

Regards

Mitch

 

Let me know if it helps... Kudos if it works!!!

Mentor
TONELLAL
Posts: 162
Registered: ‎01-17-2010
Message 16 of 20 (478 Views)

Re: Open embedded XL sheet with iLogic

11-16-2012 06:10 AM in reply to: mehatfie

Hi Mitch,

 

It works perfectly ! You were right, you need to create the link with Excel, then create an object, then use it. I think the iLogic commands GoExcel... do this automatically.

As you said in your previous message, I think it is easy to make this in VBA instead of iLogic. Basically, iLogic = simple parameterization, VBA = programmation. When you need to use "Dim ..." or "xxx.yyy.zzz... " in iLogic, it's time to switch to VBA !

 

Subsidiary question : where have you found the syntax ??

 

 

Regards,

Alain

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 17 of 20 (474 Views)

Re: Open embedded XL sheet with iLogic

11-16-2012 06:19 AM in reply to: TONELLAL

Hi TONELLAL,

 

I'm glad to hear it worked for you. The object creation for excel I found as part of Curtis' code at the following link:

 

http://inventortrenches.blogspot.ca/2012/06/create-new-excel-file-with-ilogic.html

 

The rest of the code referencing the embedded file I did through the API. Once you learn how to navigate your way through the API everything becomes a lot easier.

 

Regards

Mitch

Member
andrewhaigh
Posts: 4
Registered: ‎01-30-2013
Message 18 of 20 (407 Views)

Re: Open embedded XL sheet with iLogic

04-26-2013 07:25 AM in reply to: mehatfie

Mitch,

 

I've just found your code above after searching around for a way to open a linked excel sheet - it's exactly what I was after, cheers.

 

As a follow up, do you (or anyone else here) know if there's a way to monitor the status of the linked spreadsheet?

Ideally, I'd want to run an iLogic rule when the user saves the spreadsheet.

 

I've had a look into the API in what look to me to be the relevant areas, but haven't found anything to help - although with little experience in there I think there's a good chance I could be missing something.

 

Thanks,

 

Andy.

New Member
djhunsucker
Posts: 3
Registered: ‎08-24-2007
Message 19 of 20 (66 Views)

Re: Open embedded XL sheet with iLogic

08-07-2014 11:27 AM in reply to: mehatfie

In 2014 this worked great.  In Inventor 2015, it merges the screen with excel and is unusable.  Has anyone seen a way to open an embedded spreadsheet with 2015?

 

Thanks
Dan

New Member
djhunsucker
Posts: 3
Registered: ‎08-24-2007
Message 20 of 20 (64 Views)

Re: Open embedded XL sheet with iLogic

08-07-2014 11:42 AM in reply to: djhunsucker

Incase someone else stumble across this, found a way for 2015 to like it.

I changed the last line to:

 

ExcelFile.Activate(OLEVerbEnum.kEditOpenOLEVerb, ExcelApp)
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.