Hello eveybody,
I have a metal sheet part, I test if the the option MergeFace is checked, if not I try to chek it but it doesn't work, I dont know why ?
Here is my code :
Sub Main()
Dim swApp As SldWorks
Dim swDoc As ModelDoc2
Dim swFlatPatt As FlatPatternFeatureData
Try
swApp = CreateObject("SldWorks.Application")
swDoc = swApp.ActiveDoc
Dim swSelectedFeature As Feature = GetFeatureByName("Etat déplié1", swDoc)
swFlatPatt = swSelectedFeature.GetDefinition()
If Not swFlatPatt.MergeFace Then swFlatPatt.MergeFace = True
Catch ex As Exception
Debug.Print(ex.Message)
End Try
Console.Read()
End Sub
Function GetFeatureByName(ByVal _Name As String, swDoc As ModelDoc2) As Feature
Try
For i As Integer = 0 To swDoc.GetFeatureCount - 5
Dim swFeature As Feature = swDoc.FeatureByPositionReverse(i)
If swFeature.Name.ToUpper = _Name.ToUpper Then
Return swFeature
End If
Dim swSubFeature As Feature = swFeature.GetFirstSubFeature()
If swSubFeature Is Nothing Then Continue For
Do
If swSubFeature.Name.ToUpper = _Name.ToUpper Then
Return swSubFeature
End If
swSubFeature = swSubFeature.GetNextSubFeature
Loop Until swSubFeature Is Nothing
Next
Return Nothing
Catch ex As Exception
Throw ex
End Try
End Function
Thanks in advance.
SolidworksApi macros