ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
DBDariush Bastani17/06/2011

Hello everyone,

  I am going through API Help and find an example for above action, also I am bring it here:

Change Referenced Configuration Example (VBA)

This example shows how to change the configuration of a component in an assembly without opening the part.

Option Explicit

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swAssy                  As SldWorks.AssemblyDoc

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swModel                 As SldWorks.ModelDoc

    Dim swComp                  As SldWorks.Component

    Dim RefCfg                  As String

   

    Set swApp = CreateObject("SldWorks.Application")

    Set swModel = swApp.ActiveDoc

    Set swAssy = swModel

    Set swSelMgr = swModel.SelectionManager

    Set swComp = swSelMgr.GetSelectedObject5(1)

   

    ' Debugging only

    RefCfg = swComp.ReferencedConfiguration

        ' Change component config to "in-use"

    swComp.ReferencedConfiguration = ""

        ' For changes to take effect

    swAssy.EditRebuild

End Sub

Now in my assembly I want to without opening a part , change the configuration to a specific configuration and it apply to current assembly. How can I do that or what should I put on Bolt expression on above Macro?

Thanks