Hi! I'm by no means an expert, but I've cobbled together a rendering macro. When run, it exports .bmps of all configurations and named views of a part or assembly to a chosen folder.
The issue is, when I have a decently complex part or assembly, it sometimes just renders empty screens. You'll see that it has a pause in it to give everything a chance to build, but even when I extend that pause to a very long time, it will still occasionally give me an empty screen. It seems to be a little random which configurations fail to export.
Here's the relevant section of code, and the macro in its entirety is attached:
'Goes through all named views and configurations and renders them to .BMP
For u = 10 To UBound(vNamedViewArr)
sViewName = vNamedViewArr(u)
rebuild = swModel.ForceRebuild3(True)
swModel.GraphicsRedraw2
swModel.ViewZoomtofit2
bShowView = swModel.ShowNamedView2(sViewName, -1)
For i = 0 To UBound(vConfNameArr)
sConfigName = vConfNameArr(i)
bShowConfig = swModel.ShowConfiguration2(sConfigName)
rebuild = swModel.ForceRebuild3(True)
swModel.GraphicsRedraw2
swModel.ViewZoomtofit2
Sleep 3000
'Access PhotoView 360
Set swRayTraceRenderer = swApp.GetRayTraceRenderer(swPhotoView)
Set swRayTraceRenderOptions = swRayTraceRenderer.RayTraceRendererOptions
'Display render window (not necessary for the macro to work but it takes so long that you'll think your computer is frozen otherwise)
rendering = swRayTraceRenderer.DisplayPreviewWindow
'sets location and title to the chosen location and configuration name
fileLocName = fileLoc & sConfigName & " " & sViewName
'exports in BMP format
swRayTraceRenderOptions.ImageFormat = swImageFormat_WindowsBmp
status = swRayTraceRenderer.RenderToFile(fileLocName, 0, 0)
'Close Photoview 360
rendering = swRayTraceRenderer.CloseRayTraceRender
Next i
Next u
SolidworksApi/macros