I am writing a macro that creates a new configuration in an assembly and automatically unchecks 'Suppress New Features and Mates'. However, the macro only works with a preselected configuration name. Currently, my macro creates a new configuration called 'default3' but I would like a userform to pop up and prompt the user to enter a configuration name. Here is my code so far:
Dim swApp As SldWorks.SldWorks
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Default", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.EditConfiguration3("Default", "Default", "", "", 32)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.AddConfiguration2("default3", "", "", False, False, False, True, 256)
End Sub
Anyone have any recommendations? Thanks,
SolidworksApi/macros
Check out InputBox
Hiee Stephen Bond,
If you want to display more attractive userform then you have to insert the userform in Solidwork VBA add labels, textboxes as per your requirement then code to display and take the input for configuration name in a variable then pass it to AddConfiguration2 line in your code.
Another very simple way is to as per Josh Brady reply you can add the input box.
Please refer following code i have added some line your code for input box its work for me.
Dim swApp As SldWorks.SldWorks
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Config_Name As Variant
Sub main()
Config_Name = InputBox("Give Configuration Name")
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Default", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
'boolstatus = Part.EditConfiguration3("Default", "Default", "", "", 32)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.AddConfiguration2(Config_Name , "", "", False, False, False, True, 256)
End Sub
Thank You...
You beat me to the answer Josh!