6 Replies Latest reply on Apr 11, 2013 1:12 PM by Jason Bardis

    Macro Help: iso view, change units options, save, close

    Jason Bardis

      Hi-

       

      I've been banging my head against this macro all day & have been tantalizingly close to getting it to work for pretty much all day...I'll leave out all the dead ends & teases that got me this far.

       

       

      My crawling goal: for the current open document, make the view iso, change units in Tools/Options/Document Settings to IPS & Length .12345678, then save, then close.

       

      My walking goal: for all of the current open documents, do the same for all.

       

       

      My macro seems to meet my crawling goal if I have just 1 part document open but not if several are open. My macro also doesn't seem to work on assembly files.

       

      Thank you,

      -Jason

       

       

       

      ' ******************************************************************************

      ' C:\Users\jbardis\AppData\Local\Temp\swx6980\Macro1.swb - macro recorded on 04/09/13 by jbardis

      ' ******************************************************************************

      Dim vModelName As Variant

      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

       

       

      'Activate iso view

      Part.ShowNamedView2 "*Isometric", 7

       

       

      'Change Tools/Options/Units system to IPS & Precision to .12345678

      boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem, 0, swUnitSystem_e.swUnitSystem_IPS)

      boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropDecimalPlaces, 0, 8)

       

       

      'Save

      Part.ForceRebuild3 True

      Part.Save2 Silent

       

       

      'Close

      swApp.QuitDoc vModelName

       

       

       

       

      End Sub