Macros Intermittently Not Working
Macros Intermittently Not Working
(OP)
Hi
We've been having a bit of an issue running macros. The problem dates back to the 1st computer we had running a 64bit OS, which is a long time ago in a Windows and SolidWorks version far far away.
When it first started, it would happen at some point during the day, normally after having some large assembly open. All of our macros that we have created here stop working, SolidWorks just displays a message saying Cannot open "file path, \macro.dll"
Restarting SolidWorks would solve the problem.
Now we are running 64bit on pretty much all of our stations, and it's becoming a big problem. Restarting SolidWorks does not always fix the issue now, and it happens a lot.
I've tried re-compiling the code and that seems to fix it, but it doesn't last long.
The machines it is happening on are all decent spec, and not getting anywhere near their limits.
Any ideas?
We've been having a bit of an issue running macros. The problem dates back to the 1st computer we had running a 64bit OS, which is a long time ago in a Windows and SolidWorks version far far away.
When it first started, it would happen at some point during the day, normally after having some large assembly open. All of our macros that we have created here stop working, SolidWorks just displays a message saying Cannot open "file path, \macro.dll"
Restarting SolidWorks would solve the problem.
Now we are running 64bit on pretty much all of our stations, and it's becoming a big problem. Restarting SolidWorks does not always fix the issue now, and it happens a lot.
I've tried re-compiling the code and that seems to fix it, but it doesn't last long.
The machines it is happening on are all decent spec, and not getting anywhere near their limits.
Any ideas?






RE: Macros Intermittently Not Working
We have run into this before when upgrading from 2008 to 2009. All of a sudden recursives didn't work (it would grab random data and use it to return some rather interesting results) along with some other commands. That issue and the fact that the macros all of a sudden ran 20% to 30% slower has meant we are afraid to update to later versions. The macros had to be rewritten to get around it and no one has the time to do that every year.
The most bizzarre thing is that most of our macro crashes now occur on file handling stuff (like close or open).
Some SolidWork VBA commands just don't work (such as anything to do with modifying the hole wizzard and some Simulation stuff).
The only way I was able to find work arounds was to run it a lot in debug mode and find out where the code was crashing. This can be hard because sometimes it will not crash in debug as much as in normal mode.
Once you find out where, you can program around it (usually).
RE: Macros Intermittently Not Working
If I start debugging, nothing happens. I have to hit stop.
RE: Macros Intermittently Not Working
James Spisich
Design Engineer, CSWP
RE: Macros Intermittently Not Working
You can also set toggles to stop it.
The F8 step by step will show you where it hangs up.
John
RE: Macros Intermittently Not Working
I've passed the problem on to my VAR, but they're struggling with it. I find it strange that it's not a common issue, we've been coping with it for years.
RE: Macros Intermittently Not Working
You don't say what kind of macros you are running. ( swp, vbproj, csproj )
TOP
CSWP, BSSE
www.engtran.com www.niswug.org
www.linkedin.com/in/engineeringtransport
Phenom IIx6 1100T = 8GB = FX1400 = XP64SP2 = SW2009SP3
"Node news is good news."
RE: Macros Intermittently Not Working
RE: Macros Intermittently Not Working
TOP
CSWP, BSSE
www.engtran.com www.niswug.org
www.linkedin.com/in/engineeringtransport
Phenom IIx6 1100T = 8GB = FX1400 = XP64SP2 = SW2009SP3
"Node news is good news."
RE: Macros Intermittently Not Working
-----
Imports SolidWorks.Interop.sldworks
Imports System
Imports System.Diagnostics
Imports System.Text
Partial Class SolidWorksMacro
Private Sub SolidWorksMacro_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Dim sb As New StringBuilder
Try
Me.swApp = Me.SolidWorksApplication
Catch exStartup As Exception
sb.Length = 0
sb.AppendLine(exStartup.Message)
sb.AppendLine()
sb.AppendLine(exStartup.StackTrace)
System.Diagnostics.Debug.WriteLine(sb.ToString())
System.Windows.Forms.MessageBox.Show(sb.ToString(), "1")
End Try
Dim runResult As SolidWorks.RunMacroResult = RunMacro()
If (runResult = SolidWorks.RunMacroResult.NoneSpecified) Then
Try
SwMacroSetup()
Catch exSetup As Exception
sb.Length = 0
sb.AppendLine(exSetup.Message)
sb.AppendLine()
sb.AppendLine(exSetup.StackTrace)
System.Diagnostics.Debug.WriteLine(sb.ToString())
System.Windows.Forms.MessageBox.Show(sb.ToString(), "2")
End Try
main()
Try
SwMacroCleanup()
Catch exCleanup As Exception
sb.Length = 0
sb.AppendLine(exCleanup.Message)
sb.AppendLine()
sb.AppendLine(exCleanup.StackTrace)
System.Diagnostics.Debug.WriteLine(sb.ToString())
System.Windows.Forms.MessageBox.Show(sb.ToString(), "3")
End Try
End If
End Sub
Private Sub SolidWorksMacro_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
End Class
-----
I don't really have the time at the moment to test it out, and I'm not experienceing the problem at the moment, but I thought I'd post the code up in case anyone else finds it useful.
RE: Macros Intermittently Not Working