-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
288 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Align All Dimensions Automatically | 🧩 SOLIDWORKS VBA Macros Library </title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="title" content="Align All Dimensions Automatically | 🧩 SOLIDWORKS VBA Macros Library "> | ||
|
||
|
||
<link rel="icon" href="../favicon.ico"> | ||
<link rel="stylesheet" href="../public/docfx.min.css"> | ||
<link rel="stylesheet" href="../public/main.css"> | ||
<meta name="docfx:navrel" content="../toc.html"> | ||
<meta name="docfx:tocrel" content="toc.html"> | ||
|
||
<meta name="docfx:rel" content="../"> | ||
|
||
|
||
<meta name="docfx:docurl" content="https://github.com/BlueByteSystemsInc/SOLIDWORKSVBAMacros/blob/main/src/Align_All_Dimensions_Automatically.md/#L1"> | ||
<meta name="loc:inThisArticle" content="In this article"> | ||
<meta name="loc:searchResultsCount" content="{count} results for "{query}""> | ||
<meta name="loc:searchNoResults" content="No results for "{query}""> | ||
<meta name="loc:tocFilter" content="Filter by title"> | ||
<meta name="loc:nextArticle" content="Next"> | ||
<meta name="loc:prevArticle" content="Previous"> | ||
<meta name="loc:themeLight" content="Light"> | ||
<meta name="loc:themeDark" content="Dark"> | ||
<meta name="loc:themeAuto" content="Auto"> | ||
<meta name="loc:changeTheme" content="Change theme"> | ||
<meta name="loc:copy" content="Copy"> | ||
<meta name="loc:downloadPdf" content="Download PDF"> | ||
|
||
<script type="module" src="./../public/docfx.min.js"></script> | ||
|
||
<script> | ||
const theme = localStorage.getItem('theme') || 'auto' | ||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme) | ||
</script> | ||
|
||
</head> | ||
|
||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime=""> | ||
<header class="bg-body border-bottom"> | ||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation"> | ||
<div class="container-xxl flex-nowrap"> | ||
<a class="navbar-brand" href="../index.html"> | ||
<img id="logo" class="svg" src="../images/fav.png" alt="🧩 SOLIDWORKS VBA Macros Library"> | ||
🧩 SOLIDWORKS VBA Macros Library | ||
</a> | ||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation"> | ||
<i class="bi bi-three-dots"></i> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navpanel"> | ||
<div id="navbar"> | ||
<form class="search" role="search" id="search"> | ||
<i class="bi bi-search"></i> | ||
<input class="form-control" id="search-query" type="search" disabled="" placeholder="Search" autocomplete="off" aria-label="Search"> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
|
||
<main class="container-xxl"> | ||
<div class="toc-offcanvas"> | ||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel"> | ||
<div class="offcanvas-header"> | ||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button> | ||
</div> | ||
<div class="offcanvas-body"> | ||
<nav class="toc" id="toc"></nav> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="content"> | ||
<div class="actionbar"> | ||
<button class="btn btn-lg border-0 d-md-none" style="margin-top: -.65em; margin-left: -.8em" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents"> | ||
<i class="bi bi-list"></i> | ||
</button> | ||
|
||
<nav id="breadcrumb"></nav> | ||
</div> | ||
|
||
<article data-uid=""> | ||
<h1 id="align-all-dimensions-automatically">Align All Dimensions Automatically</h1> | ||
|
||
<h2 id="description">Description</h2> | ||
<p>This VBA macro automates selecting and arranging dimensions in SOLIDWORKS drawings. It loops through views, selects display dimensions, and auto-arranges them.</p> | ||
<h2 id="system-requirements">System Requirements</h2> | ||
<ul> | ||
<li>SOLIDWORKS 2014 or newer</li> | ||
<li>Active drawing document open in SOLIDWORKS</li> | ||
</ul> | ||
<h2 id="vba-code">VBA Code:</h2> | ||
<pre><code class="lang-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 | ||
</code></pre> | ||
<h2 id="system-requirements-1">System Requirements</h2> | ||
<p>To run this VBA macro, ensure that your system meets the following requirements:</p> | ||
<ul> | ||
<li>SOLIDWORKS Version: SOLIDWORKS 2018 or later</li> | ||
<li>VBA Environment: Pre-installed with SOLIDWORKS (Access via Tools > Macro > New or Edit)</li> | ||
<li>Operating System: Windows 7, 8, 10, or later</li> | ||
</ul> | ||
<h2 id="customization">Customization</h2> | ||
<p>Need to modify the macro to meet specific requirements or integrate it with other processes? We provide custom macro development tailored to your needs. <a href="https://bluebyte.biz/contact">Contact us</a>.</p> | ||
|
||
</article> | ||
|
||
<div class="contribution d-print-none"> | ||
<a href="https://github.com/BlueByteSystemsInc/SOLIDWORKSVBAMacros/blob/main/src/Align_All_Dimensions_Automatically.md/#L1" class="edit-link">Edit this page</a> | ||
</div> | ||
|
||
<div class="next-article d-print-none border-top" id="nextArticle"></div> | ||
|
||
</div> | ||
|
||
<div class="affix"> | ||
<nav id="affix"></nav> | ||
</div> | ||
</main> | ||
|
||
<div class="container-xxl search-results" id="search-results"></div> | ||
|
||
<footer class="border-top text-secondary"> | ||
<div class="container-xxl"> | ||
<div class="flex-fill"> | ||
<span>Hosted and provided by <a href='https://bluebyte.biz'>Blue Byte Systems Inc</a>. Made with Maple syrup 🍁 and Couscous 🍲.</span> | ||
</div> | ||
</div> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
Oops, something went wrong.