Description
- Creates eight custom-named ISO views (based on front, right, back, and left, viewed from top and bottom).
- Enables quicker, consistent access to ISO views beyond the standard two.
System Requirements
- SOLIDWORKS Version: SOLIDWORKS 2014 or newer
- Operating System: Windows 7 or later
Pre-requisites
- An open document of SOLIDWORKS must be active.
- It is best to use a 3D model, as the ISO views generated will represent geometric perspectives with meaning and use.
Results
- Eight ISO views are generated, and the name is customized for easy identification and use.
- The macro will then delete any previously named views that have the same eight names before creating them, giving us a set of custom ISO views that will not cause duplicates.
Steps to Implement the Macro
- Open the File: You should have a 3D model file open in SOLIDWORKS where ISO views can be meaningfully generated.
- Load and Run the Macro:
- Using the Macro:
VBA Macro Code
' Disclaimer:
' The code provided should be used at your own risk.
' Blue Byte Systems Inc. assumes no responsibility for any issues or damages that may arise from using or modifying this code.
' For more information, visit [Blue Byte Systems Inc.](https://bluebyte.biz).
' *********************************************************
' Description:
' This macro creates a series of isometric views and saves them as named views in the active SolidWorks document.
' *********************************************************
Sub main()
' Declare SolidWorks application and document variables
Dim swApp As Object ' SolidWorks application object
Dim Part As Object ' Active document object
Dim boolstatus As Boolean ' Boolean to capture status (not used in this macro)
Dim longstatus As Long ' Long status for operations (not used in this macro)
Dim Annotation As Object ' Annotation object placeholder (not used here)
Dim Gtol As Object ' Geometric tolerance object placeholder (not used here)
Dim DatumTag As Object ' Datum tag object placeholder (not used here)
Dim FeatureData As Object ' Feature data placeholder (not used here)
Dim Feature As Object ' Feature object placeholder (not used here)
Dim Component As Object ' Component object placeholder (not used here)
' Initialize SolidWorks application and active document
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
' Check if a document is open
If Part Is Nothing Then
MsgBox "No active document found. Please open a model.", vbExclamation, "Error"
Exit Sub
End If
' Define mathematical constants and view transformations
pi = 4 * Atn(1) ' Value of π (pi)
Z = Tan(30 * pi / 180) ' Tangent of 30 degrees
X = Atn(Z / Sqr(-Z * Z + 1)) ' Rotation angle in radians for X-axis
Y = -45 * pi / 180 ' Rotation angle in radians for Y-axis
' Delete previously saved ISO views to ensure clean state
Part.DeleteNamedView ("TRF-ISO")
Part.DeleteNamedView ("TRR-ISO")
Part.DeleteNamedView ("TLF-ISO")
Part.DeleteNamedView ("TLR-ISO")
Part.DeleteNamedView ("BRF-ISO")
Part.DeleteNamedView ("BRR-ISO")
Part.DeleteNamedView ("BLF-ISO")
Part.DeleteNamedView ("BLR-ISO")
' Create and save named views for different ISO perspectives
' Top Right Front ISO View
Part.ShowNamedView2 "*Front", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("TRF-ISO")
' Top Right Rear ISO View
Part.ShowNamedView2 "*Right", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("TRR-ISO")
' Top Left Rear ISO View
Part.ShowNamedView2 "*Back", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("TLR-ISO")
' Top Left Front ISO View
Part.ShowNamedView2 "*Left", -1
Part.ActiveView().RotateAboutCenter X, Y
Part.ViewZoomtofit
Part.NameView ("TLF-ISO")
' Bottom Right Front ISO View
Part.ShowNamedView2 "*Front", -1
Part.ActiveView().RotateAboutCenter -X, Y
Part.ViewZoomtofit
Part.NameView ("BRF-ISO")
' Bottom Right Rear ISO View
Part.ShowNamedView2 "*Right", -1
Part.ActiveView().RotateAboutCenter -X, Y
Part.ViewZoomtofit
Part.NameView ("BRR-ISO")
' Bottom Left Rear ISO View
Part.ShowNamedView2 "*Back", -1
Part.ActiveView().RotateAboutCenter -X, Y
Part.ViewZoomtofit
Part.NameView ("BLR-ISO")
' Bottom Left Front ISO View
Part.ShowNamedView2 "*Left", -1
Part.ActiveView().RotateAboutCenter -X, Y
Part.ViewZoomtofit
Part.NameView ("BLF-ISO")
' Clean up objects
Set Part = Nothing
Set swApp = Nothing
End Sub
Macro
You can download the macro from here
Need to modify the macro to meet specific requirements?
Contact us today to see how our experience can help provide you with a custom solution for maximizing your engineering efficiency.
