- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My solution has multiple projects, with one of the projects acting as the entry point, built with the ACAD Wizard. All of the projects use 1 or more PaletteSets that are set up in their own classes alongside the CommandClass..
The issue I am having is this... after opening one of these PaletteSets during an AutoCAD session, if it is left open when I close AutoCAD, the next time AutoCAD opens, during ACAD startup the PalleteSet tries to reopen itself. In this case the "User Defined Part" palette was left open.
I have recently undertaken rebuilding this set of projects from ones that were organically developed over many years, where PaletteSets worked just fine. Here's a sample of how I'm setting up my palettes.
' (C) Copyright 2021 by JL
'
Imports System.Drawing
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Windows
Imports FreemanCAD
' This line is not mandatory, but improves loading performances
<Assembly: CommandClass(GetType(UserDefinedParts.MyCommands))>
Namespace UserDefinedParts
' This class is instantiated by AutoCAD for each document when
' a command is called by the user the first time in the context
' of a given document. In other words, non static data in this class
' is implicitly per-document!
Public Class MyCommands
Friend Shared UDP_ps As PaletteSet = Nothing
<CommandMethod("USERDEFINEDPARTS", "UDP", "UDP", CommandFlags.Transparent)>
Public Sub UserDefinedParts()
If UDP_ps Is Nothing Then
UDP_ps = New UDP_Palette
End If
UDP_ps.Visible = True
End Sub
End Class
Public Class UDP_Palette
Inherits PaletteSet
Private Shared m_DocData As MyDocData = Nothing
Private doc As Document = Core.Application.DocumentManager.MdiActiveDocument
Private ed As Editor = doc.Editor
Private db As Database = doc.Database
Private m_PalState As Boolean = False
Private ReadOnly paletteVisibility As Boolean = False
Public Sub New()
MyBase.New("User Defined Parts", New Guid("331F70E2-4651-4575-98C3-D65557CEAA22"))
Style = PaletteSetStyles.ShowCloseButton Or PaletteSetStyles.ShowTabForSingle Or PaletteSetStyles.ShowAutoHideButton
ed.WriteMessage(vbCrLf & "Loading UDP Tool")
Dim form_UDP = New FRM_UDP()
Add("UDP", form_UDP)
DarkThemedIcon = My.Resources.userdefinedpart
LightThemedIcon = My.Resources.userdefinedpart
DockEnabled = DockSides.Left + DockSides.Right
Size = New Size(330, 650)
Visible = True
paletteVisibility = True
m_PalState = True
KeepFocus = True
If m_DocData Is Nothing Then m_DocData = New MyDocData
AddHandler Core.Application.DocumentManager.DocumentActivated, AddressOf DocumentManager_DocumentActivated
AddHandler StateChanged, AddressOf GetPalleteSetState
End Sub
Private Sub GetPalleteSetState(sender As Object, e As PaletteSetStateEventArgs)
m_PalState = e.NewState.ToString = "Show"
End Sub
Private Sub DocumentManager_DocumentActivated(sender As Object, e As DocumentCollectionEventArgs)
If m_DocData IsNot Nothing Then
Visible = Core.Application.DocumentManager.Count >= 1 AndAlso m_PalState
doc = Core.Application.DocumentManager.MdiActiveDocument
If doc IsNot Nothing Then
db = doc.Database
ed = doc.Editor
End If
End If
End Sub
End Class
End NamespaceAm I missing anything there that would be causing this startup issue? Any help is greatly appreciated!!
Solved! Go to Solution.