What's the type of a DocumentSubType? (vb.net)

What's the type of a DocumentSubType? (vb.net)

awatt
Advocate Advocate
2,077 Views
3 Replies
Message 1 of 4

What's the type of a DocumentSubType? (vb.net)

awatt
Advocate
Advocate

My help file says this:

Syntax

PresentationDocument.DocumentSubType() As DocumentSubType

 

I click the documentsubtype link, and the help browser goes nowhere.  

 

Here's the code I'm trying to write:

 

oInvApp = Marshal.GetActiveObject("Inventor.Application")

oDoc = oInvApp.ActiveDocument

 

Dim oDocSubType As ???

 

oDocSubType = oDoc.DocumentSubType

 

I tried string, and Visual Studio said it couldn't guarantee it would work.

 

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

raith-mb
Advocate
Advocate
Accepted solution

Try this:

 

Dim sDocSubType As String = oDoc.SubType

Dim sReadableType As String = "Unknown"

 

'part document sub-types

Select Case sDocumentSubType

   Case "{4D29B490-49B2-11D0-93C3-7E0706000000}"

   sReadableType = "part"

 

   Case "{28EC8354-9024-440F-A8A2-0E0E55D635B0}"

   sReadableType = "Schweiss-BG"

 

   Case "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

   sReadableType = "sheet metal"

 

   Case "{92055419-B3FA-11D3-A479-00C04F6B9531}"

   sReadableType = "generic proxy"

 

   Case "{9C464204-9BAE-11D3-8BAD-0060B0CE6BB4}"

   sReadableType = "compatibility proxy"

 

   Case "{9C88D3AF-C3EB-11D3-B79E-0060B0F159EF}"

   sReadableType = "catalog proxy"

 

   Case "{E60F81E1-49B3-11D0-93C3-7E0706000000}"

   sReadableType = "assembly"

 

   Case "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}"

   sReadableType = "drawing"

 

   Case "{62FBB030-24C7-11D3-B78D-0060B0F159EF}"

   sReadableType = "design element"

 

   Case "{76283A80-50DD-11D3-A7E3-00C04F79D7BC}"

   sReadableType = "presentation"

End Select

 

Roland

0 Likes
Message 3 of 4

philippe.leefsma
Alumni
Alumni

It's definitely a string, in most cases used to check if the document is a sheetmetal part or a weldment assembly. I don't know from where you get those values but they are most likely custom. If you want to check if the document is assembly, part or drawing, you can directly use Document.DocumentType, which is an enum.

 

Here are some VBA samples:

 

Public Sub CreateSheetMetalStyle()

    ' Set a reference to the sheet metal document.
    ' This assumes a part document is active.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument

    ' Make sure the document is a sheet metal document.
    If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
        MsgBox "A sheet metal document must be open."
        Exit Sub
    End If

.....


Private Sub CreateWeldmentAsm()

    Dim template As String
    template = ThisApplication.FileManager.GetTemplateFile(kAssemblyDocumentObject, _
                 kDefaultSystemOfMeasure, _
                 kDefault_DraftingStandard, _
                 "{28EC8354-9024-440F-A8A2-0E0E55D635B0}")

    Dim asm As AssemblyDocument
    Set asm = ThisApplication.Documents.Add(kAssemblyDocumentObject, template)
                
    If (asm.SubType = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}") Then
        Debug.Print "Weldment Assembly"
    End If
        
End Sub

Why don't you use the offline help? It's clearly indicated that subType is a string:

 

Screen Shot 2015-05-06 at 10.29.01 PM.png

 

Hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 4

awatt
Advocate
Advocate

I think what you've both shown is what I eventually did, successfully.

 

But there's still somethging wierd in the offline help.

Following the link I've circled leads me to a dead end.  Page not found.temppic.png