The macro recorder indeed doesn't record changes to a weldment. It does record creating structural members though, that helped me to get started. I haven't worked with them either, but here's the route I think you should follow:
- You can traverse the feature tree until you get to a feature where GetTypeName2 equals WeldMemberFeat
- You can then use swFeat.GetDefinition and put that into a StructuralMemberFeatureData object.
- Use that to get to the groups
- Change the sketch segments in the groups
Another thing I found: you can use the IFeatureManager object to add groups, members and other weldment items.
as you suggested code is written as :
Later no idea how to make the change to remove group OR to add new skech in the existing group. Also tried for modifydefinition but nothing happened.
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim boolstatus As Boolean
Dim FeatMgr As FeatureManager
Dim SelMgr As SelectionMgr
Dim swWeldFeat As SldWorks.Feature
Dim swWeldFeatData As SldWorks.StructuralMemberFeatureData
Dim Group2 As StructuralMemberGroup
Dim j, i As Integer
Dim vGroups As Variant
Dim vSegments As Variant
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set FeatMgr = Part.FeatureManager
Set SelMgr = Part.SelectionManager
Dim myFeature As Object
boolstatus = Part.Extension.SelectByID2("Structural Member1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Set swWeldFeat = SelMgr.GetSelectedObject6(1, 0)
Set swWeldFeatData = swWeldFeat.GetDefinition
vGroups = swWeldFeatData.Groups
Set Group2 = vGroups(1)
Debug.Print " Segment Count in Group " & i + 1 & " : " & Group2.GetSegmentsCount; ""
Debug.Print " Rotational angle of group: " & Group2.Angle
Debug.Print " ApplyCornerTreatment: " & Group2.ApplyCornerTreatment
Debug.Print " CornerTreatmentType: " & Group2.CornerTreatmentType
Debug.Print " MirrorProfile: " & Group2.MirrorProfile
Debug.Print " MirrorProfileAxis: " & Group2.MirrorProfileAxis
Debug.Print " GapWithinGroup: " & Group2.GapWithinGroup
vSegments = Group2.Segments
For j = LBound(vSegments) To UBound(vSegments)
My colleague suggested to not create sketch pattern, only create pattern of "Structure Member1",
and is working fine.