diff --git a/docs/index.json b/docs/index.json index 35055b4..a4992b1 100644 --- a/docs/index.json +++ b/docs/index.json @@ -9,6 +9,11 @@ "title": "Blue Byte Systems Inc. SOLIDWORKS VBA Macro Library | 🧩 SOLIDWORKS VBA Macros Library", "keywords": "Blue Byte Systems Inc. SOLIDWORKS VBA Macro Library A macro is a small, self-contained program that automates repetitive tasks in SOLIDWORKS. Our VBA Macro Library is designed to streamline your workflow by providing a collection of pre-written macros that help automate common tasks in SOLIDWORKS such as part creation, assembly management, and sketching. Getting Started Explore the VBA Macro Library to find pre-built automation solutions for your SOLIDWORKS projects. Free and Organized by Category All of our VBA macros are free to use and are carefully organized into the following categories: Parts: Automate tasks related to part creation, modifications, and features. Assemblies: Manage assemblies, components, and mates efficiently. Sketching: Simplify sketch-related tasks, including constraints, dimensions, and geometry creation. Drawings: Generate or modify drawing views and annotations quickly. Bill Of Materials: Macros that manage Bill Of Materials. Each macro is designed to save you time and reduce repetitive tasks, helping you work more efficiently with SOLIDWORKS. Contact Us For more information or to contact us about our VBA Macro Library, please visit our Contact Us page." }, + "src/Align_All_Dimensions_Automatically.html": { + "href": "src/Align_All_Dimensions_Automatically.html", + "title": "Align All Dimensions Automatically | 🧩 SOLIDWORKS VBA Macros Library", + "keywords": "Align All Dimensions Automatically Description This VBA macro automates selecting and arranging dimensions in SOLIDWORKS drawings. It loops through views, selects display dimensions, and auto-arranges them. System Requirements SOLIDWORKS 2014 or newer Active drawing document open in SOLIDWORKS VBA Code: ' ******************************************************************** ' DISCLAIMER: ' This code is provided as-is with no warranty or liability by ' Blue Byte Systems Inc. The company assumes no responsibility for ' any issues arising from the use of this code in production. ' ******************************************************************** Option Explicit Public swApp As SldWorks.SldWorks Public swModel As SldWorks.ModelDoc2 Public swDraw As SldWorks.DrawingDoc Public swView As SldWorks.View Public swDispDim As SldWorks.DisplayDimension Public swAnn As SldWorks.Annotation Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc ' Ensure the active document is a drawing If swModel.GetType <> swDocDRAWING Then MsgBox \"This macro only works on drawings!\", vbCritical, \"Error\" Exit Sub End If Set swDraw = swModel Set swView = swDraw.GetFirstView swModel.ClearSelection2 True ' Loop through all views and select display dimensions Do While Not swView Is Nothing Set swDispDim = swView.GetFirstDisplayDimension5 Do While Not swDispDim Is Nothing Set swAnn = swDispDim.GetAnnotation swAnn.Select True Set swDispDim = swDispDim.GetNext5 Loop Set swView = swView.GetNextView Loop ' Auto-arrange dimensions swModel.Extension.AlignDimensions swAlignDimensionType_AutoArrange, 0.06 swModel.ClearSelection2 True End Sub System Requirements To run this VBA macro, ensure that your system meets the following requirements: SOLIDWORKS Version: SOLIDWORKS 2018 or later VBA Environment: Pre-installed with SOLIDWORKS (Access via Tools > Macro > New or Edit) Operating System: Windows 7, 8, 10, or later Customization Need to modify the macro to meet specific requirements or integrate it with other processes? We provide custom macro development tailored to your needs. Contact us." + }, "src/Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html": { "href": "src/Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html", "title": "Rebuild & Save All Drawings in a Directory as PDF | 🧩 SOLIDWORKS VBA Macros Library", diff --git a/docs/manifest.json b/docs/manifest.json index 8566394..1175dd8 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -65,6 +65,16 @@ }, "version": "" }, + { + "type": "Conceptual", + "source_relative_path": "src/Align_All_Dimensions_Automatically.md", + "output": { + ".html": { + "relative_path": "src/Align_All_Dimensions_Automatically.html" + } + }, + "version": "" + }, { "type": "Conceptual", "source_relative_path": "src/Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.md", diff --git a/docs/sitemap.xml b/docs/sitemap.xml index b3ee90e..f8d98ec 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -2,55 +2,61 @@ https://solidworksvbamacros.bluebyte.biz/README.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/index.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 + daily + 0.5 + + + https://solidworksvbamacros.bluebyte.biz/src/Align_All_Dimensions_Automatically.html + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/addmasscenter.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/assembly_export_dxf.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/create_boundingbox_feature_for_all_components.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/exportbomtoexcelwiththumbnails.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/introduction.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 https://solidworksvbamacros.bluebyte.biz/src/traverse_assembly_component_tree_recursively_solidworks_vba_macro.html - 2024-09-15T01:19:03-07:00 + 2024-09-16T09:52:12-07:00 daily 0.5 diff --git a/docs/src/Align_All_Dimensions_Automatically.html b/docs/src/Align_All_Dimensions_Automatically.html new file mode 100644 index 0000000..48a200c --- /dev/null +++ b/docs/src/Align_All_Dimensions_Automatically.html @@ -0,0 +1,182 @@ + + + + + Align All Dimensions Automatically | 🧩 SOLIDWORKS VBA Macros Library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+
Table of Contents
+ +
+
+ +
+
+
+ +
+
+ + + +
+ +
+

Align All Dimensions Automatically

+ +

Description

+

This VBA macro automates selecting and arranging dimensions in SOLIDWORKS drawings. It loops through views, selects display dimensions, and auto-arranges them.

+

System Requirements

+
    +
  • SOLIDWORKS 2014 or newer
  • +
  • Active drawing document open in SOLIDWORKS
  • +
+

VBA Code:

+

+' ********************************************************************
+' DISCLAIMER: 
+' This code is provided as-is with no warranty or liability by 
+' Blue Byte Systems Inc. The company assumes no responsibility for 
+' any issues arising from the use of this code in production.
+' ********************************************************************
+
+Option Explicit
+
+Public swApp As SldWorks.SldWorks
+Public swModel As SldWorks.ModelDoc2
+Public swDraw As SldWorks.DrawingDoc
+Public swView As SldWorks.View
+Public swDispDim As SldWorks.DisplayDimension
+Public swAnn As SldWorks.Annotation
+
+Sub main()
+
+    Set swApp = Application.SldWorks
+    Set swModel = swApp.ActiveDoc
+    
+    ' Ensure the active document is a drawing
+    If swModel.GetType <> swDocDRAWING Then
+        MsgBox "This macro only works on drawings!", vbCritical, "Error"
+        Exit Sub
+    End If
+    
+    Set swDraw = swModel
+    Set swView = swDraw.GetFirstView
+    swModel.ClearSelection2 True
+    
+    ' Loop through all views and select display dimensions
+    Do While Not swView Is Nothing
+        Set swDispDim = swView.GetFirstDisplayDimension5
+        Do While Not swDispDim Is Nothing
+            Set swAnn = swDispDim.GetAnnotation
+            swAnn.Select True
+            Set swDispDim = swDispDim.GetNext5
+        Loop
+        Set swView = swView.GetNextView
+    Loop
+    
+    ' Auto-arrange dimensions
+    swModel.Extension.AlignDimensions swAlignDimensionType_AutoArrange, 0.06
+    swModel.ClearSelection2 True
+    
+End Sub
+
+

System Requirements

+

To run this VBA macro, ensure that your system meets the following requirements:

+
    +
  • SOLIDWORKS Version: SOLIDWORKS 2018 or later
  • +
  • VBA Environment: Pre-installed with SOLIDWORKS (Access via Tools > Macro > New or Edit)
  • +
  • Operating System: Windows 7, 8, 10, or later
  • +
+

Customization

+

Need to modify the macro to meet specific requirements or integrate it with other processes? We provide custom macro development tailored to your needs. Contact us.

+ +
+ + + + + +
+ +
+ +
+
+ +
+ + + + diff --git a/docs/src/toc.html b/docs/src/toc.html index 5d0d944..8661bf4 100644 --- a/docs/src/toc.html +++ b/docs/src/toc.html @@ -61,6 +61,9 @@
  • Rebuild & Save All Drawings in a Directory as PDF
  • +
  • + Align All Dimensions Automatically +
  • diff --git a/docs/src/toc.json b/docs/src/toc.json index 28573f6..c7e8af6 100644 --- a/docs/src/toc.json +++ b/docs/src/toc.json @@ -1,2 +1,2 @@ -{"items":[{"name":"🧩 SOLIDWORKS VBA Macros"},{"name":"Introduction","href":"introduction.html","topicHref":"introduction.html"},{"name":"Part Documents"},{"name":"Part Documents","items":[{"name":"Add Mass Center","href":"addmasscenter.html","topicHref":"addmasscenter.html"}],"expanded":true},{"name":"Assembly Documents"},{"name":"Assembly Documents","items":[{"name":"Export All SheetMetal Components to DXF","href":"assembly_export_dxf.html","topicHref":"assembly_export_dxf.html"},{"name":"Traverse Assembly Component Tree Recursively","href":"traverse_assembly_component_tree_recursively_solidworks_vba_macro.html","topicHref":"traverse_assembly_component_tree_recursively_solidworks_vba_macro.html"},{"name":"Create Bounding Box for Assembly and Components","href":"create_boundingbox_feature_for_all_components.html","topicHref":"create_boundingbox_feature_for_all_components.html"}],"expanded":true},{"name":"Drawing Documents"},{"name":"Drawing Documents","items":[{"name":"Rebuild & Save All Drawings in a Directory as PDF","href":"Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html","topicHref":"Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html"}],"expanded":true},{"name":"Bill Of Materials"},{"name":"Bill Of Materials","items":[{"name":"Export BOM To Excel with Thumbnails","href":"exportbomtoexcelwiththumbnails.html","topicHref":"exportbomtoexcelwiththumbnails.html"}],"expanded":true}],"pdf":false} +{"items":[{"name":"🧩 SOLIDWORKS VBA Macros"},{"name":"Introduction","href":"introduction.html","topicHref":"introduction.html"},{"name":"Part Documents"},{"name":"Part Documents","items":[{"name":"Add Mass Center","href":"addmasscenter.html","topicHref":"addmasscenter.html"}],"expanded":true},{"name":"Assembly Documents"},{"name":"Assembly Documents","items":[{"name":"Export All SheetMetal Components to DXF","href":"assembly_export_dxf.html","topicHref":"assembly_export_dxf.html"},{"name":"Traverse Assembly Component Tree Recursively","href":"traverse_assembly_component_tree_recursively_solidworks_vba_macro.html","topicHref":"traverse_assembly_component_tree_recursively_solidworks_vba_macro.html"},{"name":"Create Bounding Box for Assembly and Components","href":"create_boundingbox_feature_for_all_components.html","topicHref":"create_boundingbox_feature_for_all_components.html"}],"expanded":true},{"name":"Drawing Documents"},{"name":"Drawing Documents","items":[{"name":"Rebuild & Save All Drawings in a Directory as PDF","href":"Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html","topicHref":"Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html"},{"name":"Align All Dimensions Automatically","href":"Align_All_Dimensions_Automatically.html","topicHref":"Align_All_Dimensions_Automatically.html"}],"expanded":true},{"name":"Bill Of Materials"},{"name":"Bill Of Materials","items":[{"name":"Export BOM To Excel with Thumbnails","href":"exportbomtoexcelwiththumbnails.html","topicHref":"exportbomtoexcelwiththumbnails.html"}],"expanded":true}],"pdf":false} diff --git a/src/Align_All_Dimensions_Automatically.md b/src/Align_All_Dimensions_Automatically.md new file mode 100644 index 0000000..bceef86 --- /dev/null +++ b/src/Align_All_Dimensions_Automatically.md @@ -0,0 +1,70 @@ +# Align All Dimensions Automatically +## Description +This VBA macro automates selecting and arranging dimensions in SOLIDWORKS drawings. It loops through views, selects display dimensions, and auto-arranges them. + +## System Requirements +- SOLIDWORKS 2014 or newer +- Active drawing document open in SOLIDWORKS + +## VBA Code: +```vbnet + +' ******************************************************************** +' DISCLAIMER: +' This code is provided as-is with no warranty or liability by +' Blue Byte Systems Inc. The company assumes no responsibility for +' any issues arising from the use of this code in production. +' ******************************************************************** + +Option Explicit + +Public swApp As SldWorks.SldWorks +Public swModel As SldWorks.ModelDoc2 +Public swDraw As SldWorks.DrawingDoc +Public swView As SldWorks.View +Public swDispDim As SldWorks.DisplayDimension +Public swAnn As SldWorks.Annotation + +Sub main() + + Set swApp = Application.SldWorks + Set swModel = swApp.ActiveDoc + + ' Ensure the active document is a drawing + If swModel.GetType <> swDocDRAWING Then + MsgBox "This macro only works on drawings!", vbCritical, "Error" + Exit Sub + End If + + Set swDraw = swModel + Set swView = swDraw.GetFirstView + swModel.ClearSelection2 True + + ' Loop through all views and select display dimensions + Do While Not swView Is Nothing + Set swDispDim = swView.GetFirstDisplayDimension5 + Do While Not swDispDim Is Nothing + Set swAnn = swDispDim.GetAnnotation + swAnn.Select True + Set swDispDim = swDispDim.GetNext5 + Loop + Set swView = swView.GetNextView + Loop + + ' Auto-arrange dimensions + swModel.Extension.AlignDimensions swAlignDimensionType_AutoArrange, 0.06 + swModel.ClearSelection2 True + +End Sub +``` + + +## System Requirements +To run this VBA macro, ensure that your system meets the following requirements: + +- SOLIDWORKS Version: SOLIDWORKS 2018 or later +- VBA Environment: Pre-installed with SOLIDWORKS (Access via Tools > Macro > New or Edit) +- Operating System: Windows 7, 8, 10, or later + +## Customization +Need to modify the macro to meet specific requirements or integrate it with other processes? We provide custom macro development tailored to your needs. [Contact us](https://bluebyte.biz/contact). \ No newline at end of file diff --git a/src/toc.yml b/src/toc.yml index fbab084..18ad822 100644 --- a/src/toc.yml +++ b/src/toc.yml @@ -27,6 +27,8 @@ items: - name: Rebuild & Save All Drawings in a Directory as PDF href: Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.md + - name: Align All Dimensions Automatically + href: Align_All_Dimensions_Automatically.md - name: Bill Of Materials - name: Bill Of Materials expanded: true