Ilogic to change punch row in sheet metal part

Ilogic to change punch row in sheet metal part

yvandelafontaine
Advocate Advocate
891 Views
3 Replies
Message 1 of 4

Ilogic to change punch row in sheet metal part

yvandelafontaine
Advocate
Advocate

Good day all,

 

I have a iFeature that i use in as a punch in sheet metal (center hole with 3 tapped hole around)

I found how to change a table driven ifeature row using logic in a model part, but when i try to do the same using a table driven punch feature in sheetmetal it gives me error.

 

how do i do to get a punch feature to change row???

0 Likes
Accepted solutions (1)
892 Views
3 Replies
Replies (3)
Message 2 of 4

sajith_subramanian
Autodesk Support
Autodesk Support
Accepted solution

Hello yvandelafontaine,

 

Table-driven ifeatures may not be supported when inserted as a punch tool. 

 

Link to a similar discussion.

http://forums.autodesk.com/t5/inventor-forum/problem-using-ilogic-and-ifeature-changerow/m-p/6464113...

 

However as a workaround, you may implement it using the Inventor API. Following is a sample code snippet that does something similar

 

Sub changerow()

 

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
   
' This assumes that the punch tool feature is selected before running this code.
Dim oPunchTool As PunchToolFeature
Set oPunchTool = oPartDoc.SelectSet(1)

 

Dim rowtobeset As iFeatureTableRow
Set rowtobeset = oPunchTool.iFeatureDefinition.iFeatureTable.iFeatureTableRows.Item(4) ' Selecting the fourth row in this case.
oPunchTool.iFeatureDefinition.ActiveTableRow = rowtobeset

 

End Sub

 

Also, if you may want to convert the above VBA code into iLogic, please refer below link.

 

http://adndevblog.typepad.com/manufacturing/2015/11/convert-vba-to-net-ilogic.html

 

 

Let me know if this helps.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
Message 3 of 4

yvandelafontaine
Advocate
Advocate

I work great, but now how do i find a specific row in a specific column?

 

I want to use the "TYPE" column to look for a specific name in there. (see attached .ide above)

I would be making an oTYPE argument defined by an "If" condition to set the string value of "oTYPE"

 

I've seen in the iFeatureTable Object in the API Help that i can look for a column but I don't quite understand how to use it.

0 Likes
Message 4 of 4

sajith_subramanian
Autodesk Support
Autodesk Support

Hello yvandelafontaine,

 

Below is a sample code from the API help document that does something similar.

 

Public Sub EditTableDriveniFeature()
    ' Get the part document and component definition of the active document.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument
    If Err Then
        MsgBox "A part must be active."
        Exit Sub
    End If

    Dim oFeatures As PartFeatures
    Set oFeatures = oPartDoc.ComponentDefinition.Features

    ' Get the first iFeature assuming that it is table-driven.
    Dim oiFeature As iFeature
    Set oiFeature = oFeatures.iFeatures.Item(1)
    
    ' Check to see if the first iFeature is table-driven.
    If Not oiFeature.iFeatureDefinition.IsTableDriven Then
        MsgBox "The first iFeature in the part is not table-driven."
        Exit Sub
    End If
    
    '** Look through the table to find the row where "Size" is "3".
    Dim oTable As iFeatureTable
    Set oTable = oiFeature.iFeatureDefinition.iFeatureTable
    
    ' Find the "Size" column.
    Dim oColumn As iFeatureTableColumn
    Dim bFoundSize As Boolean
    bFoundSize = False
    For Each oColumn In oTable.iFeatureTableColumns
        If oColumn.DisplayHeading = "Size" Then
            bFoundSize = True
            Exit For
        End If
    Next
    
    If Not bFoundSize Then
        MsgBox "The column ""Size"" was not found."
        Exit Sub
    End If
    
    ' Find the row in the "Size" column with the value of "3"
    Dim oCell As iFeatureTableCell
    bFoundSize = False
    For Each oCell In oColumn
        If oCell.Value = "3" Then
            bFoundSize = True
            Exit For
        End If
    Next
    
    If Not bFoundSize Then
        MsgBox "The cell with value ""3"" was not found."
        Exit Sub
    End If
    
    oiFeature.iFeatureDefinition.ActiveTableRow = oCell.Row
End Sub

 

Let me know if this helps.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes