My current code is attached. I want to set an if statement, when the InStr function finds a specific line in the string swComp.Name2, set that parts configuration to, whichever one I want to. How would I do that?
you would need to use retVal=swModel.ShowConfiguration2("Name of Config").
how can I do that though when I need to read the value of swComp.Name2 in the TraverseComponent Sub, but the swModel Object is defined in the Main sub? I should have mentioned I'm fairly new to visual basic so Go easy HA!
Too lazy to look at your code...
Your code is traversing an assembly model, and you need to change the configuration of one component of the assembly based on its name, right? That's
2017 SOLIDWORKS API Help - ReferencedConfiguration Property (IComponent2)
ShowConfiguration2 is when you have a document open in its own window and you want to show a different config of that document.
You should be able to easily bring that over.
You need to add swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2 to your TraverseComponet Sub Declarations.
So it will look like this
Sub TraverseComponent(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swComp As SldWorks.Component2, nLevel As Long)
Then you will call the sub like this TraverseComponent swApp, swModel, swRootComp, 1.
I am not avaible for open your macro. You can use this code. Check "ShowConfiguration2 ".
Dim swModel as Sldworks.Modeldoc2
Dim ConfigurationName as string
Retrieving data ...