1 Reply Latest reply on Oct 17, 2014 2:10 AM by Andrea Orlando

    There is a method to make active a sub-assembly for making changes at inside components ?

    Andrea Orlando

      I want to write a Macro that make parts and sub-assemblies virtual. When the macro traverse the assembly tree, only the first level of assembly work fine; parts inside of sub-assembly cannot be changed because her assembly is not active. Any suggestion ?

        • Re: There is a method to make active a sub-assembly for making changes at inside components ?
          Andrea Orlando

          I was wrong to select the component; if I select correctly, the EditAssembly method works fine:

           

          Example:

          ' ******************************************************************************

          ' C:\Users\utstaff4\AppData\Local\Temp\swx428\Macro1.swb - macro recorded on 10/17/14 by utstaff4

          ' ******************************************************************************

          Dim swApp As Object

           

           

          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

          Dim myModelView As Object

          Set myModelView = Part.ActiveView

          myModelView.FrameState = swWindowState_e.swWindowMaximized

          boolstatus = Part.Extension.SelectByID2("CANCELLAMI_ASM_02-1@CANCELLAMI_ASM_01", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)

          Part.EditAssembly

          Part.ClearSelection2 True

          End Sub

           

          The trick is to use SelectByID2 or similar.