iLogic edit

iLogic edit

Anonymous
Not applicable
337 Views
3 Replies
Message 1 of 4

iLogic edit

Anonymous
Not applicable

Hi everyone! I'm in the process of learning the utmost basics of iLogics and how to write rules. The person who previously did that at our company has left, and i've now been asked to modify some of his old rules. He had made a script to create a rev table, we now want to modify that rev table. After looking at the script i found where the parameters were set, and after trying to modify to add another column and change the name of an existing one it just won't work. There must be something I'm missing, and I dont know how fast i can learn to solve this problem. If any one could help me out by pointing out where i've overlooked something that would be fantastic. Thank you! 

 

ORIGINAL SCRIPT:

 

SyntaxEditor Code Snippet

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

    'Look for partlist within drawing. End rule, if it doesn't exist.
    'say there is a Partslist on the sheet.
    Dim oRevisionTables As RevisionTables
    oRevisionTables = oSheet.RevisionTables
    
    If oRevisionTables.Count = 0 Then

        Dim oLocation As Point2d
        oLocation = ThisApplication.TransientGeometry.CreatePoint2d(6.667, 3.173)
        
        oRevisionTables.Add(oLocation)
    
    End If
    
           Dim oRevisionTable As RevisionTable = oRevisionTables.Item(1)
        
        If oRevisionTable.RevisionTableColumns.Count = 5 Then
        oRevisionTable.RevisionTableColumns.Item(1).Delete
         
           End If
              
           Dim oRevisionTableColumn As RevisionTableColumn
        Dim oColumnName As String
        Dim oWidth As Double
        Dim oContents As String
        
        For Each oRevisionTableColumn In oRevisionTable.RevisionTableColumns
        oColumnName = oRevisionTableColumn.Title

               If oColumnName = "REV" Then
               oWidth = .875
               oRevisionTableColumn.Width = oWidth
               End If 
               If oColumnName = "DESCRIPTION" Then
               oWidth = 5
               oRevisionTableColumn.Width = oWidth
               End If 
               If oColumnName = "DATE" Then
               oWidth = 2
               oRevisionTableColumn.Width = oWidth
               End If
               If oColumnName = "APPROVED" Then
               oWidth = 2
               oRevisionTableColumn.Width = oWidth
               End If
       
         Next

    'toggle parts list heading placement
          If oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtBottom Then
          oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtTop
          Else
        oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtBottom
          End If        

      'toggle parts list direction
          If oRevisionTable.TableDirection = oRevisionTable.TableDirection.kBottomUpDirection Then
        oRevisionTable.TableDirection = oRevisionTable.TableDirection.kTopDownDirection
         Else
        oRevisionTable.TableDirection = oRevisionTable.TableDirection.kBottomUpDirection
         End If
        
        Dim oRow As RevisionTableRow
        oRow = oRevisionTable.RevisionTableRows.Item(oRevisionTable.RevisionTableRows.Count)
        ' Make sure we have the active row
            If oRow.IsActiveRow Then     
           
                Dim oCell1 As RevisionTableCell = oRow.Item(1)
                oCell1.Text = "0"
    
                Dim oCell2 As RevisionTableCell = oRow.Item(2)
    '                    'Set it equal to the user name on the open application        
                oCell2.Text= "INITIAL RELEASE"
            
                Dim oCell3 As RevisionTableCell = oRow.Item(3)
                'Set it equal to the the current date        
                oCell3.Text= "" 'DateTime.Now.ToString("d")
                
                Dim oCell4 As RevisionTableCell = oRow.Item(4)
                'Set it equal to the the current date        
                oCell4.Text= ""
        
            End If

 

MODIFIED (underligned where changed)

 

SyntaxEditor Code Snippet

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

    'Look for partlist within drawing. End rule, if it doesn't exist.
    'say there is a Partslist on the sheet.
    Dim oRevisionTables As RevisionTables
    oRevisionTables = oSheet.RevisionTables
    
    If oRevisionTables.Count = 0 Then

        Dim oLocation As Point2d
        oLocation = ThisApplication.TransientGeometry.CreatePoint2d(6.367, 3.173)
        
        oRevisionTables.Add(oLocation)
    
    End If
    
           Dim oRevisionTable As RevisionTable = oRevisionTables.Item(1)
        
        If oRevisionTable.RevisionTableColumns.Count = 5 Then
        oRevisionTable.RevisionTableColumns.Item(1).Delete
         
           End If
              
           Dim oRevisionTableColumn As RevisionTableColumn
        Dim oColumnName As String
        Dim oWidth As Double
        Dim oContents As String
        
        For Each oRevisionTableColumn In oRevisionTable.RevisionTableColumns
        oColumnName = oRevisionTableColumn.Title

               If oColumnName = "REV" Then
               oWidth = .875
               oRevisionTableColumn.Width = oWidth
               End If 
               If oColumnName = "DESCRIPTION" Then
               oWidth = 5
               oRevisionTableColumn.Width = oWidth
               End If 
               If oColumnName = "DATE" Then
               oWidth = 2
               oRevisionTableColumn.Width = oWidth
               End If
               If oColumnName = "DESIGN BY" Then
               oWidth = 2
               oRevisionTableColumn.Width = oWidth
               End If
               If oColumnName = "CHECK BY" Then
               oWidth = 2
               oRevisionTableColumn.Width = oWidth
               End If
            
       
         Next

    'toggle parts list heading placement
          If oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtBottom Then
          oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtTop
          Else
        oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtBottom
          End If        

      'toggle parts list direction
          If oRevisionTable.TableDirection = oRevisionTable.TableDirection.kBottomUpDirection Then
        oRevisionTable.TableDirection = oRevisionTable.TableDirection.kTopDownDirection
         Else
        oRevisionTable.TableDirection = oRevisionTable.TableDirection.kBottomUpDirection
         End If
        
        Dim oRow As RevisionTableRow
        oRow = oRevisionTable.RevisionTableRows.Item(oRevisionTable.RevisionTableRows.Count)
        ' Make sure we have the active row
            If oRow.IsActiveRow Then     
           
                Dim oCell1 As RevisionTableCell = oRow.Item(1)
                oCell1.Text = "0"
    
                Dim oCell2 As RevisionTableCell = oRow.Item(2)
    '                    'Set it equal to the user name on the open application        
                oCell2.Text= "INITIAL RELEASE"
            
                Dim oCell3 As RevisionTableCell = oRow.Item(3)
                'Set it equal to the the current date        
                oCell3.Text= "" 'DateTime.Now.ToString("d")
                
                Dim oCell4 As RevisionTableCell = oRow.Item(4)
                'Set it equal to the the current date        
                oCell4.Text= ""
                
                Dim oCell5 As RevisionTableCell = oRow.Item(5)
                'Set it equal to the the current date        
                oCell5.Text= ""
        
            End If
 

 

