Identify parts created by Frame Generator with DocumentInterests object

By Wayne Brill

If you are trying to determine if an assembly has been created with the Frame Generator use the DocumentInterests object of the document. This object has a hasinterest method that takes a GUID and returns a Boolean. The GUID to use is the following:

{AC211AE0-A7A5-4589-916D-81C529DA6D17}

VBA Example:

Sub docOfInterestTest()
    If ThisApplication.Documents.count = 0 _
                               Then Exit Sub
    Dim oDocInts As DocumentInterests
    Set oDocInts = ThisApplication. _
        ActiveDocument.DocumentInterests
    Dim bHasInterest As Boolean
    bHasInterest = oDocInts.hasinterest _
    ("{AC211AE0-A7A5-4589-916D-81C529DA6D17}")
 
    If bHasInterest Then
        Dim odocint As DocumentInterest
        For Each odocint In oDocInts
            ‘Will be FrameDoc for the
            ‘frame document
            Debug.Print odocint.Name
         
        Next
    End If
End Sub

VB.NET

Public Class Form1             Dim m_inventorApp As Inventor.Application _                                          = Nothing             Private Sub Button1_Click(ByVal sender As  _                                    System.Object, _                      ByVal e As System.EventArgs) _                            Handles Button1.Click                 ' Get an active instance of Inventor            Try                m_inventorApp = System.Runtime. _                       InteropServices.Marshal. _           GetActiveObject("Inventor.Application")                 Catch 'Inventor not started                System.Windows.Forms.MessageBox. _                 Show("Start an Inventor session")                Exit Sub            End Try                 'Call the Sub            docOfInterestTest()        End Sub             Sub docOfInterestTest()            If m_inventorApp.Documents.Count = 0 _                                       Then Exit Sub            Dim oDocInts As DocumentInterests            oDocInts = m_inventorApp. _                ActiveDocument.DocumentInterests            Dim bHasInterest As Boolean            bHasInterest = oDocInts.hasinterest _            ("{AC211AE0-A7A5-4589-916D-81C529DA6D17}")                 If bHasInterest Then                Dim odocint As DocumentInterest                For Each odocint In oDocInts                    'Will be FrameDoc for the                &#160
;   'frame document                    Debug.Print(odocint.Name)                     Next            End If        End Sub    End Class

Comments

3 responses to “Identify parts created by Frame Generator with DocumentInterests object”

  1. Hi,
    I’m starting to develop some macros with VBA. I used your code to know if an assembly or part is a Frame and it work fine.
    My problem is after to have duplicate these documents.
    I duplicate documents and replace all file by code and it seem to work fine but if I try to modify the model using Frame Generator it reply with an error.
    I need to know how to handle frame generator by code to complete my code, can you help me?

  2. In the .zip you can see 2 assembly document:
    10118166 original assembly (it work fine)
    10118166 duplicate assembly (frame generator don’t work)
    https://www.dropbox.com/s/zfa0we2a9wkemzr/ARCHIVIO.zip?dl=0
    Thanks

  3. Wayne Brill Avatar
    Wayne Brill

    Hi Valerio,
    Please create a post on the Inventor customization forum for this issue.
    http://forums.autodesk.com/t5/inventor-customization/bd-p/120
    In your new post please include the link to this post. Also let me know the link to your new post in the forum and I will reply to the post in the customization forum.
    Thanks,
    Wayne

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading