AnsweredAssumed Answered

Solidworks macro how to start new blank assembly model and save as new name

Question asked by John Weakley on Nov 4, 2013
Latest reply on Apr 12, 2014 by Vijay Kumar

I'm having trouble using the macro recorder, after it's recorded and played back, it only performs half of the recorded macro.

The "Save As" portion never completes.

Any help would be much appreciated.

Here is what I recorded:



Imports SolidWorks.Interop.sldworks

Import SolidWorks.Interop.swconst

Imports System.Runtim.InteropServices

Imports System


Partial Class SolidWorksMacro


     Public Sub main()


          Dim swDoc As ModelDoc2 = Nothing

          Dim swPart As PartDoc = Nothing

          Dim swDrawing As DrawingDoc = Nothing

          Dim swAssembly As AssemblyDoc = Nothing

          Dim boolstatus As Boolean = False

          Dim longstatus As Integer = 0

          Dim longwarnings As Integer = 0


          swDoc = CType(swApp.NewDocument("P:\templates\Assmebly.asmdot", 0, 0, 0), ModelDoc2)

          swApp.ActivateDoc2("Assem1", False, longstatus)


          Dim myModelView As ModelView = Nothing

          myModelView = CType(swDoc.ActiveView, ModelView)

          myModelView.FramState = CType(swWindowState_e.swWindowMaximized, Integer)

          longstatus = swDoc.SaveAs3("C:\Users\User1\Desktop\1234.SLDASM", 0, 2)


     End Sub


  ''' <summary>

  ''' The SldWorks swApp variable is pre-assigned for you.

  ''' </summary>

  Public swApp As SldWorks



End Class