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.
- Top-front-right (TRF-ISO)
- Top-right-rear (TRR-ISO)
- Top-left-rear (TLR-ISO)
- Top-left-front (TLF-ISO)
- Bottom-right-front (BRF-ISO)
- Bottom-right-rear (BRR-ISO)
- Bottom-left-rear (BLR-ISO)
- Bottom-left-front (BLF-ISO)
- 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:
- Open the SOLIDWORKS VBA editor by pressing (Alt + F11).
- Insert a new Module and then paste the provided macro code from the SOLIDWORKS macro to create custom ISO views.
- You can run it immediately from the VBA editor, or from the main SOLIDWORKS software by navigating to Tools > Macro > Run and selecting the file. This depends on your particular work procedure.
- Using the Macro:
- The macro will run automatically: it will first delete any existing named views that take the same output name as the eight specified in order not to duplicate the views produced.
- Then it will create new ISO views based on the specifications and save the created views under those new names for easy selection and use.
VBA Macro Code
Visual Basic
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
' 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.
