2

I'm trying to bind the drag/drop of a family into the project and disable it.

My code is based on the Revit 2014 SDK Sample DisableCommand

My code has the .CanHaveBinding test and I have a dialog that displays success or failure. When I run the command it shows success, but I'm still able to drag drop families. Any ideas?

RevitCommandId commandId2 = RevitCommandId.LookupCommandId("ID_PROCESS_DROP"); 
    if (!commandId2.CanHaveBinding)
    {
        TaskDialog.Show("Error", "Drag/Drop cannot be overridden.");
    }
    else
    {
        TaskDialog.Show("Success", "Drag/Drop can be overridden.");
    }
try
{
    AddInCommandBinding dropBinding = uiapp.CreateAddInCommandBinding(commandId2);
    dropBinding.Executed += new EventHandler<Autodesk.Revit.UI.Events.ExecutedEventArgs>(dragDropDisable);
}
catch (Exception ex)
{
     Console.WriteLine("Error: {0}",ex.ToString());
}

    private void dragDropDisable( object sender, Autodesk.Revit.UI.Events.ExecutedEventArgs args)
{
TaskDialog.Show("Disabled", "Never Drag/Drop families into your project!");
}
BigBadBIM
  • 21
  • 1

2 Answers2

0

I think your method (and class) may need to be static - I've had weird things happen with instance methods in the past. Also, I'm not sure what your implementation of the method does exactly but it may need to return a CommandData.Result in order for the command to fully complete

prestonsmith
  • 758
  • 1
  • 9
  • 29
0

Try this

dropBinding.Executed += dragDropDisable;
Ameer Mansour
  • 53
  • 1
  • 10