Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Autodesk.Revit.DB;
- using Autodesk.Revit.UI;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Reflection;
- using System.Reflection.Emit;
- namespace Centek_Revit_Addin
- {
- class DynamicButton
- {
- // I would like to use a function like this to generate the class during runtime, presumably using TypeBuilder:
- public static void generateClass(int id)
- {
- // ... Code which would generate a class with the name "GeneratedClass" with the 'id' parameter appended at the end
- // ... The class implements IExternalCommand
- // ... The class has an Execute function with the parameters listed in the example, which returns a call to the Execute function in DynamicButton
- // along with the added integer 'id' parameter at the end
- }
- public static Autodesk.Revit.UI.Result Execute(ExternalCommandData revit, ref string message, ElementSet elements, int id)
- {
- TaskDialog.Show("About", "ID of the class that called us: " + id);
- return Autodesk.Revit.UI.Result.Succeeded;
- }
- }
- // ===== This class would have been generated during runtime using generateClass(15) ====== //
- class GeneratedClass1 : Autodesk.Revit.UI.IExternalCommand
- {
- public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData revit, ref string message, Autodesk.Revit.DB.ElementSet elements)
- {
- return DynamicButton.Execute(revit, ref message, elements, 1);
- }
- }
- // =================================================================== //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement