Macro created with the SolidWorks Macro Recorder that is not working

Hello everyone,

I just created this macro with the Solidworks macro recorder, to create a visualization cube on a part, the manual creation worked fine.

But when I want to create the visualization cube by launching the macro, no visualization cube appears and I don't know why.

Thanks in advance


macro2.swp

Hello

Your macro works.

Do you have  a "Visualization Cube" function that appears in the feature manager?

If so, check that you have the visualization cube display mode enabled,  see HERE. The easiest way is to use the Aim Up Display toolbar ().

Kind regards

Thank you d.roger,

But no, the function does not appear in the feature manager when the macro is launched

Which version of SW are you on?

And put your coins in solved mode otherwise it won't work...

Normally, the following simple macro is functional on (SW2019):

Dim swApp As Object
Dim Part As ModelDoc2
Dim BoundingBox As Object
Dim longstatus As Long

Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc

    Set BoundingBox = Part.FeatureManager.InsertGlobalBoundingBox(swGlobalBoundingBoxFitOptions_e.swBoundingBoxType_BestFit, False, False, longstatus)

End Sub

Works with either a part or an assembly loaded in SW.

Kind regards

Thank you and it's still nice a well-cleaned code unlike a code from the recorder.

In any case, I find that the code of the sld recorder gives a result that is more difficult to analyze than the Excel recorder.

But it's not very rational because I'm a fan of VBA Excel.