/***************************************************/ /**** Public methods ****/ /***************************************************/ public RevitListenerAdapter GetAdapter(Document document) { RevitListenerAdapter adapter; if (!m_Adapters.TryGetValue(document, out adapter)) { adapter = new RevitListenerAdapter(UIControlledApplication, document); m_Adapters[document] = adapter; } if (AdapterSettings != null) { adapter.RevitSettings = AdapterSettings; } return(adapter); }
/***************************************************/ /**** Public methods ****/ /***************************************************/ public void Execute(UIApplication app) { lock (RevitListener.Listener.m_PackageLock) { try { //Clear the event log BH.Engine.Reflection.Compute.ClearCurrentEvents(); //Get instance of listener RevitListener listener = RevitListener.Listener; IEnumerable <object> objs; // Do not attempt to push if no document is open. if (app.ActiveUIDocument == null || app.ActiveUIDocument.Document == null) { BH.Engine.Reflection.Compute.RecordError("The adaper has successfully connected to Revit, but open document could not be found. Push aborted."); objs = new List <object>(); } else { //Get the revit adapter RevitListenerAdapter adapter = listener.GetAdapter(app.ActiveUIDocument.Document); //Push the data objs = adapter.Push(listener.LatestPackage, listener.LatestTag, listener.LatestPushType, listener.LatestConfig); } //Clear the lastest package list listener.LatestPackage.Clear(); listener.LatestPushType = oM.Adapter.PushType.AdapterDefault; listener.LatestConfig = null; listener.LatestTag = ""; //Return the pushed objects listener.ReturnData(objs); } catch (Exception e) { RevitListener.Listener.ReturnData(new List <string> { "Failed to push. Exception from the adapter: " + e.Message }); } } }
/***************************************************/ /**** Public methods ****/ /***************************************************/ public void Execute(UIApplication app) { lock (RevitListener.Listener.m_PackageLock) { try { //Clear the event log BH.Engine.Reflection.Compute.ClearCurrentEvents(); //Get instance of listener RevitListener listener = RevitListener.Listener; int count = 0; // Do not attempt to remove if no document is open. if (app.ActiveUIDocument == null || app.ActiveUIDocument.Document == null) { BH.Engine.Reflection.Compute.RecordError("The adaper has successfully connected to Revit, but open document could not be found. Remove aborted."); } else { //Get the revit adapter RevitListenerAdapter adapter = listener.GetAdapter(app.ActiveUIDocument.Document); //Remove the elements count = adapter.Remove(listener.LatestRequest, listener.LatestConfig); } //Clear the previous data listener.LatestConfig = null; //Return the number of deleted elements listener.ReturnData(new List <object> { count }); } catch (Exception e) { RevitListener.Listener.ReturnData(new List <string> { "Failed to remove. Exception from the adapter: " + e.Message }); } } }