- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to help our BIM Support Staff who deal with tickets about issues rooted in users opening Revit Project Files with poor practices.
Examples:
- Double Clicking a Local or Central model from windows file explorer causing either file opening with the wrong arguments or unintended version upgrades.
- Opening C:\Revit Projects instead of opening a new local copy from the central model on the network drive.
My first thought was to see if I could use the process cmd line inputs to see if the DocumentOpeningEvent was triggered by a file explorer double click. This unfortunately doesn't work as /dde is triggered on all opening events via the Revit UI. That being said the DocumentOpeningEvent Cancel work well to stop the documents form upgrading and or opening. So my guess is using the Event Handler for the event is the right thought. I just am not full aware of how I might be able to identify how the opening information and program startup is occurring. Curious if anyone has gone down this road or has any ideas on how this might be possible.
public Result OnStartup(UIControlledApplication a)
{
a.ControlledApplication.DocumentOpening += new EventHandler<DocumentOpeningEventArgs>(FileExplorerLaunchLockOut);
return Result.Succeeded;
}
private void FileExplorerLaunchLockOut(object sender, DocumentOpeningEventArgs arga)
{
Process process = Process.GetCurrentProcess();
try
{
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
using (ManagementObjectCollection objects = searcher.Get())
{ cmdline = objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString(); }
}
catch { }
bool a2 = cmdline.Contains("/dde");
if (a2 == true)
{
arga.Cancel();
TaskDialog.Show("Invald Opening Document Method", "Document File for Revit Should not be opened via Windows Explorer/UI methods\nAKA: Double Clicking!!!!\nOpen Command Cancelled\nUse Reivt User Interface to open desired file");
}
}
// SendKeys.Send("^D");
//Process.GetCurrentProcess().CloseMainWindow();
}
Solved! Go to Solution.