TWiesendanger
9/7/2018 - 2:06 PM

Nullen in Stückliste entfernen

oToggle = InputRadioBox("Select an option", "Clear Zeros", _
"Restore Zeros", False, "iLogic")
 
 
 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
 
' Set a reference to the first parts list on the active sheet.
' This assumes that a parts list is on the active sheet.
Dim oPartList As PartsList
 
Try
    oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
Catch
    MessageBox.Show("No Parts List found.", "iLogic")
    Return 'exit rule
End Try
 
 
'[ wrap In a transaction
'define application
oApp = ThisApplication
 
Call oApp.TransactionManager.StartTransaction(ThisDoc.Document, "Parts List Zeros")
 
 
'progress bar
Dim iRowCount As Integer
iRowCount = oPartList.PartsListRows.Count
Dim iStepCount As Integer
iStepCount = iRowCount * oPartList.PartsListColumns.Count
Dim oDelay As Integer
oDelay = 25    
Dim oProgressBar As Inventor.ProgressBar       
oMessage = "Updating... "
oProgressBar = ThisApplication.CreateProgressBar(False, iStepCount, oMessage)
oProgressBar.Message = ("Loading... " )
System.Threading.Thread.Sleep(oDelay)
                 
' Iterate through the contents of the parts list   
    Dim i As Long
    'look at each row
    For i = 1 To iRowCount
    oRow  = oPartList.PartsListRows.Item(i)
             
        'look at each column in the row
        Dim j As Long
        For j = 1 To oPartList.PartsListColumns.Count
            'look at the cell value
            Dim oCell As PartsListCell
            oCell = oRow.Item(j)   
            If oToggle = True Then
                If oCell.Value = "0" Then
                    oCell.Value = "" 'clear
                End If         
            Else
                If oCell.Value = "" And oCell.Static = True Then
                    oCell.Value = "0" 'set to zero
                End If
            End If
            'update progress bar
            oProgressBar.Message = _
            ("Processing Row " & i & " of " & iRowCount)
            oProgressBar.UpdateProgress
            System.Threading.Thread.Sleep(oDelay)
         
        Next   
     
    Next
oProgressBar.Close
 
oApp.TransactionManager.EndTransaction
']