Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ReferencedDocumentDescriptor.ReferencedDocument doesn't do the trick

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1652 Views, 5 Replies

ReferencedDocumentDescriptor.ReferencedDocument doesn't do the trick

Since I am a novice at VB/VBA, I expect that I am doing something wrong. Just not sure what that is?

 

In an assembly drawing with views of the top level and sub-components, what does the DrawingView.ReferencedDocumentDescriptor.ReferencedDocument property actually refer to?

 

The API Help for this property provides this description: Property that returns the model document referenced by this view.

 

I thought that it would be the document associated with whatever view I visited in the program. Apparently that is not so.

Using the following, I visited each standard view in the drawing and displayed the model descriptor in a MsgBox.

 

 

Dim oSheet as Sheet

Dim oView as DrawingView
'For each standard view

For Each oView In oSheet.DrawingViews
    If oView.ViewType = kStandardDrawingViewType Then
        Dim RefDoc As Document
        'the following only gets the assembly for the drawing document not the view document
        Set RefDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
        MsgBox ("RefDoc = ") & RefDoc              
    End If
Next 'oView

 

What I found was every view posted the same result for this property. Did I miss something?

 

Thanks,

 

 

 

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

I added a bit more to illustrate my point. Using the following on a two sheet assembly drawing, the descriptor remains the same for all views, including those of individual subcomponents but the DisplayName changes for every view to show the name of the component in the view. That seems strange to me. (Inventor 2013)

 

Dim oSheet as Sheet

Dim oView as DrawingView

        'For each standard view show label
        For Each oView In oSheet1.DrawingViews
            If oView.ViewType = kStandardDrawingViewType Then
                oView.ShowLabel = True
                Dim RefDoc As Document
                'the following only gets the assembly for the drawing document not the view document
                Set RefDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
                Dim RefDocName As String
                RefDocName = oView.ReferencedDocumentDescriptor.DisplayName
                MsgBox RefDoc & " " & RefDocName     
            End If
        Next 'oView

Message 3 of 6
Anonymous
in reply to: Anonymous

I tried your code and modified a little. Its working fine for me.

 

I have a different views of assembly and components in a single sheet.

And using the below VBA code displays the display name for the components added in the view.

 

Sub Test()
    
    Dim oDrwDoc As DrawingDocument
    Set oDrwDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDrwDoc.ActiveSheet
    
    Dim oView As DrawingViews
    Set oView = oSheet.DrawingViews

    Dim vw As DrawingView
    
    For Each vw In oSheet.DrawingViews
        If vw.ViewType = kStandardDrawingViewType Then
            vw.ShowLabel = True
            Debug.Print vw.ReferencedDocumentDescriptor.DisplayName
        End If
    Next


End Sub

 

Message 4 of 6
rjay75
in reply to: Anonymous

The line 

  MsgBox RefDoc & " " & RefDocName

is telling VBA to show a message box with with the Document object followed by the value of the document's DisplayName. RefDoc is the actual Document Object in memory of which there is not really a printable representation. The value printed isn't the document itself rather an internal identifier of the document type. In vba if you convert a document object to a string (which is what's happening in your MsgBox statement) it shows 50332160. Different programming languages may print different things by default, usually some representation of the object type.

 

So you are not getting the same document object, but showing they all reference a Document object. 

 

If you are looking to tell the difference between documents compare the FullDocumentName property.

 

Message 5 of 6
Anonymous
in reply to: Anonymous

Thank you for responding.

I wasn't having issues showing the names with the views. I was having issues understanding the value returned by ReferencedDocument.

But I see something in your line of code that poses a question that I want to research.

 

Much appreciated,

 

 

Message 6 of 6
Anonymous
in reply to: rjay75

Thank you, this is what I anticipated being the case. Because the number coming back was the same and the display names different, it seemed to point to the one document that is active as opposed to the document being referenced by the view.

 

Thank you for clarifying that point.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report