Hello Folks,
I'm in need of a little assistance. Here is my scenario: I would like to start AutoCAD and then load a pallete in a button click event. I have created an Interface and COM class to handle this and all works fine. The problem I am having is that I do not want the pallete to load on the call GetInterfaceObject or NETLoad. I want to load the pallete in a button click event not in the Initialize Sub of the COM Class. Is this even possible? Thanks for any insight.
Ken
Here is the click event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim acAppObj As AcadApplication
acAppObj = CreateObject("AutoCAD.Application.17")
Dim acDoc As AcadDocument = acAppObj.ActiveDocument
Dim ThePalletObj As ClassLibrary1.IClass2 = acAppObj.GetInterfaceObject("ClassLibrary1.ComClass1")
'I would like to call this method to load the pallete.
'ThePalletObj.LoadIt()
End Sub
Here is the COM Class:
Imports Autodesk.AutoCAD.Windows
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System.Reflection
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
Implements IClass2
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "78fc94bf-f16a-45cc-9bf2-ede66358e582"
Public Const InterfaceId As String = "d8ee9b8d-3c6e-419d-aa22-d033efe97228"
Public Const EventsId As String = "a4044d8f-b0c8-43e8-8aa5-7c3e8ae88310"
#End Region
Private WithEvents CtlToolsPalette As Autodesk.AutoCAD.Windows.PaletteSet
Private WithEvents DocManager As Autodesk.AutoCAD.ApplicationServices.DocumentCollection
Private mycontrol As New UserControl1
Public Sub New()
MyBase.New()
End Sub
Public Sub LoadIt() Implements IClass2.LoadIt
'I would like to load the pallete here
End Sub
Private Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
CtlToolsPalette = New Autodesk.AutoCAD.Windows.PaletteSet("TestPallete")
With CtlToolsPalette
.Add("TestPallete", mycontrol)
.Style = 10
.MinimumSize = New System.Drawing.Size(200, 400)
.Size = New System.Drawing.Size(254, 400)
.Opacity = 90
.Visible = True
.DockEnabled = DockSides.Left + DockSides.Right
.Visible = True
End With
DocManager = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
End Sub
Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
End Sub
End Class