ReplaceComponents Macro

Discussion in 'SolidWorks' started by Creighbm, Aug 11, 2003.

  1. Creighbm

    Creighbm Guest

    I am simply trying to replace components in an assembly using the
    following code:

    Dim swApp As Object
    Dim Part As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long
    Dim Annotation As Object
    Dim Gtol As Object
    Dim DatumTag As Object
    Dim FeatureData As Object
    Dim Feature As Object
    Dim Component As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.OpenDoc4("C:\Program
    Files\SolidWorks\data\Templates\DMAssembly.sldasm", 2, 0, "",
    longstatus)
    Set Part = swApp.ActivateDoc("DMAssembly")

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    boolstatus = Part.Extension.SelectByID("DM1-1@DMAssembly",
    "COMPONENT", 0, 0, 0, False, 0, Nothing)
    Part.ClearSelection
    Part.ClearSelection
    boolstatus = Part.Extension.SelectByID("DM1-1@DMAssembly",
    "COMPONENT", 0, 0, 0, False, 0, Nothing)
    Part.ClearSelection
    Part.ReplaceComponents "C:\Program
    Files\SolidWorks\data\Templates\DM4.sldprt", "", False, 0, True
    End Sub

    I got this by recording a macro and I am getting an error saying
    "Wrong number of arguments or invalid property assigment." I dont
    understand why I am getting this error since I recorded the macro from
    SolidWorks. Thanks in advance for any help.
     
    Creighbm, Aug 11, 2003
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.