0 Likes
338 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

1. The methodology used looks awful, and doesn't really follow the standard workflow of using styles to accomplish things. This system is wholly based on overrides.

 

2. Try this:

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument 
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

    'Look for partlist within drawing. End rule, if it doesn't exist.
    'say there is a Partslist on the sheet.
    Dim oRevisionTables As RevisionTables
    oRevisionTables = oSheet.RevisionTables
    
    If oRevisionTables.Count = 0 Then
        Dim oLocation As Point2d
        oLocation = ThisApplication.TransientGeometry.CreatePoint2d(6.367, 3.173)
        oRevisionTables.Add(oLocation)
    End If
    
       Dim oRevisionTable As RevisionTable = oRevisionTables.Item(1)
        
 '       If oRevisionTable.RevisionTableColumns.Count = 5 Then
 '           oRevisionTable.RevisionTableColumns.Item(1).Delete
 '       End If
              
        Dim oRevisionTableColumn As RevisionTableColumn
        Dim oColumnName As String
        Dim oWidth As Double
        Dim oContents As String
        
        For Each oRevisionTableColumn In oRevisionTable.RevisionTableColumns
               'oColumnName = oRevisionTableColumn.Title
               Select Case oRevisionTableColumn.Title
                   Case "REV"
                       oWidth = .875
                       oRevisionTableColumn.Width = oWidth
                   Case "DESCRIPTION"
                       oWidth = 5
                       oRevisionTableColumn.Width = oWidth
                   Case "DATE"
                       oWidth = 2
                       oRevisionTableColumn.Width = oWidth
                   Case "DESIGN BY" Then
                       oWidth = 2
                       oRevisionTableColumn.Width = oWidth
                   Case "CHECK BY" Then
                       oWidth = 2
                       oRevisionTableColumn.Width = oWidth
               End Select 
         Next

    'toggle parts list heading placement
          If oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtBottom Then
          oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtTop
          Else
        oRevisionTable.HeadingPlacement = oRevisionTable.HeadingPlacement.kHeadingAtBottom
          End If        

      'toggle parts list direction
          If oRevisionTable.TableDirection = oRevisionTable.TableDirection.kBottomUpDirection Then
        oRevisionTable.TableDirection = oRevisionTable.TableDirection.kTopDownDirection
         Else
        oRevisionTable.TableDirection = oRevisionTable.TableDirection.kBottomUpDirection
         End If
        
        Dim oRow As RevisionTableRow
        oRow = oRevisionTable.RevisionTableRows.Item(oRevisionTable.RevisionTableRows.Count)
        ' Make sure we have the active row
            If oRow.IsActiveRow Then     
           
                Dim oCell1 As RevisionTableCell = oRow.Item(1)
                oCell1.Text = "0"
    
                Dim oCell2 As RevisionTableCell = oRow.Item(2)
    '                    'Set it equal to the user name on the open application        
                oCell2.Text= "INITIAL RELEASE"
            
                Dim oCell3 As RevisionTableCell = oRow.Item(3)
                'Set it equal to the the current date        
                oCell3.Text= "" 'DateTime.Now.ToString("d")
                
                Dim oCell4 As RevisionTableCell = oRow.Item(4)
                'Set it equal to the the current date        
                oCell4.Text= ""
                
                Dim oCell5 As RevisionTableCell = oRow.Item(5)
                'Set it equal to the the current date        
                oCell5.Text= ""
        
            End If

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

Anonymous
Not applicable

 

It produced the same issue we keep getting with the modifications that we've done too. No better. But thank you for taking a look. Knowing that it 'looks aweful' too helps to know that it could be done better. Like i had mentioned, this is all completely new to me and im not sure if it's 100% worth learning because it might just be simpler and more cost effective to have someone write the script for us. 

0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor

Even with the lines commented out so that it's not deleting the first column?

 

I would check and see when you place the default revision block via the UI how many columns it has in and such.

 

Revising the styles would be the proper way to affect this change. It would then mean you could cut out about 85% of the code and accomplish the same thing.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes