- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I found this question here, https://forums.autodesk.com/t5/revit-api-forum/pass-value-from-ribbon-pushbutton-to-function/m-p/68... ,but I must be newer to the Revit api than this person, I am still lost.
I want to pass an int from a revit ribbon button selection in my app.cs file, to my main command.cs file. Sample view of the ribbon:
I want to pass an int = 3 if the user selected bend #3 and and pass int 4 if the user selects "bend #4". Is there an easy way to do this with the app.cs file? Or should I just make a whole bunch of differing Command Files that changes the value of the int? It seems like the more elegant way to handle this is to pass the variable from the app.cs file but I am not sure if this is possible. Here is the bit of code that relies on the single value in the command.cs file:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
// Access current selection
Selection sel = uidoc.Selection;
// Initialize a list of points
IList<XYZ> selectedPoints = new List<XYZ>();
// Hitting Escape will exit out of the loop for selecting points
bool value = true;
while (value)
{
try
{
XYZ point1 = uidoc.Selection.PickPoint("Select a point");
selectedPoints.Add(point1);
}
catch (Exception exp)
{
value = false;
}
}
//THIS VALUE NEEDS TO BE UPDATED BASED ON USER SELECTED BTN
int bar_size_chosen = 4;
//crate line function creates the first main curve, from which all other lines will be created
Thank you for your help!
Solved! Go to Solution.