Skip to content

Commit

Permalink
added macro
Browse files Browse the repository at this point in the history
  • Loading branch information
AmenJlili committed Sep 17, 2024
1 parent 28a0ba6 commit 8fe156c
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 10 deletions.
5 changes: 5 additions & 0 deletions docs/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 15 additions & 9 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,61 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/README.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/index.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/Align_All_Dimensions_Automatically.html</loc>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/addmasscenter.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/assembly_export_dxf.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/create_boundingbox_feature_for_all_components.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/exportbomtoexcelwiththumbnails.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/introduction.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/traverse_assembly_component_tree_recursively_solidworks_vba_macro.html</loc>
<lastmod>2024-09-15T01:19:03-07:00</lastmod>
<lastmod>2024-09-16T09:52:12-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
Expand Down
182 changes: 182 additions & 0 deletions docs/src/Align_All_Dimensions_Automatically.html
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 | &#129513; SOLIDWORKS VBA Macros Library </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Align All Dimensions Automatically | &#129513; 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 &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<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="&#129513; SOLIDWORKS VBA Macros Library">
&#129513; 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 &lt;&gt; swDocDRAWING Then
MsgBox &quot;This macro only works on drawings!&quot;, vbCritical, &quot;Error&quot;
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 &gt; Macro &gt; 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>
3 changes: 3 additions & 0 deletions docs/src/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<li>
<a href="Rebuild_Save_All_Drawings_in_a_Directory_as_PDF.html" name="" title="Rebuild &amp; Save All Drawings in a Directory as PDF">Rebuild &amp; Save All Drawings in a Directory as PDF</a>
</li>
<li>
<a href="Align_All_Dimensions_Automatically.html" name="" title="Align All Dimensions Automatically">Align All Dimensions Automatically</a>
</li>
</ul>
</li>
<li>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/toc.json
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}
Loading

0 comments on commit 8fe156c

Please sign in to comment.