Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Leonardo_Czuy
361 Views, 6 Replies

Check If PartDocumentObject is Structural Profiles

Hello,

I am trying to find a way to retrieve parts that use only structural profiles, which are located in the Content Center under the Structural Profile category. With the approach I've taken, I can ignore Plates, but for example, if a part is a Screw, it still enters the list.

 

 

Sub Main()
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
    Dim fileTXT = System.IO.File.CreateText(ThisDoc.Path & "\SaveFOlder\materialProfiles.txt")

    For Each oDoc In oAsmDoc.AllReferencedDocuments
        ' Se for arquivo de Montagem Ignora
        If oDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
            Continue For
        End If

        ' Se for arquivo de chapa ignora
        If oDoc.ComponentDefinition.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then
            Continue for
        End If

        Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition

        Dim materialProfile As String
        materialProfile = oDef.Material.Name

        If materialProfile = "Genérico" Then Continue For
        If materialProfile = "GRATING" Then Continue For

        Dim codeProfile As String
        codeProfile = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)

        Dim stockNumber As String
        stockNumber = iProperties.Value(System.IO.Path.GetFileName(oDoc.FullFileName), "Project", "Stock Number")

        Dim quantityProfile As Integer
        quantityProfile = oAsmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).Count

        
        fileTXT.WriteLine(codeProfile & " - " & stockNumber & quantityProfile)

    Next
    fileTXT.Close()

End sub