Skip to content

Commit

Permalink
added files
Browse files Browse the repository at this point in the history
  • Loading branch information
AmenJlili committed Sep 13, 2024
1 parent 9157e7e commit ba271df
Show file tree
Hide file tree
Showing 8 changed files with 376 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 @@ -28,5 +28,10 @@
"href": "src/introduction.html",
"title": "| 🧩 SOLIDWORKS VBA Macros Library",
"keywords": "Introduction to VBA Macros in SOLIDWORKS What is a VBA Macro? A VBA (Visual Basic for Applications) macro is a small program written using the VBA programming language, designed to automate repetitive tasks within software applications. In the context of SOLIDWORKS, VBA macros allow users to streamline their workflows by automating design tasks, reducing manual input, and increasing overall productivity. Instead of performing the same actions manually, a macro can execute them in seconds, saving time and minimizing human error. Why Use VBA Macros in SOLIDWORKS? SOLIDWORKS is a powerful CAD software used by engineers and designers to create complex 3D models and assemblies. However, as with any software, there are tasks that are repetitive or prone to error when performed manually. This is where VBA macros come in handy—they enable users to automate tasks such as: Modifying properties or configurations across multiple files Generating drawings or BOMs (Bill of Materials) Editing or creating features in parts and assemblies Exporting data to various formats such as DXF, PDF, or Excel Using VBA macros can significantly improve your efficiency, especially when dealing with large assemblies, multi-part projects, or standardized workflows. Instead of spending time on repetitive actions, users can focus on innovation and improving their designs. Getting Started with SOLIDWORKS VBA Macros To use VBA macros in SOLIDWORKS, you can either write your own macros or use existing ones provided by various sources, such as Blue Byte Systems’ SOLIDWORKS VBA Macro Library. The library offers a collection of macros that automate common tasks, each categorized for easy access based on functionality (e.g., part creation, assembly management, drawing automation). How to Create or Run a VBA Macro in SOLIDWORKS Open the VBA Editor: Go to the Tools menu in SOLIDWORKS, then navigate to Macro and select New to create a new macro, or Run to execute an existing one. Write or Edit the Macro: If you’re creating a new macro, the VBA editor will open, allowing you to write your code. Macros consist of VBA code that interfaces with SOLIDWORKS' API (Application Programming Interface) to control different aspects of the application. Execute the Macro: Once the macro is written or selected, you can run it directly within SOLIDWORKS. The macro will perform the tasks it's programmed for, interacting with the current part, assembly, or drawing. Test and Debug: Always test macros on sample files to ensure they work as expected, and make necessary adjustments to the code if any issues arise. Free VBA Macro Library by Blue Byte Systems Blue Byte Systems provides a comprehensive VBA macro library tailored for SOLIDWORKS users. These macros are designed to help users automate tasks in various areas, including part modeling, assembly management, and sketching. The library is completely free, making it accessible to all SOLIDWORKS users, from beginners to advanced engineers. The macros are organized into categories for easy navigation: Part Automation: Macros related to modifying or creating parts. Assembly Automation: Macros to streamline assembly management. Drawing Automation: Macros focused on automating drawing creation and export. Sketch Automation: Macros for working with sketches more efficiently. Whether you're looking to automate repetitive tasks, modify part properties, or generate drawings quickly, the library offers solutions that save you time and enhance your productivity."
},
"src/traverse_assembly_component_tree_recursively_solidworks_vba_macro.html": {
"href": "src/traverse_assembly_component_tree_recursively_solidworks_vba_macro.html",
"title": "Traverse Assembly Components in SOLIDWORKS Using VBA | 🧩 SOLIDWORKS VBA Macros Library",
"keywords": "Traverse Assembly Components in SOLIDWORKS Using VBA Macro Description This article explains how to write a VBA macro in SOLIDWORKS to traverse through an assembly's components and list their hierarchy. The macro explores the assembly structure, identifies components, and logs their names with proper indentation to reflect their parent-child relationship within the assembly. VBA Macro 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. ' ******************************************************************** Dim swApp As SldWorks.SldWorks Dim swRootAssemblyModelDoc As ModelDoc2 Sub main() Set swApp = Application.SldWorks swApp.CommandInProgress = True Set swRootAssemblyModelDoc = swApp.ActiveDoc Dim swFeature As Feature Set swFeature = swRootAssemblyModelDoc.FirstFeature While Not swFeature Is Nothing TraverseFeatureForComponents swFeature Set swFeature = swFeature.GetNextFeature Wend swApp.CommandInProgress = False End Sub Private Sub TraverseFeatureForComponents(ByVal swFeature As Feature) Dim swSubFeature As Feature Dim swComponent As Component2 Dim typeName As String typeName = swFeature.GetTypeName2 If typeName = \"Reference\" Then Set swComponent = swFeature.GetSpecificFeature2 If Not swComponent Is Nothing Then LogComponentName swComponent Set swSubFeature = swComponent.FirstFeature() While Not swSubFeature Is Nothing TraverseFeatureForComponents swSubFeature Set swSubFeature = swSubFeature.GetNextFeature() Wend End If End If End Sub Private Sub LogComponentName(ByVal swComponent As Component2) Dim parentCount As Long Dim swParentComponent As Component2 Set swParentComponent = swComponent.GetParent() While Not swParentComponent Is Nothing parentCount = parentCount + 1 Set swParentComponent = swParentComponent.GetParent() Wend Dim indentation As String indentation = Replicate(\" \", parentCount) Debug.Print indentation & Split(swComponent.GetPathName(), \"\\\")(UBound(Split(swComponent.GetPathName(), \"\\\"))) End Sub Public Function Replicate(RepeatString As String, ByVal NumOfTimes As Long) If NumOfTimes = 0 Then Replicate = \"\" Exit Function End If Dim s As String Dim c As Long Dim l As Long Dim i As Long l = Len(RepeatString) c = l * NumOfTimes s = Space$(c) For i = 1 To c Step l Mid(s, i, l) = RepeatString Next Replicate = s End Function System Requirements To run this VBA macro, ensure that your system meets the following requirements: SOLIDWORKS Version: SOLIDWORKS 2017 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."
}
}
10 changes: 10 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@
},
"version": ""
},
{
"type": "Conceptual",
"source_relative_path": "src/traverse_assembly_component_tree_recursively_solidworks_vba_macro.md",
"output": {
".html": {
"relative_path": "src/traverse_assembly_component_tree_recursively_solidworks_vba_macro.html"
}
},
"version": ""
},
{
"type": "Toc",
"source_relative_path": "toc.yml",
Expand Down
18 changes: 12 additions & 6 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,43 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/README.html</loc>
<lastmod>2024-09-12T01:11:03-07:00</lastmod>
<lastmod>2024-09-12T05:06:53-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/index.html</loc>
<lastmod>2024-09-12T01:11:03-07:00</lastmod>
<lastmod>2024-09-12T05:06:53-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/addmasscenter.html</loc>
<lastmod>2024-09-12T01:11:03-07:00</lastmod>
<lastmod>2024-09-12T05:06:53-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-12T01:11:03-07:00</lastmod>
<lastmod>2024-09-12T05:06:53-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/exportbomtoexcelwiththumbnails.html</loc>
<lastmod>2024-09-12T01:11:03-07:00</lastmod>
<lastmod>2024-09-12T05:06:53-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://solidworksvbamacros.bluebyte.biz/src/introduction.html</loc>
<lastmod>2024-09-12T01:11:03-07:00</lastmod>
<lastmod>2024-09-12T05:06:53-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-12T05:06:53-07:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
Expand Down
3 changes: 3 additions & 0 deletions docs/src/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<li>
<a href="assembly_export_dxf.html" name="" title="Export All SheetMetal Components to DXF">Export All SheetMetal Components to DXF</a>
</li>
<li>
<a href="traverse_assembly_component_tree_recursively_solidworks_vba_macro.html" name="" title="Traverse Assembly Component Tree Recursively">Traverse Assembly Component Tree Recursively</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"}],"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"}],"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 ba271df

Please sign in to comment.