×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro to delete a group in a structural member

Macro to delete a group in a structural member

Macro to delete a group in a structural member

(OP)
Hi everyone,
I have a welded part with a "Structural Member1" that contains 2 groups of 2 segments each, and
I would like to delete/remove one of the group. (and/or remove one segment in one of the groups)

I have found one macro to create a weldment, and one to modify the profil, but none for that. Anyone has an idea?

So far I have this macro that gives me the number of groups and their number of segments:

CODE --> VBA

Dim swApp As Object
Dim swPart As Object
Dim boolstatus As Boolean
Dim swWeldFeat As Feature
Dim swWeldFeatData As StructuralMemberFeatureData
Dim group As StructuralMemberGroup
Dim vgroups As Variant

Sub main()
Set swApp = Application.SldWorks
Set swPart = swApp.ActiveDoc

boolstatus = swPart.Extension.SelectByID2("Structural Member1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Set swWeldFeat = swPart.SelectionManager.GetSelectedObject6(1, 0)
Set swWeldFeatData = swWeldFeat.GetDefinition

boolstatus = swWeldFeatData.AccessSelections(swPart, Nothing)

Debug.Print swWeldFeatData.GetGroupsCount()
vgroups = swWeldFeatData.Groups

Set group = vgroups(0)
Debug.Print group.GetSegmentsCount

Set group = vgroups(1)
Debug.Print group.GetSegmentsCount

boolstatus = swWeldFeat.ModifyDefinition(swWeldFeatData, swPart, Nothing)

End Sub 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources