Revit API AddInCommandBinding for ID_PROCESS_DROP

Revit API AddInCommandBinding for ID_PROCESS_DROP

Anonymous
Not applicable
887 Views
7 Replies
Message 1 of 8

Revit API AddInCommandBinding for ID_PROCESS_DROP

Anonymous
Not applicable

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!");
}

 

0 Likes
888 Views
7 Replies
Replies (7)
Message 2 of 8

augusto.goncalves
Alumni
Alumni

Hi,

 

We don't believe the generic drag'n'drop can be tracked with this command binding... but, more important, what is exactaly that you want to achieve with that? We may be able to find a better alternative...

 

Thanks!

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 3 of 8

Anonymous
Not applicable
I'd like to block/ replace drag/dropping a family into the project environment.
Just replace with a task dialog that says that action is not allowed.
Very similar to SDK example that demonstrates AddInCommandBinding

Erik Lewis, CDT, CM-BIM
BIM Manager

Devenney Group Ltd., Architects
Phoenix-Los Angeles-Oakland-Dallas

201 West Indian School Road
Phoenix, AZ 85013

T: 602.343.4099
M: 602.316.2514
elewis@devenneygroup.com

Leading the transformation of healthcare delivery through value-driven innovation
www.devenneygroup.com

This message may contain confidential and/or proprietary information, and it is intended for the person/entity to which it was originally addressed. Any use by others is strictly prohibited.
0 Likes
Message 4 of 8

augusto.goncalves
Alumni
Alumni

So what about track the 'FamilyLoadingIntoDocument' event? Inside it, just call e.Cancel()

 

public Result OnStartup(UIControlledApplication a)
{
  a.ControlledApplication.FamilyLoadingIntoDocument += ControlledApplication_FamilyLoadingIntoDocument;

}

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 5 of 8

Anonymous
Not applicable
Does that event include the regular Load Family Command and the Load into Project Command from the Family editor environment? I could look in the API help, but since I have your ear...

Really any hook to grab that event and block/disable it would work.
I'll try it tonight.


Erik Lewis, CDT, CM-BIM
BIM Manager

Devenney Group Ltd., Architects
Phoenix-Los Angeles-Oakland-Dallas

201 West Indian School Road
Phoenix, AZ 85013

T: 602.343.4099
M: 602.316.2514
elewis@devenneygroup.com

Leading the transformation of healthcare delivery through value-driven innovation
www.devenneygroup.com

This message may contain confidential and/or proprietary information, and it is intended for the person/entity to which it was originally addressed. Any use by others is strictly prohibited.
0 Likes
Message 6 of 8

Anonymous
Not applicable

Looks like that's new to the 2015 api? is that right?  If so, that won't work for this in particular as I need the code to work for 2014 as well.

0 Likes
Message 7 of 8

arnostlobel
Alumni
Alumni

If this is about preventing families to be loaded into a document, perhaps the Dynamic Updater framework can be used, which has been around since 2014 (and maybe even earlier.) And updater can be set to be notified about new elements created (types, in this case) and can post a failure that would prevent the current action (regardless of what it actually is) from being committed. Naturally, this approach may be less obvious to the end user than disabling a particular command, but the final effect would be the same – loading in new types is disabled.

Arnošt Löbel
0 Likes
Message 8 of 8

Anonymous
Not applicable

The idea is to prevent only that method of loading families.  When Families are dragged and dropped into the project, they don't trigger type catalogs and it goes against our company best practices.

 

I had thought about Dynamic Updater, but I wasn't sure how to identify when that particular event happened.

 

0 Likes