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: 

How to use embedded excel file

4 REPLIES 4
Reply
Message 1 of 5
Gwennberg
3486 Views, 4 Replies

How to use embedded excel file

Hi

I have used the command "insert object" to embed an excel sheet. I can see in the modelbar the new stage called "3rd Party", expanded I also see "Embedding 1". If I use edit I can se my excel sheet. So far good.

 

My next task is to creat a Rule to recall cells in the sheet. I use the command CellValue (embedded) to pick my cell value. My problem is that then I close my rule-editor I got the error:

Error in rule: Rule0, in document: Box test.ipt

GoExcel: 3rd Party worksheet not found: "3rd Party:Embedding 1", Sheet: "Sheet1"

 

It seems like I´m not able to recall my cellvalues. Whats wrong?

 

Whats the diffrens between embedding a excelsheet as above or use the add link command i Parameters window?

 

BR/Goran

Tags (1)
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Gwennberg

I'm not sure what language you're doing this in, but here's my code for accessing cells from an embedded excel sheet in C#.  It's a rather lengthy process to set the Excel object, workbook, sheet objects properly.  See the last 3 lines of code for how to write/read excel values.  value2 is the most important part. value2 returns the value of the cell. value I believe would return the formula of the cell.

 

 

Inventor.Application oApp = null;
oApp = System.Runtime.InteropServices.Marshal.GetActiveObject ("Inventor.Application") as Inventor.Application;
ReferencedOLEFileDescriptor oOleRef = null;

//this loops through each inserted table. It will open the excel sheet with the proper name
for (int i = 0; i < oApp.ActiveDocument.ReferencedOLEFileDescriptors.Count; i++)
{
	if (oApp.ActiveDocument.ReferencedOLEFileDescriptors[i + 1].DisplayName == "NameOfTableYouAreLookingFor")
	{
		oOleRef = oApp.ActiveDocument.ReferencedOLEFileDescriptors[i + 1];
		break;
	}
}
Object retObj = null;

//opens the spreadsheet
oOleRef.Activate (OLEVerbEnum.kEditOpenOLEVerb, out retObj);

Workbook oWB = (Workbook)retObj;
Worksheet oSheet = (Worksheet)oWB.Sheets[sheetNameHere];

//Specify cell value here. For an example I used cell A32
Range idRange = oSheet.get_Range ("A32");

//set value2 of the cell to what you want to insert
idRange.Value2 = "text to insert";

//if you plan to read from the cell, do this
var retrievedValue = idRange.Value2

 

Message 3 of 5
SteveX82
in reply to: Gwennberg

For reasons unknown, iLogic can only find this embedded spreadsheet if you Embed it via the "Link" button on the Parameters list. Inserting the spreadsheet via the "Insert Object" command, which does exactly the same thing to your browser, produces an entirely different result.

 

Also, don't try editing your spreadsheet's name in your browswer, as iLogic will insist on referring to it by the name by which it was originally placed.

 

It doesn't make any sense to me, either....

Message 4 of 5
cj
Community Visitor
in reply to: Anonymous

I have recently migrated from Mech Desktop to Inventor Pro 2013 x64 and am endeavouring to do a similar thing without success.  I tried using the code you kindly listed in a new iLogic rule but it rejected virtually every line.

So I wondered if you could please assist me to achieve the following.

I have a rule as follows:

If Type = "Large" Then

Model_Type = "Large_Energy_Cell"

ElseIf Type = "Medium" Then

Model_Type = "Medium_Energy_Cell"

ElseIf Type = "Small" Then

Model_Type = "Small_Energy_Cell”

End If

I have a linked Excel spreadsheet that lists the value of my User Parameters with 3 rows of values with Model_Type being in cell A1 and Large_Energy_Cell etc. in cells A2 to A4.

I want to be able to drive the value of my User Parameters from the spreadsheet according to which of the 3 options is selected in Model_Type within my user parameters. My 3rdParty value is Embedding 1. 

I am also unsure if my User Parameters have to be multi-list with the 3 value options?

All the tutorials seem only to write the parameter values to a spread sheet rather than vice versa.

Your kind assistance would be greatly appreciated. Thank you.

Message 5 of 5
Anonymous
in reply to: cj

Unfortunately, it makes sense that it rejected nearly every line.  The code example I gave is in C#.  That means it would be useful for anyone using a .net language (C# or VB.NET).  I don't know much about iLogic, but I believe there's a different procedure for accessing an embedded Excel.  

 

I found this post. Maybe it will help you some: http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Embedded-Spreadsheets-and-iLogic/td-p/...

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

Post to forums  

Autodesk Design & Make Report