Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: rikard.nilsson

Rikard,

 

Your solution worked. I made a couple adjustments based on the outputs I was getting in my Excel file.

 

1) When the plane offset was 0, Inventor was reporting the "full" volume. To correct this, I dumped the "full" volume into a new parameter value that is written into the last volume cell after the loop is finished. I also added another line to rewrite the volume at the 0 offset to be 0 gallons.

2) The iProperties.Volume value is in cubic inches. Therefore, I added some math to convert the cubic inches into gallons and rounded the figure to 1 decimal place.

3) I eliminated the "+1" at the beginning of the loop statement. This eliminated 1 loop from the sequence.

 

The final version of the iLogic code is pasted below.

 

InventorVb.DocumentUpdate()
Feature.IsActive("Split1") = True

i = 0
Parameter("Offset") = i * (1 in / 1 ul)
GoExcel.Open("Table.xlsx", "Sheet1")
String1 = "A4"
String2 = "B4"

GoExcel.CellValue(String1) = Parameter("Offset")
GoExcel.CellValue(String2) = Round(iProperties.Volume / 231, 1)
Parameter("Full") = Round(iProperties.Volume / 231, 1)

Height = H2H
Inc = 1

Do Until Parameter("Offset") > Height
        GoExcel.CellValue(String1) = Parameter("Offset")
        GoExcel.CellValue(String2) = Round(iProperties.Volume / 231, 1)
        i = i + Inc
        Parameter("Offset") = i * (1 in    / 1 ul)
        
        Dim myChars() As Char = String1.ToCharArray()
        Dim resultString As String = ""
        For Each ch As Char In myChars
             If Char.IsDigit(ch) Then
                  resultString = resultString & ch
             End If
        Next
        A = CStr(resultString) + Inc
        String1 = Left(String1,1) & CStr(A)
        String2 = Left(String2,1) & CStr(A)

        InventorVb.DocumentUpdate(False)    'required to get current mass properties
Loop

GoExcel.CellValue(String1) = Parameter("Offset")
GoExcel.CellValue(String2) = Parameter("Full")
GoExcel.CellValue("B4") = 0

GoExcel.Save
GoExcel.Close

Feature.IsActive("Split1") = False

 

I am very grateful for your time and expertise in helping me solve this. I will mark this topic as "Accepted Solution"

 

Sincerely,

Steven