Retrieve grain direction [SOLVED]

Hi guys,
does anyone know if it is possible to retrieve the grain direction in a flat-pattern-feature?

Hey Amen,
now I had the time to test it. It works very well. Thanks for your support!

Sure, here is my small script for testing:

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim featureMgr As FeatureManager
Dim selectMgr As selectionMgr

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set featureMgr = swModel.FeatureManager
Set selectMgr = swModel.SelectionManager

Dim vFeatures As Variant
Dim vFeature As Variant
Dim swFeature As Feature
Dim swEdge As Edge
Dim swFace As Face2
Dim selType1 As Long
Dim selType2 As Long

vFeatures = featureMgr.GetFeatures(False)

For Each vFeature In vFeatures

    Set swFeature = vFeature
    
    If swFeature.GetTypeName2 = "FlatPattern" Then
        
        swFeature.Select2 False, -1
        swModel.FeatEditDef
                
        selType1 = selectMgr.GetSelectedObjectType3(1, -1)
        selType2 = selectMgr.GetSelectedObjectType3(2, -1)
        
        If selType1 = swSelEDGES Then
            Debug.Print "Selection1 is Edge"
            
        ElseIf selType1 = swSelFACES Then
            Debug.Print "Selection1 is Face"
            
        End If
        
        If selType2 = swSelEDGES Then
            Debug.Print "Selection2 is Edge"
            
        ElseIf selType2 = swSelFACES Then
            Debug.Print "Selection2 is Face"
            
        End If
        
        swModel.ForceRebuild3 True
    End If
    
Next vFeature

End Sub```

Just did a quick search in the API docs. I thought IFlatPatternFeatureData would have something but apparently not.

Your best bet is to open the PMP and make sure the grain selection box is highlighted some that you can get what edge or sketch line is selected with the the selection manager. I’m pretty sure the mark is 1 or 2 counting from the top of the PMP controls.

Hope this helps!

this is a great idea… i will try and let you know!

@Marcel Would it be possible to share the code enabling this function? I’m also interested in it so that I can show it on a layout. (Or better partial code)
Thanks