AnsweredAssumed Answered

Isometric + zoom to fit + rebuild + save

Question asked by Hrituc Alexandru on Aug 25, 2015
Latest reply on Oct 19, 2016 by Sanya Shmidt

Hi,

I want to have a macro button which when i press it to make Isometric + zoom to fit + rebuild + save to model, to assembly and even to drawing if is possible...

How can make this?... Now it works only with parts.

 

 

 

' Preconditions: Model document is open.

 

' Postconditions: Current view mode is changed to isometric and Zoom to Fit.

 

 

 

Option Explicit

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Set swApp = CreateObject("SldWorks.Application")

    Set swModel = swApp.ActiveDoc

     Dim boolstatus          As Boolean

    Dim lErrors             As Long

    Dim lWarnings           As Long

    Dim Part As Object

   

    ' Not quite the same as when done through the user interface;

    ' model is zoomed out a bit further

 

    swModel.ShowNamedView2 "*Isometric", -1

 

    ' Now view the same as done through the user interface

 

    swModel.ViewZoomtofit2

    boolstatus = swModel.EditRebuild3()

    boolstatus = swModel.ForceRebuild3(True)

    boolstatus = swModel.Save3(swSaveAsOptions_Silent, lErrors, lWarnings)

 

 

End Sub

Outcomes