Message 1 of 6

Not applicable
02-13-2018
07:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone!
As the title says, is it possible to obtain objects from event handlers using ref?
I want to use Revit API and WPF in order to extract a list of elements from the model (and for this I'm going to use Revit API) and then import it to WPF. However, as I use external event in order to use Revit API, all the lists and instances that are obtained in the event are not transferred to the main code (i.e. Window and Button_Click).
So this is the summary of the code I'm using:
//So I'm doing a Window in WPF public partial class Window1: Window { //create the External Events which will be read from the previous window public ExternalEvent Event; //create an instance that should be readable throughout the code and that should have the same reference that the one in the EvenHander (list) IList<string> list; public ThirdWindow(ExternalEvent exEvent) { InitializeComponent(); Event = exEvent; } //button in WPF that will raise the event and use the list private void button_Click(object sender, RoutedEventArgs e) { //call the event Event.Raise(); //and then I want to store in List_button the list I had in the EventHandler ref IList<string> List_button = ref list; } public class EventRegisterHandler_IdentifyMaterialsWithoutSP : IExternalEventHandler { public bool EventRegistered { get; set; } public IList<string> MaterialList_W3 { get; set; } public void Execute(UIApplication app) { UIDocument uiDoc = app.ActiveUIDocument; Document doc = app.ActiveUIDocument.Document; //in this part I'm calling Class1 in order to use Function1 Class1 revitFunction = new Class1(); //Function1 will allow me to store a IList of stuff IList<string> List1 = revitFunction.Function1(doc); //and I want to be able to have access to this list OUTSIDE the event handler ref IList<string> list = ref List1; } public string GetName() { return "EventRegisterHandler"; } }
So, is there a way to extract information out of the event handler? is it possible to extract a IList<> from the event handler and use it in the Window Class?
Solved! Go to Solution.