Advertisement
Guest User

Untitled

a guest
Jun 5th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. using Autodesk.Revit.DB;
  2. using Autodesk.Revit.UI;
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Reflection;
  10. using System.Reflection.Emit;
  11.  
  12. namespace Centek_Revit_Addin
  13. {
  14.     class DynamicButton
  15.     {
  16.         // I would like to use a function like this to generate the class during runtime, presumably using TypeBuilder:
  17.         public static void generateClass(int id)
  18.         {
  19.             // ... Code which would generate a class with the name "GeneratedClass" with the 'id' parameter appended at the end
  20.             // ... The class implements IExternalCommand
  21.             // ... The class has an Execute function with the parameters listed in the example, which returns a call to the Execute function in DynamicButton
  22.             //      along with the added integer 'id' parameter at the end
  23.         }
  24.  
  25.         public static Autodesk.Revit.UI.Result Execute(ExternalCommandData revit, ref string message, ElementSet elements, int id)
  26.         {
  27.             TaskDialog.Show("About", "ID of the class that called us: " + id);
  28.             return Autodesk.Revit.UI.Result.Succeeded;
  29.         }
  30.     }
  31.  
  32.  
  33.  
  34.     // ===== This class would have been generated during runtime using generateClass(15) ====== //
  35.     class GeneratedClass1 : Autodesk.Revit.UI.IExternalCommand
  36.     {
  37.         public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData revit, ref string message, Autodesk.Revit.DB.ElementSet elements)
  38.         {
  39.             return DynamicButton.Execute(revit, ref message, elements, 1);
  40.         }
  41.     }
  42.     // =================================================================== //
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement