- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have a (weird) problem with one of my add-ins that uses a dockable window. It's starting to drive me a little crazy because I have no clue what is going on.. The option to add it disappears (option is gone at +, and at view->user interface). It seems to happen most of the time, but not consistently. Am not sure is it a bug in Inventor or a mistake on my side.
The add-in is loaded as it should. As far as I know I am correctly initializing the window. I have no deactivation implemented, cause I could not find anywhere that this is required. Below is my dockable window initialization code.
public partial class Plugin
{
private DockableWindow? propertyWindow;
public static IHost? AppHost { get; set; }
public void InitializePropertyEditor()
{
// create window
var mainWindow = AppHost.Services.GetRequiredService<MainWindow>();
mainWindow.WindowStyle = WindowStyle.None;
mainWindow.ResizeMode = ResizeMode.NoResize;
mainWindow.Visibility = Visibility.Visible;
// add the window to the inventor window
var helper = new WindowInteropHelper(mainWindow);
helper.EnsureHandle();
var hwnd = helper.Handle;
propertyWindow = GetDockableWindow();
propertyWindow.DisabledDockingStates = DockingStateEnum.kDockBottom | DockingStateEnum.kDockTop;
propertyWindow.AddChild(hwnd);
propertyWindow.ShowVisibilityCheckBox = true;
// propertyWindow.Visible = false;
// add the hook to intercept some key events
HwndSource.FromHwnd(hwnd)?.AddHook(WndProc);
}
private DockableWindow GetDockableWindow()
{
var internalName = "BasAutomation.PropertyEditor";
var windowName = "Properties";
DockableWindow propertyWindow;
try
{
propertyWindow = app.UserInterfaceManager.DockableWindows[internalName];
logger.LogInformation($"Found existing dockable window. InternalName: {internalName}");
}
catch
{
propertyWindow = app.UserInterfaceManager.DockableWindows.Add(InventorClient.AddInClientIdFormatted, internalName, windowName);
logger.LogInformation($"Created new dockable window. InternalName: {internalName}");
}
return propertyWindow;
}
private const uint DLGC_WANTARROWS = 0x0001;
private const uint DLGC_WANTTAB = 0x0002;
private const uint DLGC_WANTALLKEYS = 0x0004;
private const uint DLGC_HASSETSEL = 0x0008;
private const uint DLGC_WANTCHARS = 0x0080;
private const uint WM_GETDLGCODE = 0x0087;
private const uint WM_SIZING = 0x0214;
private static IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_GETDLGCODE)
{
handled = true;
return new IntPtr(DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL | DLGC_WANTTAB | DLGC_WANTALLKEYS);
}
return IntPtr.Zero;
}
}
I found out that inventor stores dockable window state in the registry. When inventor is closed, it writes an entry to the Pane folder. Here position / docking state etc are stored.
These are my observations, I don't know will this help, but like i said, I'm really lost here:
1. If I start fresh, so without the folder with the GUID as name, and without the pane folder entry, and visible = true, the dockable window shows, but is floating. (screenshot attached)
Then I can dock it. When I close it the option to add it back is gone.
When I restart inventor, the window shows docked at the last docked location (before closing)..
2. When the window is active, I don't see it in the User interface dropdown.
3. When visible is set to false, I don't see the option to add the window at all. However if I set the visibility to true with VBA, it does show.
4. If I set a docking state and visible = true, it does load the panel everytime. Only again, when I close it, I cannot re-add. Anyway, I want to have the initial state as invisible and not docked, so the user can pick.
5. To make it even stranger, there are random moments that suddenly everything works fine...
TLDR:
I'm facing an issue with a dockable window in my Autodesk Inventor add-in.
The option to re-add the dockable window disappears inconsistently from both the "+" button and View > User Interface. The dockable window is created successfully. With VBA I can set the window visibility to true and it shows up.
Does anyone have any idea?
Free apps: Smart Leader | Part Visibility Utility | Mate Origins
Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro
Solved! Go to Solution.