SheetMetal.FlatExtents in a loop

SheetMetal.FlatExtents in a loop

Anonymous
Not applicable
358 Views
2 Replies
Message 1 of 3

SheetMetal.FlatExtents in a loop

Anonymous
Not applicable

Could someone help me modify the below code to pull the flat length & width extents from each sheet metal part in my For loop ? It returns 0 for both at the moment.

For Each oRow As BOMRow In oBOMRows
	
		oRowCompDef = oRow.ComponentDefinitions.Item(1)
		
		If oRowCompDef.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
			Dim oCD As SheetMetalComponentDefinition = oRowCompDef
			
			FlatLength = SheetMetal.FlatExtentsLength
			FlatWidth = SheetMetal.FlatExtentsWidth
			
			MsgBox(oRowCompDef.Document.DisplayName & vbLf & "Length = " & FlatLength & vbLf & "Width = " & FlatWidth)
			
		End If
Next

 

0 Likes
359 Views
2 Replies
Replies (2)
Message 2 of 3

marcin_otreba
Contributor
Contributor

try:

 

For Each oRow As BOMRow In oBOMRows
    
        oRowCompDef = oRow.ComponentDefinitions.Item(1)
        
        If oRowCompDef.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
            Dim oCD As SheetMetalComponentDefinition = oRowCompDef
            
            FlatLength = ocd.FlatPattern.Length
            FlatWidth = ocd.FlatPattern.Width
            
            MsgBox (oRowCompDef.Document.DisplayName & vbLf & "Length = " & FlatLength & vbLf & "Width = " & FlatWidth)
            
        End If
Next

0 Likes
Message 3 of 3

YuhanZhang
Autodesk
Autodesk

Try below code:

 

For Each oRow As BOMRow In oBOMRows
    
        oRowCompDef = oRow.ComponentDefinitions.Item(1)
        
        If oRowCompDef.Document.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
            Dim oCD As SheetMetalComponentDefinition = oRowCompDef
            
            If oCD.HasFlatPattern Then
                Dim oFlatPattern As FlatPattern
                oFlatPattern = oCD.FlatPattern
        
                FlatLength = oFlatPattern.Length
                FlatWidth = oFlatPattern.Width
        
            End If
            
            MsgBox (oRowCompDef.Document.DisplayName & vbLf & "Length = " & FlatLength & vbLf & "Width = " & FlatWidth)
            
        End If
Next


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes