api question

Discussion in 'SolidWorks' started by Ben, Aug 19, 2003.

  1. Ben

    Ben Guest

    I hae the following code for a macro

    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    boolstatus = Part.Extension.SelectByID("", "FACE", -22.25058668939,
    5.223159153259, 2.532190636408, False, 0, Nothing)
    Part.ShowNamedView2 "*Normal To", 0
    Part.NameView "X", -1
    boolstatus = Part.Extension.SelectByID("Default@PANEL 5.SLDPRT",
    "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing)
    Part.ClearSelection
    Part.ShowConfiguration "Default"
    Part.ShowNamedView2 "*Dimetric", 9
    End Sub

    But I get an error for this line "Part.NameView "X", -1"
    the error is runtime error450 wrong number of arguments or invalid
    assignment.

    HELP???????

    While I am at it, how do I get a macro to pause and ask me to choose a face
    and then continue on? you can see this macro starts with a face selcected,
    I have another macro to run before it and would like the two macros to be
    joined but what is stopping me is the selection of the face in the middle of
    the potentially combined macro.


    TIA
    Ben
     
    Ben, Aug 19, 2003
    #1
  2. Ben

    Heikki Leivo Guest

    But I get an error for this line "Part.NameView "X", -1"
    Refer to API help, look for NameView function:
    ---8<---
    Syntax (OLE Automation)
    void ModelDoc2.NameView ( vName)
    Input:(BSTR) vNameName for the new view
    ---8<---

    As the error description tells and API help verifies, you are trying to
    enter too many arguments to NameView function. What are you trying to do
    with that -1?

    -h-
     
    Heikki Leivo, Aug 20, 2003
    #2
  3. While I am at it, how do I get a macro to pause and ask me to choose a
    face
    Sub main ()
    Load UserForm
    UserForm.Show False
    End Sub

    Now if you want notification so that you can do something after a selection
    without another click. then declare your part like this.

    Public WithEvents Part As SldWorks.AssemblyDoc

    Private Function Part_NewSelectionNotify() As Long
    'put everything you want to happen after a selection here
    'check that the selection is a usable surface
    'if so continue the next part of your macro
    End Sub

    Corey Scheich
     
    Corey Scheich, Aug 20, 2003
    #3
  4. Ben

    Ben Guest

    -h-

    I never put the -1 in the macro, it was there after I recorded it. None the
    less when I try and get rid of it I get a compile error: expected
    expression. Thank you for your help, maybe I can make some sense of this now
    that I have had a few beers and a good sleep.

    AHHHHH HA! being the details oriented guy I am I removed the -1 and.... get
    this... the comma before the -1 and all is good...lol sometimes I hate it
    when you mistake a comma or decimal for a spec of garbage on your screen..
    that's my excuse and I am sticking to it.

    On a serious note I am not sure why the recording put that -1 there.... any
    ideas?

    By the way what is the VBA book to read and learn from for SW?

    Ben
     
    Ben, Aug 20, 2003
    #4
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.