Out of SolidWorks:
Artem Taturevych, Application Engineer at Intercad (Australia)
translationXpert – add-in to translate SolidWorks models
Thank you Artem.
I'm trying to use GetConfigurationNames but I have not figured out how to test it against the user input. I have been searching for a way to test if a array contains a string but every thing I have seen to try does not work or ,more likely, I don't understand how to git it to work. Below is what I have. The "If ConfigList contains PartNoInput.Text Then" line is just a place holder for ware I think the test would go. How should that be tested?
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim ConfigList As Variant
Private Sub AddPartButton_Click()
'connect to SolidWorks and the active document
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Get list of configurations
ConfigList = swModel.GetConfigurationNames
'Test if configList contains user input.
If ConfigList contains PartNoInput.Text Then
MsgBox "That Part number already exists."
swModel.AddConfiguration3 PartNoInput.Text, Empty, Empty, 0
I'm new to programming/VBA so I really appreciate any help.
Dim i as Integer
Dim myConfigToTest as String
Dim doesItExist as Boolean
doesItExists = False
myConfigToTest = PartNoInput.Text
For i = 0 to Ubound(ConfigList)
If ConfigList(i) = myConfigToTest Then doesItExist = True 'to avoid case sensitive issues, Option Compare Text at the top
if doesItExist then Msgbox "Already Exists!"
Thanks Simon! That worked.