
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to create an iLogic rule that contains a loop. Each time the loop runs, I want the rule to output a set of values from my part model to an Excel spreadsheet, creating a table of values.
For example, my part is the fluid inside a large bucket (not the real part because of confidentiality). I can split / slice the part with an offset plane, removing the portion of the part above the plane. I want the code to move the offset plane by some increment, record the offset distance and the volume of the part after the split to the spreadsheet (say, cells A4 and B4), then loop through this process, writing the next values into the next cells (A5 & B5) until the the offset distance exceeds the height of the bucket. At the end, it would save and close the Excel file. The table of X-Offset and Y-Volume values could be viewed, printed, charted or otherwise used from within Excel.
Using this code, I was able to create a loop that moved the plane by my desired increment. But, I could not figure out how to increment the cell addresses from one loop to the next. I ended up with just (2) values, located in the original (2) cells (A4 & B4).
i = 0 Offset = i * (1 in / 1 ul) GoExcel.Open("Table.xlsx", "Sheet1") String1 = "A4" String2 = "B4" GoExcel.CellValue("Table.xlsx", "Sheet1", String1) = Offset GoExcel.CellValue("Table.xlsx", "Sheet1", String2) = iProperties.Volume Do Until Offset > Height + 1 GoExcel.CellValue("Table.xlsx", "Sheet1", String1) = Offset GoExcel.CellValue("Table.xlsx", "Sheet1", String2) = iProperties.Volume i = i + Inc Offset = i * (1 in / 1 ul) A = Val(String1) + Inc String1 = Left(String1,1) & CStr(A) String2 = Left(String2,1) & CStr(A) Continue Do Exit Do Loop GoExcel.Save GoExcel.Close
Any help on this would be appreciated.
Steven
Solved! Go to Solution.