Get access to Revit Project Browser tree via Win32 api calls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Trying to get access to the Revit Project Browser tree. so I can traverse and act on desired tree nodes. Using Spy++ to get class id as highlighted below. Then trying to SendCommand to get the root of the tree.... its returning 0; I also tried the SendCommandOn the parent window and it also failed.
Can anyone help?
The treeRoot variable in line:
int treeRoot = SendMessage((int)hWnd, TVM_GETNEXTITEM, TVGN_ROOT, IntPtr.Zero);"
below is returning 0;
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Process[] processes = Process.GetProcessesByName("Revit");
if (0 < processes.Length)
{
IntPtr mainWindowHandle = processes[0].MainWindowHandle;
EnumChildWindows(mainWindowHandle, winEnumCallBack, IntPtr.Zero);
}
return Result.Succeeded;
}
static bool winEnumCallBack(IntPtr hWnd, IntPtr lParam)
{
StringBuilder className = new StringBuilder(100);
IntPtr result = GetClassName(hWnd, className, className.Capacity);
if (className.ToString() == "Afx:0000000140000000:b:0000000000010003:0000000000000006")
{
int treeRoot = SendMessage((int)hWnd, TVM_GETNEXTITEM, TVGN_ROOT, IntPtr.Zero);
// treeRoot returning 0 - Help !!!!!
}
return true;
}