ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
MCMichael Caulton30/07/2021

I am trying to update the flat pattern features fixed face to the currently selected face using the API in VBA.

Running the SW example I can get the API to select the current face but I cannot seem to set the fixed face to the user selected face.

Does anyone have any ideas what I need to do to update the fixed face?


VBA CODE BELOW


Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSelFace As SldWorks.Face2

Sub main()
 
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
 
' Get user selected face - a face must be selected
Set swSelMgr = swModel.SelectionManager
Set swSelFace = swSelMgr.GetSelectedObject5(1)
 
' Find FlatPattern feature in tree
Set swFeat = swModel.FirstFeature
While Not swFeat Is Nothing
If swFeat.GetTypeName2 = "FlatPattern" Then
 
'Get FlatPattern feature
Dim swFlatPatt As SldWorks.FlatPatternFeatureData
Set swFlatPatt = swFeat.GetDefinition
 
' SET THE FIXED FACE TO BE THE USER SELECTED FACE
 
' THIS DEOS NOT CHANGE THE FIXED FACE
swFlatPatt.FixedFace = swSelFace
 
End
 
End If
Set swFeat = swFeat.GetNextFeature
Wend

End Sub