Hi All,
We have can thousands of configurations within part and assembly and I am trying to automate the tedium of uploading each one to our our ERP software. We have been provided an addin which provides an upload button for the currently active configuration. My thought was to use Microsoft Power Automate which can record and playback keystrokes and mouse movements to load a configuration and press the upload button.
From what I can tell there is no keyboard button which can select and activate the next configuration. Recording a mouse action is not practical since the next configuration is always in a different position.
I have zero experience writing code, but would be very grateful for anyone to point me to an example I could use as a starting point to create a "load next configuration" macro which I can then customize into a button on the interface. Bonus if I could figure out how to put up an error message if the macro is run at the last configuration.
Load Next Configuration Macro
-
- Posts: 3
- Joined: Wed Oct 06, 2021 12:33 pm
- AlexLachance
- Posts: 2203
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2391
- x 2032
Re: Load Next Configuration Macro
Jonas,Jonas Concepcion wrote: ↑Wed Oct 06, 2021 12:35 pm Hi All,
We have can thousands of configurations within part and assembly and I am trying to automate the tedium of uploading each one to our our ERP software. We have been provided an addin which provides an upload button for the currently active configuration. My thought was to use Microsoft Power Automate which can record and playback keystrokes and mouse movements to load a configuration and press the upload button.
From what I can tell there is no keyboard button which can select and activate the next configuration. Recording a mouse action is not practical since the next configuration is always in a different position.
I have zero experience writing code, but would be very grateful for anyone to point me to an example I could use as a starting point to create a "load next configuration" macro which I can then customize into a button on the interface. Bonus if I could figure out how to put up an error message if the macro is run at the last configuration.
The 'next' configuration here, is very subjective. Could you dwelve a bit more into detail? What represents the 'next' configuration? Are you speaking of the next configuration in an alphabetical order, or a next configuration in a creation order, or something else?
To execute what you speak of, I create a temporary assembly where I can have a pattern that represents the number of occurances and then "configure" the configurable component.
Then I send the info to our ERP using our macro that creates a BOM to copy and paste it to our ERP.
-
- Posts: 3
- Joined: Wed Oct 06, 2021 12:33 pm
Re: Load Next Configuration Macro
Our parts and assemblies configurations are created with design tables. In the configuration tree these can be shown in the order created, alphabetical, or by the order they are listed in the design table. For my use it does not matter they way they are organized or even if it is the "next" one down the line so long as the macro cycles through all of them once.AlexLachance wrote: ↑Wed Oct 06, 2021 4:10 pm Jonas,
The 'next' configuration here, is very subjective. Could you dwelve a bit more into detail? What represents the 'next' configuration? Are you speaking of the next configuration in an alphabetical order, or a next configuration in a creation order, or something else?
To execute what you speak of, I create a temporary assembly where I can have a pattern that represents the number of occurances and then "configure" the configurable component.
Then I send the info to our ERP using our macro that creates a BOM to copy and paste it to our ERP.
We have the piece that extracts the BOM to our ERP already. But it only does it for the active configuration. I just need a button to load the "next" configuration.
-
- Posts: 4
- Joined: Thu Mar 25, 2021 8:20 am
- Location: Germany
- x 3
- Contact:
Re: Load Next Configuration Macro
Hi Jonas
I have no idea what Microsoft Power Automate can do exactly, but I assume that it can wait for windows and press buttons inside them. After starting the SW macro, the configurations are read from the model, and each click on yes loads the next one. While the window is open on top, actions can be done in the CAD.
BiI ERP-PDM
I have no idea what Microsoft Power Automate can do exactly, but I assume that it can wait for windows and press buttons inside them. After starting the SW macro, the configurations are read from the model, and each click on yes loads the next one. While the window is open on top, actions can be done in the CAD.
Code: Select all
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Sub main()
Dim swConfigs As Variant
Dim i As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swConfigs = swModel.GetConfigurationNames
For i = 0 To UBound(swConfigs)
If Not NextConfig Then Exit Sub
swModel.ShowConfiguration2 swConfigs(i)
Next i
Set swModel = Nothing
Set swApp = Nothing
End Sub
Function NextConfig() As Boolean
Dim wShell As Object
Set wShell = CreateObject("WScript.Shell")
' https://docs.microsoft.com/en-us/previous-versions//x83z1d9f(v=vs.85)?redirectedfrom=MSDN
If wShell.Popup("Next config?", 60, "Switch configs", 4 + 32 + 4096) = 6 Then NextConfig = True
Set wShell = Nothing
End Function
BiI ERP-PDM