MACRO LIBRARY

Get the normal data for a face

Free public access. No account or subscription required.

Files

Associated model(s) Get the normal data for a face

Code

'Gets the normal value of a selected face
    
'Preconditions: face is selected
'Results: see immediate window
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFace As SldWorks.Face2
Dim swSelMgr As SldWorks.SelectionMgr
Dim vNormal As Variant
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swFace = swSelMgr.GetSelectedObject6(1, -1)
    vNormal = swFace.Normal
    Debug.Print Round(vNormal(0), 3) & ", " & Round(vNormal(1), 3) & ", " & Round(vNormal(2), 3)
    
    'to flip normal, multiple normal vector by -1
    
End Sub
    
'From IFeatureManager::FeatureExtrusion2
'Default for cut operations: opposite sketch normal
'Default for boss operations: with sketch normal
    
'The default sketch normal is the same as the face or plane normal
    
'In IFeatureManager::FeatureCut3, the default direction for the cut is opposite of sketch _
    normal. So set this argument to True to go opposite of face normal, which should cut _
    into the part. Vice versa for a boss extrusion.