Set Default Row in iPart Sub-Component

Set Default Row in iPart Sub-Component

solson
Advocate Advocate
876 Views
2 Replies
Message 1 of 3

Set Default Row in iPart Sub-Component

solson
Advocate
Advocate

I have a customer that has a linked parameter between an iPart Factory and another component in the assembly.  The iPart is a piece of pipe and the part with a linked parameter is a lining for the pipe.  The issue that I am facing is that the users have to open the pipe to get the lining to update.  What I discovered is that the active pipe member in the assembly has to be the active member in the iPart Factory IPT.  The reason for this, is that the needed member needs to be the active member in the factory so that the pipe broadcasts the correct ID to the lining.  

 

We tried several approaches, including have iLogic open the member or the iPart Factory.  We tried all kinds of code that would update.  I am fairly certain that if I can use iLogic to set the needed row as the Default Row in the iPart Factory everything else will work.  I am struggling to get iLogic to set the Default Row.  I have seen sample code that shows that you need to have the Row Object to use the iPartFactory.DefaultRow function.  I am certain that is what I have in my code now, but for some reason the code is not working.  I continually get a message stating that it could not find the member.  

 

I know that one solution would to be use iLogic to pass parameters from the pipe to the lining, but my customer would prefer not to use that approach.

 

I have built a simplified version of the scenario I am seeing, and will attach the file to this post (the sample was made in Inventor 2015).  Any advice would be greatly appreciated.


Steve Olson
Manager, Training Services
https://knowledge.autodesk.com/profile/O37DF451BDD2485B
https://www.youtube.com/channel/UCgQTCawsuRFJVSHRXIwLdtg
0 Likes
Accepted solutions (1)
877 Views
2 Replies
Replies (2)
Message 2 of 3

Balaji_Ram
Alumni
Alumni
Accepted solution

Hello,

 

Here is a VBA code snippet that worked ok in setting the default row and the linked parameter caused an update.

In the following code, the index values may need to be modified to suit your needs.

 

    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    
    Dim iRow As Integer
    iRow = 3
                
    Dim occ As ComponentOccurrence
    Set occ = asmDoc.ComponentDefinition.Occurrences(2)
  
    Dim partCompDef1 As PartComponentDefinition
    Set partCompDef1 = occ.Definition
    
    If partCompDef1.IsiPartMember Then
        Dim factoryDoc As PartDocument
        Set factoryDoc = partCompDef1.iPartMember.ReferencedDocumentDescriptor.ReferencedDocument
      
        Dim partCompDef2 As PartComponentDefinition
        Set partCompDef2 = factoryDoc.ComponentDefinition
        
        ' Set the default row in the factory document
        If partCompDef2.IsiPartFactory Then
            Dim oTableRow As iPartTableRow
            Set oTableRow = partCompDef2.iPartFactory.TableRows.Item(iRow)
            partCompDef2.iPartFactory.DefaultRow = oTableRow
            Debug.Print oTableRow.MemberName & " has been made default"
        End If
                
        Dim newRow As Long
        newRow = iRow
        Call occ.ChangeRowOfiPartMember(newRow)
    End If

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

solson
Advocate
Advocate

Balaji,

 

Thank you very much for taking your time to supply this code.  It accomplishes the desired task.

 

Steve


Steve Olson
Manager, Training Services
https://knowledge.autodesk.com/profile/O37DF451BDD2485B
https://www.youtube.com/channel/UCgQTCawsuRFJVSHRXIwLdtg
0 Likes