Automate ipart member drawings updates after member generation

Automate ipart member drawings updates after member generation

briant.markham
Enthusiast Enthusiast
659 Views
6 Replies
Message 1 of 7

Automate ipart member drawings updates after member generation

briant.markham
Enthusiast
Enthusiast

I have lots of ipart factories with hundreds of ipart members, and it is really easy to make a change to the factory and re-generate the member files, but to get the drawings to update requires each drawing to be manually opened in inventor and manually saved. This seems like a ridiculus limitation, there has to be some way to automate the drawing updates either through a macro or ilogic, any help would be greatly appreciated. Thanks

0 Likes
Accepted solutions (1)
660 Views
6 Replies
Replies (6)
Message 2 of 7

philip1009
Advisor
Advisor

Is there a drawing for each member or is there a drawing with a table driven by the master part?  Are the drawings located in the same folder as the members?

0 Likes
Message 3 of 7

briant.markham
Enthusiast
Enthusiast

There is a separate complete drawing for each member and the drawings are located in the same directory as the members. A drawing with a table wouldn't cover the range of parts that this covers.

0 Likes
Message 4 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support

@briant.markham,

 

Can you please provide sample iPart factory with 2 members along with drawings to test? Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 7

briant.markham
Enthusiast
Enthusiast

sure.

0 Likes
Message 6 of 7

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@briant.markham,

 

Sorry for late reply,

 

Hoping that below VBA code may be helpful. To update drawings, run below VBA code at iPartFactory.

Sub Update_Drawings()

    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    If oDef.IsiPartFactory = True Then
        Dim iPartCell As iPartTableCell
        Dim cnt As Integer
        cnt = oDef.iPartFactory.FileNameColumn.Count
        Dim i As Integer
        For i = 1 To cnt
            Set iPartCell = oDef.iPartFactory.FileNameColumn.Item(i)
            Call Update_Memeber_Drawing(oDef.iPartFactory.MemberCacheDir, iPartCell.Value)
        Next
        
    Else
        MsgBox ("Part document is not iPart Factory")
        Exit Sub
    End If
    
End Sub

Sub Update_Memeber_Drawing(dir_Name As String, memberName As String)
    
    Dim oMemeber_path As String
    oMemeber_path = dir_Name & "\" & memberName & ".dwg"
    
    ThisApplication.SilentOperation = True
    
    Dim oDrawdoc As DrawingDocument
    Set oDrawdoc = ThisApplication.Documents.Open(oMemeber_path, False)
    
    Call oDrawdoc.Update
    
    Call oDrawdoc.Save
    
    Call oDrawdoc.Close
    
    ThisApplication.SilentOperation = False
    
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 7

briant.markham
Enthusiast
Enthusiast

That worked great except I had to add some code between update and save that did a check and loop till the update had fully taken effect.

 

Thanks

0 Likes