ActiveDocChangeNotify

Discussion in 'SolidWorks' started by Wayne Tiffany, Jul 14, 2004.

  1. I found this event and figured it would work regardless of the type of file
    activity the user performed, such as changing config, changing files, etc.
    However, I can't figure out how to "attach" to it. I can't just throw it
    out there.....

    If I do this:
    Public WithEvents Part As SldWorks.PartDoc

    then I can watch for this, and it works:
    Private Function Part_ActiveConfigChangePostNotify() As Long
    Apply_Button.Enabled = True
    End Function

    However, my opening Dim statement is:
    Dim Part As Object
    because the file could be either a part or assy file.

    So, I thought I could use the ActiveDocChangeNotify to watch for every
    change. Do I need to do a "Public WithEvents..." statement to handle this?
    If so, how do I handle both part & assy files?

    Thanks once again for the help. (Humbly)

    WT
     
    Wayne Tiffany, Jul 14, 2004
    #1
  2. That is an event called by the SolidWorks application object not the part or
    assembly
    In the picture I sent you yesterday you can see how I had it set up. You
    have to call

    Public WithEvents swApp As SldWorks.SldWorks

    and attach it to SW by

    Set swApp = Application.SolidWorks

    just like you normaly do it

    Corey
     
    Corey Scheich, Jul 14, 2004
    #2
  3. Thanks - I knew it had to be something like that, but my search for an
    example came up empty. Oh, I keep meaning to tell you that the image you
    refer to didn't come through - only <<...OLE_Obj...>>.

    Now, I thought this watch would take care of it all, but it appears that it
    doesn't catch a change of config in the same document.

    So, back to work on that one.

    WT
     
    Wayne Tiffany, Jul 14, 2004
    #3
  4. Nope you will have to use both
    Assy_ConfigChangePostNotify
    and
    Part_ConfigChangePostNotify
    and also
    swApp_ActiveDocChangeNotify 'to ensure you are always watching the active
    document.

    here is a really simple example that will show you how it works.

    You will have to change documents after you play it or set the current
    document in other code before it will start working.

    snip...

    Public WithEvents swApp As SldWorks.SldWorks
    Public WithEvents swPart As SldWorks.PartDoc
    Public WithEvents swAssy As SldWorks.AssemblyDoc
    Public WithEvents swDrw As SldWorks.DrawingDoc
    Public ActvDoc As SldWorks.ModelDoc2

    Private Function swApp_ActiveModelDocChangeNotify() As Long
    Dim DocType As String
    Set ActvDoc = swApp.ActiveDoc
    Select Case ActvDoc.GetType
    Case 1
    Set swPart = swApp.ActiveDoc
    MsgBox "You changed documents to a Part"
    Case 2
    Set swAssy = swApp.ActiveDoc
    MsgBox "You changed documents to an Assembly"
    Case 3
    Set swDrw = swApp.ActiveDoc
    MsgBox "You changed documents to a Drawing"
    End Select
    End Function

    Private Function swAssy_ActiveConfigChangePostNotify() As Long

    MsgBox "You changed you Assembly's Configuration"

    End Function

    Private Function swPart_ActiveConfigChangePostNotify() As Long

    MsgBox "You changed you Part's Configuration"

    End Function


    Hope that gets you running.

    Corey
     
    Corey Scheich, Jul 14, 2004
    #4
  5. I think I have finally conquered this beast. Although it's not dead yet, I
    have beat it into submission. It functions pretty much as I wanted it to,
    but I know it loops a few times, so tomorrow I will step through it to look
    for optimizing possibilities. Thanks to all, and to all "A good night."
    (Checking out, backing up, logging off, climb on the bike, roar through the
    evening traffic, go home....) :)

    WT
     
    Wayne Tiffany, Jul 15, 2004
    #5
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.
Similar Threads
There are no similar threads yet.
Loading...