How to run my ilogic on all parts in assembly?

How to run my ilogic on all parts in assembly?

kleiton.narcizo
Enthusiast Enthusiast
973 Views
3 Replies
Message 1 of 4

How to run my ilogic on all parts in assembly?

kleiton.narcizo
Enthusiast
Enthusiast

I use this code to get information of each piece, but I want to run it from the assembly, does anyone know how?

 

 

SyntaxEditor Code Snippet

ESPESSURA = SheetMetal.GetActiveStyle()
COMPRIMENTO = Round (SheetMetal.FlatExtentsLength, 0)
LARGURA = Round (SheetMetal.FlatExtentsWidth,0)
MATERIAL = iProperties.Material
FATORK = SheetMetal.ActiveKFactor

 
If COMPRIMENTO<=LARGURA  Then
TESTE = MATERIAL & " E=" & ESPESSURA & " L=" & COMPRIMENTO & " C=" & LARGURA & " FK=" & FATORK
End If

If COMPRIMENTO>=LARGURA  Then
TESTE = MATERIAL & " E=" & ESPESSURA & " L=" & LARGURA & " C=" & COMPRIMENTO & " FK=" & FATORK
End If

 

 

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

b_sharanraj
Advocate
Advocate

Hi @kleiton.narcizo

 

Does this code added in all the parts of your Master Assembly and Sub Assembly?

Regards

B.Sharan Raj

0 Likes
Message 3 of 4

Anonymous
Not applicable

This should do the trick when run from an assembly. I assumed you may have other non-sheet metal parts in the assembly, so I filtered only the sheet metal parts, another assumption made is that all the sheet metal parts have a flat pattern. Let me know how you get on with it:

 

' Get the active assembly. 
Dim oAsmDoc As AssemblyDocument 
oAsmDoc = ThisApplication.ActiveDocument

' Get all of the referenced documents. 
Dim oRefDocs As DocumentsEnumerator 
oRefDocs = oAsmDoc.AllReferencedDocuments 

' Iterate through the list of documents. 
Dim oRefDoc As Document 
  
' Check for a non-part document
If oAsmDoc.DocumentType <> kAssemblyDocumentObject Then
    MsgBox ("The Active document must be an 'Assembly'!")
    Exit Sub
End If

' Iterate through all referenced documents beneath the active assembly
For Each oRefDoc In oRefDocs

    ' Set a reference to the design tracking property set object.
    oPropertySet = oRefDoc.PropertySets.Item("Design Tracking Properties")

    If oRefDoc.ComponentDefinition.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
    
        Dim ESPESSURA As String = oRefDoc.ComponentDefinition.ActiveSheetMetalStyle.Name
        ' Get SheetMetalLength property
        Dim strCOMPRIMENTO As String = oPropertySet.Item(50).Value
        ' Convert to a rounded number
        Dim COMPRIMENTO As Decimal = Round(Decimal.Parse(strCOMPRIMENTO.Remove(strCOMPRIMENTO.Length - 2)),0)
        ' Get SheetMetalWidth property
        Dim strLARGURA As String = oPropertySet.Item(49).Value
        ' Convert to a rounded number
        Dim LARGURA As Decimal = Round(Decimal.Parse(strLARGURA.Remove(strLARGURA.Length - 2)),0)
        ' Get document material
        Dim MATERIAL As String = oRefDoc.ComponentDefinition.Material.Name
        ' Get document Kfactor
        Dim FATORK As String = oRefDoc.ComponentDefinition.UnfoldMethod.KFactor
        
        If COMPRIMENTO<=LARGURA  Then
        TESTE = MATERIAL & " E=" & ESPESSURA & " L=" & COMPRIMENTO & " C=" & LARGURA & " FK=" & FATORK
        End If
        
        If COMPRIMENTO>=LARGURA  Then
        TESTE = MATERIAL & " E=" & ESPESSURA & " L=" & LARGURA & " C=" & COMPRIMENTO & " FK=" & FATORK
        End If
        
        'MsgBox(TESTE)
    
    End If

Next

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

P.S. This will search through all referenced documents in the active assembly, so will include any parts in sub-assemblies. 

0 Likes