Rotate a flat

Rotate a flat

kv5053545
Advocate Advocate
145 Views
1 Reply
Message 1 of 2

Rotate a flat

kv5053545
Advocate
Advocate

Hi, I am working with a part that is a flat and I am trying to rotate it if the height is greater than the width, I have a code started but I do not know how to access the rotation property to rotate the flat, have you done something similar, do you know if it is possible?

kv5053545_0-1732657453051.png

 

 

 

If ThisApplication.ActiveDocument.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
    MessageBox.Show("This script only works on sheet metal (.ipt) files.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Return
End If

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition = Nothing

Try
    
    oCompDef = oDoc.ComponentDefinition
Catch ex As Exception
    MessageBox.Show("This file does not have a defined sheet metal component.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Return
End Try


If oCompDef.HasFlatPattern Then

    Dim oFlatPattern As FlatPattern = oCompDef.FlatPattern

    Dim oRangeBox As Box = oFlatPattern.RangeBox
    Dim height As Double = oRangeBox.MaxPoint.Y - oRangeBox.MinPoint.Y
    Dim width As Double = oRangeBox.MaxPoint.X - oRangeBox.MinPoint.X

    
    If height > width Then
        MessageBox.Show("The height of the Flat Pattern is greater than its width.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Else If width > height
        MessageBox.Show("The height of the Flat Pattern is not greater than its width.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information)
	Else 
		
    End If
Else
    MessageBox.Show("This file does not have a Flat Pattern defined.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If

 

 

 

 

0 Likes
146 Views
1 Reply
Reply (1)
Message 2 of 2

jnowel
Advocate
Advocate

You can access that property from FlatPatternOrientation Object

 

Dim pAngle As Inventor.Parameter = oFlatPattern.FlatPatternOrientations(1).AlignmentRotation
'Change angle to suit
pAngle.Expression = "0 deg"

 

0 Likes