Author Topic: Automatically load .dll file in 2010?  (Read 7335 times)

0 Members and 1 Guest are viewing this topic.

deathman20

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #15 on: March 01, 2011, 09:26:44 AM »
Exactly AlexF.  Just need to figure out how.

vegbruiser

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #16 on: March 01, 2011, 11:30:27 AM »
Hey, I found something you might like using this Google search:

http://au.autodesk.com/?nd=material&session_material_id=5314 is a link to an Autodesk University class handout (hosted by Wayne Brill) from 2009 and on pages 19 onwards it details how to add a Ribbon to a specific Workspace.

The code in that document seems to be based around creating a new workspace and adding your ribbon bar to it - in this case the Workspace being modified is named "Demo Workspace".

It wouldn't be too much of a stretch I don't think to have it modify an existing workspace - although if you really wanted to get your users' attention you could have your add-in create its very own workspace.

deathman20

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #17 on: March 01, 2011, 12:41:27 PM »
Oh good find Alex.  I'll put this on my list to check out but looks like what I need.  Thanks!

Right now in the mix of figuring out a block inserting issue with jigging which isn't making me a happy camper.  But thats for another thread.

deathman20

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #18 on: March 01, 2011, 03:30:09 PM »
Well had to do something productive today so looked further into this.

Removed this....
Code: [Select]
    Public Sub TrapWSCurrentChange(ByVal sender As Object, _
                                   ByVal e As cadAppSrvs.SystemVariableChangedEventArgs)
        If e.Name.Equals("WSCURRENT") Then createRibbon()
    End Sub

Added this instead.....
Code: [Select]
    Overridable Sub Initialize() Implements IExtensionApplication.Initialize
        If Autodesk.Windows.ComponentManager.Ribbon Is Nothing Then
            'load the custom Ribbon on startup, but at this point
            'the Ribbon control is not available, so register for
            'an event and wait
            AddHandler Autodesk.Windows.ComponentManager.ItemInitialized, AddressOf ComponentManager_ItemInitialized
        Else
            'the assembly was loaded using NETLOAD, so the ribbon
            'is available and we just create the ribbon
            createRibbon()
        End If
    End Sub

    Overridable Sub Terminate() Implements IExtensionApplication.Terminate

    End Sub

    Private Sub ComponentManager_ItemInitialized(ByVal sender As Object, ByVal e As RibbonItemEventArgs)
        'now one Ribbon item is initialized, but the Ribbon control
        'may not be available yet, so check if before
        If Autodesk.Windows.ComponentManager.Ribbon IsNot Nothing Then
            'ok, create Ribbon
            createRibbon()
            'and remove the event handler
            RemoveHandler Autodesk.Windows.ComponentManager.ItemInitialized, AddressOf ComponentManager_ItemInitialized
        End If
    End Sub

Did that and worked like a charm.  It will only load on the workspace that is currently open but if you change to a new workspace and close/reopen the program it will be there.  So really for most purposes it works as intended.  That document helped out lots Alex thanks.

vegbruiser

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #19 on: March 02, 2011, 04:30:54 AM »
I might be wrong but wouldn't keeping the TrapWSCurrentChange() method allow the code to create the ribbon bar regardless of which workspace you switch to?

deathman20

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #20 on: March 02, 2011, 09:11:35 AM »
I might be wrong but wouldn't keeping the TrapWSCurrentChange() method allow the code to create the ribbon bar regardless of which workspace you switch to?


Yes, though there is a minor glitch with it.  Sometimes, not always it was opening another instance of the tabs if going back to a different workspace that already had it open.  Really it won't bother us here that I know of since we just use a single workspace and thats it.  Course can be something to look at in the future.

vegbruiser

  • Guest
Re: Automatically load .dll file in 2010?
« Reply #21 on: March 02, 2011, 09:25:08 AM »
You mean it was duplicating Ribbon Tabs?

That could be solved by checking whether there's already a tab with the same name in this whatever workspace you're switching to couldn't it?