<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting data from a spreadsheet with 2 dimension array in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11437029#M142936</link>
    <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/45931"&gt;@steveh3&lt;/a&gt;.&amp;nbsp; I didn't have time to create a complete solution for you today, but I did create something to get you further along in your project.&amp;nbsp; It is difficult to get data from Excel in a 2-dimensional array using iLogic's built-in GoExcel functions, so I opted for digging into Excel's API for this one.&amp;nbsp; This will get the Excel data to a 2D array for you.&amp;nbsp; Then just to show you that it worked, I included a message at the end that shows you the values across the last line of data.&amp;nbsp; The comparisons and filtering can be added later.&lt;/P&gt;
&lt;P&gt;This is the code I have for you right now.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;AddReference "Microsoft.Office.Interop.Excel.dll"
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Sub Main
	Dim oFile As String = "C:\Temp\Wheel_database.xlsx"
	Dim oSheet As String = "FormedPlates"
	'start a new instance of Excel
	Dim oExcel As New Excel.Application
	oExcel.DisplayAlerts = False
	oExcel.Visible = True
	Dim oWB As Workbook = oExcel.Workbooks.Open(oFile)
	Dim oWS As Worksheet = oWB.Sheets.Item(oSheet)
	'specify the range of cells in that sheet you want to read into memory
	Dim oRange As Range = oWS.Range("A1:D32")
	'create 2-dimensional array of Object, and set the range's values into it
	Dim oArray(, ) As Object = oRange.Value
	'read from an array by specifying row, then column, both starting with 1
	Dim oLastRowData As String
	oLastRowData = oArray(32, 1).ToString
	oLastRowData = oLastRowData &amp;amp; " &amp;lt;&amp;gt; " &amp;amp; oArray(32, 2).ToString
	oLastRowData = oLastRowData &amp;amp; " &amp;lt;&amp;gt; " &amp;amp; oArray(32, 3).ToString
	oLastRowData = oLastRowData &amp;amp; " &amp;lt;&amp;gt; " &amp;amp; oArray(32, 4).ToString
	MsgBox("oLastRowData = " &amp;amp; oLastRowData,,"")
	
	oWS = Nothing
	oWB.Close
	oWB = Nothing
	'oExcel.Quit
	oExcel = Nothing
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Sep 2022 19:07:15 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2022-09-21T19:07:15Z</dc:date>
    <item>
      <title>Getting data from a spreadsheet with 2 dimension array</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11436782#M142931</link>
      <description>&lt;P&gt;Hello Gang...&lt;/P&gt;&lt;P&gt;I have a spreadsheet which has two dimensions OD and BC.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="steveh_1-1663779670855.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1118898i905AB4CFB5EB20A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="steveh_1-1663779670855.png" alt="steveh_1-1663779670855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For the DimC, I would like to gather all the rows where OD is greater than or equal to the DimC value chosen in the form (grey hi-lited cells).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then also do the same for the BC. Select all rows where BC is greater than or equal to MaxBC (yellow hi-lited cells).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then the result for AvailableDiscs would be the intersection of the two sets (green hi-lited). This would then show up in the form as what would be available to chose.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the form and spreadsheet set up, but I can't figure out how to dynamically update the Listing of AvailableDiscs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="steveh_2-1663779995871.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1118900i369B6B5662BF646C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="steveh_2-1663779995871.png" alt="steveh_2-1663779995871.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm assuming this is possible?&lt;/P&gt;&lt;P&gt;I have included the .ipt and spreadsheet as attachments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Steve H.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 17:12:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11436782#M142931</guid>
      <dc:creator>steveh3</dc:creator>
      <dc:date>2022-09-21T17:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data from a spreadsheet with 2 dimension array</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11437029#M142936</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/45931"&gt;@steveh3&lt;/a&gt;.&amp;nbsp; I didn't have time to create a complete solution for you today, but I did create something to get you further along in your project.&amp;nbsp; It is difficult to get data from Excel in a 2-dimensional array using iLogic's built-in GoExcel functions, so I opted for digging into Excel's API for this one.&amp;nbsp; This will get the Excel data to a 2D array for you.&amp;nbsp; Then just to show you that it worked, I included a message at the end that shows you the values across the last line of data.&amp;nbsp; The comparisons and filtering can be added later.&lt;/P&gt;
&lt;P&gt;This is the code I have for you right now.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;AddReference "Microsoft.Office.Interop.Excel.dll"
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Sub Main
	Dim oFile As String = "C:\Temp\Wheel_database.xlsx"
	Dim oSheet As String = "FormedPlates"
	'start a new instance of Excel
	Dim oExcel As New Excel.Application
	oExcel.DisplayAlerts = False
	oExcel.Visible = True
	Dim oWB As Workbook = oExcel.Workbooks.Open(oFile)
	Dim oWS As Worksheet = oWB.Sheets.Item(oSheet)
	'specify the range of cells in that sheet you want to read into memory
	Dim oRange As Range = oWS.Range("A1:D32")
	'create 2-dimensional array of Object, and set the range's values into it
	Dim oArray(, ) As Object = oRange.Value
	'read from an array by specifying row, then column, both starting with 1
	Dim oLastRowData As String
	oLastRowData = oArray(32, 1).ToString
	oLastRowData = oLastRowData &amp;amp; " &amp;lt;&amp;gt; " &amp;amp; oArray(32, 2).ToString
	oLastRowData = oLastRowData &amp;amp; " &amp;lt;&amp;gt; " &amp;amp; oArray(32, 3).ToString
	oLastRowData = oLastRowData &amp;amp; " &amp;lt;&amp;gt; " &amp;amp; oArray(32, 4).ToString
	MsgBox("oLastRowData = " &amp;amp; oLastRowData,,"")
	
	oWS = Nothing
	oWB.Close
	oWB = Nothing
	'oExcel.Quit
	oExcel = Nothing
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 19:07:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11437029#M142936</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2022-09-21T19:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data from a spreadsheet with 2 dimension array</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11437243#M142943</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/45931"&gt;@steveh3&lt;/a&gt;&amp;nbsp;I made some adjustments to the Excel sheet to do some of the calculations for you. The form in the part file now updates to the available options, by selecting your two parameter inputs at the top of the form &amp;amp; then clicking the update button. The only thing that you will need to change to test this out is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DiscSelector.ipt --&amp;gt; ParametersChosen Rule --&amp;gt; oExcelFileName (the correct path to your excel file)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See if this is what you're looking for.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 20:58:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11437243#M142943</guid>
      <dc:creator>tyler.warner</dc:creator>
      <dc:date>2022-09-21T20:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data from a spreadsheet with 2 dimension array</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11441106#M143047</link>
      <description>&lt;P&gt;Thanks Gentlemen....&lt;/P&gt;&lt;P&gt;I was able to take your logic and it worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve H.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 12:18:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/getting-data-from-a-spreadsheet-with-2-dimension-array/m-p/11441106#M143047</guid>
      <dc:creator>steveh3</dc:creator>
      <dc:date>2022-09-23T12:18:08Z</dc:date>
    </item>
  </channel>
</rss>

