VBA Command for Update List of Mechanically Welded Items

I made a macro to launch the SmartProperties automatically on each Mechanically Welded Article.

It works well.
 

On the other hand, it is necessary to update the list of Mechanically Welded Articles before otherwise it doesn't work...

Anyone know the VBA command (or macro) to perform this update?

 

(I've already tried to record a macro and click on the command, but it doesn't leave anything in the macro created...)

 

Thank you for your help

 

PS: I'm on SolidWorks 2013

Hello

 

There is a VBA example in the SolidWorks Help!

 

http://help.solidworks.com/2013/English/api/sldworksapi/Update_Weldment_Cut_List_and_Fire_Post-Notify_Event_Example_VB.htm

In fact, it looks like the 1st link is for "Fire Post-Notify Event Example".

 

This forum talks about the update:

https://forum.solidworks.com/thread/47038

Thank you for your help.

I found this: https://forum.solidworks.com/thread/69294

 

A little more precise than yours.

But I'm stuck on the "saltMgr"... What does it correspond to?

The line Set selMgr = Part.SelectionManager simply allows you to "get" (sort of select) the part in the selMgr object .

This is necessary for the smooth running of the macro.

That didn't work...

 

 

Dim Part As ModelDoc2
Dim myPart As PartDoc
Dim myCutlist As BodyFolder
Dim myFeature As Feature

    Set swapp = Application.SldWorks
    Set Part = swapp. ActiveDoc
    If part is nothing then exit sub
    If Part.GetType <> 1 Then Exit Sub
  
    Set myPart = Part
    Set selMgr = Part.SelectionManager
    If myPart.IsWeldment = false then exit sub
    Set myFeature = myPart.FeatureByName("Solid Bodies")
    Set myCutlist = myFeature.GetSpecificFeature2
    myCutlist.UpdateCutList

"Solid Bodies" is the name of the folder in English!

http://help.solidworks.com/2012/English/SolidWorks/sldworks/Organizing_Solid_Bodies.htm

Did you replace "Solid Bodies" with the name of your folder (like "body list" or "welded parts list")?

 

 

No, even with the French name, it doesn't work.
So I did a macro search of the CutList folder with your first link.

Now it's working at the top, thank you

____________________________________

Sub maj()
    While Not swFeat Is Nothing
        If swFeat.GetTypeName2 = "SolidBodyFolder" Then
                    Dim swBodyFolder As SldWorks.BodyFolder
                    Set swBodyFolder = swFeat.GetSpecificFeature2
                    swBodyFolder.UpdateCutList
        End If
            Set swFeat = swFeat.GetNextFeature
    Wend
End Sub

1 Like

-