Message 1 of 4
Not able to retrieve PushButtonData name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
so i have this method where i create multiple buttons with the same command but different naming as the parameter:
public static void AddButtonsToPanel(RibbonPanel panel, List<(string name, string labelText, string IconPath, string ToolTip)> buttons, string commandClassName)
{
var assembly = Assembly.GetExecutingAssembly();
foreach (var button in buttons)
{
var buttonData = new PushButtonData(button.name, button.labelText, assembly.Location, commandClassName)
{
ToolTip = button.ToolTip,
LargeImage = ImageUtility.LoadImage(assembly, button.IconPath)
};
panel.AddItem(buttonData);
}
}
var toolTip = "";
var familyKategorien = new List<(string Name, string Text, string IconPath, string ToolTip)>
{
("IT - Ausstattung", "IT\nAusstattung", "IT.png", toolTip),
("Tische", "Tische", "Tische.png", toolTip)
};
ButtonUtilities.AddButtonsToPanel(panel, familyKategorien, "familyCmd");
#endregion
and i try to get the button's name through the component manager:
private void ComponentManager_PreviewExecute(object sender, EventArgs e)
{
var buttonCaller = sender as Autodesk.Windows.RibbonButton;
if (buttonCaller != null)
{
Autodesk.Revit.UI.TaskDialog.Show("Debug",
$"Button Properties:\n" +
$"Name: {buttonCaller.Name}\n" +
$"Text: {buttonCaller.Text}\n" +
$"Id: {buttonCaller.Id}");
Familien.Kategorie = buttonCaller.Name; // Assign Name to Kategorie
if (string.IsNullOrEmpty(Familien.Kategorie))
{
Autodesk.Revit.UI.TaskDialog.Show("Debug", "Familien.Kategorie is empty!");
}
Familien.Kategorie = buttonCaller.Name;
}
}
However the result was null for everything except the text, shown in this pic:
Any insights or hints would be very appreciated!