Load family/place instance using externalcommand vs. externalevent

Load family/place instance using externalcommand vs. externalevent

garrettrAH7ED
Explorer Explorer
635 Views
5 Replies
Message 1 of 6

Load family/place instance using externalcommand vs. externalevent

garrettrAH7ED
Explorer
Explorer

I'm attempting to load(if needed) and place family instances in the same way as this post from Jeremy(minor updates to work in 2023 vs 2013) but using an externalevent instead of an externalcommand.

However, PromptForFamilyInstancePlacement seems to not be working correctly. When executed, the family is loaded/selected(ex: PVC Coupling), but isn't visible when hovering over other elements(ex: PVC pipe) and doesn't place when clicked. Any help appreciated!

0 Likes
636 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

Hah. Well, an external event may catch Revit at an unfortunate or unexpected moment, maybe. Have you tested compiling and running the Revit SDK external event sample? It does not use promptforfamilyinstanceplacement, just PickPoint et al, but it might give you a hint on how to get the Revit UI into a suitable state for proper UI interaction.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 6

garrettrAH7ED
Explorer
Explorer

After trying some things out, it looks like it's a problem with raising an external event from a list box event handler(I'm using WPF). Raising that same event from a button click event handler works just fine. Any idea why it isn't working for list box handlers?

0 Likes
Message 4 of 6

Kennan.Chen
Advocate
Advocate

I prefer using external events in my development process. The IExternalCommand interface is defined in the RevitAPIUI.dll and belongs to the Autodesk.Revit.UI namespace. This interface is specifically designed to integrate customized functionalities into the Revit UI. External events provide a fundamental way for developers to call the Revit API within their code.

 

Regarding your problem, it would be helpful if you could provide a simple demo that can reproduce the case.

0 Likes
Message 5 of 6

reylorente1
Collaborator
Collaborator

Hello, see if this code helps you. It is made in Revit 2024

0 Likes
Message 6 of 6

garrettrAH7ED
Explorer
Explorer

Problem turned out to be using any Taskdialogs immediately before calling the external event, removing these allowed promptforfamilyinstanceplacement to work correctly. Not sure why this is the case.

I found this out by using the SampleApp from J0ffard_13(from here), switching the PickPoint to promptforfamilyinstanceplacement and adding a listbox to the dockable pane .

Thanks for the help!

0 Likes