Drawng How to extract an excel flie of materials and crosshatch

Drawng How to extract an excel flie of materials and crosshatch

Anonymous
Not applicable
523 Views
3 Replies
Message 1 of 4

Drawng How to extract an excel flie of materials and crosshatch

Anonymous
Not applicable

Hello,

pls can you help me on how to export via API from drawing

- List of material and crosshatch

 

IN Excel or text file

 

Thanks for helping.

Best Regards

Massimo

0 Likes
524 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

 

Are you looking for list of materials from referenced document (PartDocument/AssemblyDocument) in Drawing document?

 

List of cross hatch.png

Do you expect list of hatches as shown in above image?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

yes is it possible to get the list via API?

 

Thanks in advance, best regards

Massimo

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Try below VBA code to get list of materials from referenced document of drawing document.

  Public Sub DumpDocumentMaterials()
    ' Check that a part or assembly document is active.
    If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
        MsgBox "Current docuement is not a Drawing document"
        Exit Sub
    End If
    
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
     
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    Dim oView As DrawingView
    Set oView = oSheet.DrawingViews.Item(1)
    
    Dim doc As Document
    Set doc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    
    ' Open a file to write the results.
    Open "C:\Temp\DocumentMaterialDump.txt" For Output As #1
    
    Print #1, "Materials in " & doc.FullFileName
    
    ' Iterate through the libraries.
    Dim material As MaterialAsset
    For Each material In doc.MaterialAssets
        Print #1, "    Material"
        Print #1, "      DisplayName: " & material.DisplayName
        Print #1, "      Associated Appearance: " & material.AppearanceAsset.DisplayName
        Print #1, "      Associated Physical Properties: " & material.PhysicalPropertiesAsset.DisplayName
        Print #1, "      IsReadOnly: " & material.IsReadOnly
        Print #1, "      Name: " & material.Name
        
        Dim value As AssetValue
        For Each value In material
            Call PrintAssetValue(value, 8)
        Next
    Next
    
    Close #1
    
    MsgBox "Finished writing output to ""C:\Temp\DocumentMaterialDump.txt"""
End Sub


' Utility function that prints out information for the input asset value.
Private Sub PrintAssetValue(InValue As AssetValue, Indent As Integer)
    Dim indentChars As String
    indentChars = Space(Indent)
    
    Print #1, indentChars & "Value"
    Print #1, indentChars & "  DisplayName: " & InValue.DisplayName
    Print #1, indentChars & "  Name: " & InValue.Name
    Print #1, indentChars & "  IsReadOnly: " & InValue.IsReadOnly
    
    Select Case InValue.ValueType
        Case kAssetValueTextureType
            Print #1, indentChars & "  Type: Texture"
            
            Dim textureValue As TextureAssetValue
            Set textureValue = InValue
            
            Dim texture As AssetTexture
            Set texture = textureValue.value
            
            Select Case texture.TextureType
                Case kTextureTypeBitmap
                    Print #1, indentChars & "  TextureType: kTextureTypeBitmap"
                Case kTextureTypeChecker
                    Print #1, indentChars & "  TextureType: kTextureTypeChecker"
                Case kTextureTypeGradient
                    Print #1, indentChars & "  TextureType: kTextureTypeGradient"
                Case kTextureTypeMarble
                    Print #1, indentChars & "  TextureType: kTextureTypeMarble"
                Case kTextureTypeNoise
                    Print #1, indentChars & "  TextureType: kTextureTypeNoise"
                Case kTextureTypeSpeckle
                    Print #1, indentChars & "  TextureType: kTextureTypeSpeckle"
                Case kTextureTypeTile
                    Print #1, indentChars & "  TextureType: kTextureTypeTile"
                Case kTextureTypeUnknown
                    Print #1, indentChars & "  TextureType: kTextureTypeUnknown"
                Case kTextureTypeWave
                    Print #1, indentChars & "  TextureType: kTextureTypeWave"
                Case kTextureTypeWood
                    Print #1, indentChars & "  TextureType: kTextureTypeWood"
                Case Else
                    Print #1, indentChars & "  TextureType: Unexpected type returned"
            End Select
            
            Print #1, indentChars & "  Values"
            Dim textureSubValue As AssetValue
            For Each textureSubValue In texture
                Call PrintAssetValue(textureSubValue, Indent + 4)
            Next
        Case kAssetValueTypeBoolean
            Print #1, indentChars & "  Type: Boolean"
            
            Dim booleanValue As BooleanAssetValue
            Set booleanValue = InValue
            
            Print #1, indentChars & "    Value: " & booleanValue.value
        Case kAssetValueTypeChoice
            Print #1, indentChars & "  Type: Choice"
            
            Dim choiceValue As ChoiceAssetValue
            Set choiceValue = InValue
            
            Print #1, indentChars & "    Value: " & choiceValue.value
            
            Dim names() As String
            Dim choices() As String
            Call choiceValue.GetChoices(names, choices)
            Print #1, indentChars & "    Choices:"
            Dim i As Integer
            For i = 0 To UBound(names)
                Print #1, indentChars & "      " & names(i) & ", " & choices(i)
            Next
        Case kAssetValueTypeColor
            Print #1, indentChars & "  Type: Color"
            
            Dim colorValue As ColorAssetValue
            Set colorValue = InValue
            
            Print #1, indentChars & "  HasConnectedTexture: " & colorValue.HasConnectedTexture
            Print #1, indentChars & "  HasMultipleValues: " & colorValue.HasMultipleValues
            
            If Not colorValue.HasMultipleValues Then
                Print #1, indentChars & "  Color: " & ColorString(colorValue.value)
            Else
                Print #1, indentChars & "  Colors"
                
                Dim colors() As Color
                colors = colorValue.Values
                
                For i = 0 To UBound(colors)
                    Print #1, indentChars & "    Color: " & ColorString(colors(i))
                Next
            End If
        Case kAssetValueTypeFilename
            Print #1, indentChars & "  Type: Filename"
        
            Dim filenameValue As FilenameAssetValue
            Set filenameValue = InValue
            
            Print #1, indentChars & "    Value: " & filenameValue.value
        Case kAssetValueTypeFloat
            Print #1, indentChars & "  Type: Float"
            
            Dim floatValue As FloatAssetValue
            Set floatValue = InValue
            
            Print #1, indentChars & "    Value: " & floatValue.value
        Case kAssetValueTypeInteger
            Print #1, indentChars & "  Type: Integer"
            
            Dim integerValue As IntegerAssetValue
            Set integerValue = InValue
            
            Print #1, indentChars & "    Value: " & integerValue.value
        Case kAssetValueTypeReference
            ' This value type is not currently used in any of the assets.
            Print #1, indentChars & "  Type: Reference"
            
            Dim refType As ReferenceAssetValue
            Set refType = InValue
        Case kAssetValueTypeString
            Print #1, indentChars & "  Type: String"
            
            Dim stringValue As StringAssetValue
            Set stringValue = InValue
            
            Print #1, indentChars & "    Value: """ & stringValue.value & """"
    End Select
End Sub


' Utility function that returns a string with the R,G,B,K values for an input Color object.
Private Function ColorString(InColor As Color) As String
    ColorString = InColor.Red & "," & InColor.Green & "," & InColor.Blue & "," & InColor.Opacity
End Function

Unfortunately, Inventor API does not support to get list of hatches in drawing document. Please log this wish list at idea station using below link.

 

https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes