Hello,
I am trying to modify a macro to complete a lengthy task on 3000 files. What I am trying to accomplish is to open a part or assembly( might use #task to batch)
set to diametric view, zoom to fit, set wire frame view, rotate part, force rebuild, then last is save as png.
I am getting a compile error right now with the codes I have put together.
I would appreciate any help getting this to work, I am definitely lacking training on API SW2017 sp5
Here are my codes
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant
Dim sConfigName As String
Dim sPath As String
Dim i As Long
Dim bRebuild As Boolean
Dim bRet As Boolean
Sub Main()
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
swApp.SendMsgToUser2 "Please open a PART file!", swMbWarning, swMbOk
Exit Sub
End If
Set swModelView = swModel.ActiveView
Part.ShowNamedView2 "*Dimetric", 9
Part.ViewZoomtofit2
swModel.ViewDisplayWireframe
swModelView.RollBy (Degrees2Radians(-90)) ' Roll the model view by the specified angle
bRebuild = swModel.ForceRebuild3(False) 'Rebuild the current part
sPath = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\")) 'Get the path
swModel.SaveAs (sPath & ".png") 'Save as .png
Next
End Sub
---------------------------------------------------------------------------
this is the module for rotating parts
Function Degrees2Radians(ByVal DegVal As Double) As Double
Dim Pi As Double
Pi = 3.14159265359
Degrees2Radians = DegVal * 180 / Pi
SolidworksApi macros