Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit API AddInCommandBinding for ID_PROCESS_DROP

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
647 Views, 7 Replies

Revit API AddInCommandBinding for ID_PROCESS_DROP

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

 

7 REPLIES 7
Message 2 of 8
augusto.goncalves
in reply to: Anonymous

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
Message 3 of 8
Anonymous
in reply to: augusto.goncalves

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.
Message 4 of 8
augusto.goncalves
in reply to: Anonymous

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
Message 5 of 8
Anonymous
in reply to: augusto.goncalves

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.
Message 6 of 8
Anonymous
in reply to: augusto.goncalves

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.

Message 7 of 8
arnostlobel
in reply to: Anonymous

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
Message 8 of 8
Anonymous
in reply to: arnostlobel

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.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community