Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
#region Namespaces using System; using System.Collections.Generic; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.DB.Events; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.DB.Architecture; #endregion namespace myEvent { public class RoomSelectionFilter : ISelectionFilter { public bool AllowElement(Element elem) { return elem is Room; } public bool AllowReference(Reference reference, XYZ position) { return true; } } public class ExternalEventExample : IExternalEventHandler { private ExternalEventExampleDialog mForm; public void Execute(UIApplication app) { UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; string info = ""; IList<Reference> myList = uidoc.Selection.PickObjects(ObjectType.Element,new RoomSelectionFilter(), "Pick a room"); foreach(Reference r in myList) { Element element = doc.GetElement(r); using(Transaction t = new Transaction(doc,"Pick")) { t.Start(); Parameter department = element.LookupParameter("Department"); department.Set(mForm.textBox1.Text); t.Commit(); } info += element.Name + Environment.NewLine; } TaskDialog.Show("Revit", info); } public string GetName() { return "External Event Example"; } } public class ExternalEventExampleApp : IExternalApplication { // class instance public static ExternalEventExampleApp thisApp = null; // ModelessForm instance private ExternalEventExampleDialog m_MyForm; public Result OnShutdown(UIControlledApplication application) { if (m_MyForm != null && m_MyForm.Visible) { m_MyForm.Close(); } return Result.Succeeded; } public Result OnStartup(UIControlledApplication application) { m_MyForm = null; // no dialog needed yet; the command will bring it thisApp = this; // static access to this application instance return Result.Succeeded; } // The external command invokes this on the end-user's request public void ShowForm(UIApplication uiapp) { // If we do not have a dialog yet, create and show it if (m_MyForm == null || m_MyForm.IsDisposed) { // A new handler to handle request posting by the dialog ExternalEventExample handler = new ExternalEventExample(); // External Event for the dialog to use (to post requests) ExternalEvent exEvent = ExternalEvent.Create(handler); // We give the objects to the new dialog; // The dialog becomes the owner responsible for disposing them, eventually. m_MyForm = new ExternalEventExampleDialog(exEvent, handler); m_MyForm.Show(); } } } [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)] public class Command : IExternalCommand { public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { ExternalEventExampleApp.thisApp.ShowForm(commandData.Application); return Result.Succeeded; } catch (Exception ex) { message = ex.Message; return Result.Failed; } } } }
Hello friends
I want to get textbox value in modeless form
How can I get the value?
Thanks in advance...
Solved! Go to Solution.