Solidworks VBA Graphics Refresh

Hi all

 

How do I cancel the graphics refresh on the solidworks VBA? like on VBA excel code "application.screenupdating = false"

Thank you in advance for your answers,

 

Julian.

 

Hello

By recording a macro and right-clicking on the name of an assembly and selecting "Interrupt  automatic rebuild", I got this code:

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Asemblage.SLDASM", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Part.EnableAssemblyRebuild = True
End Sub

The command to use is therefore Part.EnableAssemblyRebuild = True

Hello

OptiSW: That's not what Julien is looking for.

The EnableAssemblyRebuild  command  only suspends the rebuild as shown here: http://help.solidworks.com/2016/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.iassemblydoc~enableassemblyrebuild.html

 

Julian:

Several options are described here: http://help.solidworks.com/2016/english/api/sldworksapi/solidworks_visible_or_background_example_vb.htm

Personally I use: swApp. Visible = True. But this doesn't quite match Excel's ScreenUdating. Since this makes the application invisible instead of freezing it...

Sorry for the late reply,

 

Indeed it is not quite what I am looking for,

 

I did some research on the internet and there is this "EnableGraphicsUpdate" but it doesn't work in my code,

1 Like

Hello

Normal because the EnableGraphicsUpdate  method does not apply to the application but to the ModelView which is only the representation of your model.

See here: http://help.solidworks.com/2016/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.imodelview~enablegraphicsupdate.html

1 Like

Hello

 

So there's no code that prevents the graphical refresh for the application directly,

 

the goal was to save calculation time because on my macro I insert a note, I create a PDF of the drawing and I delete the note at the end,

if there is no solution too bad I will leave the macro as it is now,

 

Thank you for your answers,