Dheeraj Peddireddy

Issue with .sts on #TASK

Discussion created by Dheeraj Peddireddy on Aug 4, 2019
Latest reply on Aug 5, 2019 by Dheeraj Peddireddy

Hello, 

I'm trying to run a .sts script on a few thousand .stl files using #TASK. But it reports the error:

Generic error: This indicates that #TASK failed to run a macro. Please make sure that you can run macros in SolidWorks

 

I've run the same macro on Solidworks which works absolutely fine. I'm attaching the .sts script below:

 

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
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Part.ViewDisplayHiddengreyed

' Named View
Part.ShowNamedView2 "*Front", 1
Part.ViewZoomtofit2

' Save As
longstatus = Part.SaveAs3("%FOLDER1%\" & Part.GetTitle() & ".JPG", 0, 0)

' Named View
Part.ShowNamedView2 "*Top", 5
Part.ViewZoomtofit2

' Save As
longstatus = Part.SaveAs3("%FOLDER2%\" & Part.GetTitle() & ".JPG", 0, 0)

' Named View
Part.ShowNamedView2 "*Right", 4
Part.ViewZoomtofit2

' Save As
longstatus = Part.SaveAs3("%FOLDER3%\" & Part.GetTitle() & ".JPG", 0, 0)

swApp.CloseDoc Part.GetTitle
Set Part = Nothing
End Sub

Outcomes