01-26-2024
09:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-26-2024
09:16 AM
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
Solved! Go to Solution.