Hi all,
I’m encountering a problem I find no answer to in the API reference nor on the forum.
I’m trying to write a plugin communicating with an external software via its own interface (RFEM5 and RF-COM). I’ve created custom types and params to handle my data and pass it to GH components. In my parameter definition, I overwrote the Prompt_Plural, which calls the software built-in pick tool.
Data collection can fail in various ways: the user closes the selection tool without having selected anything, or simply no model is open. I would like runtime messages to reflect that so I tried to call AddRuntimeMessage in my code in various places to no avail. The error messages simply don’t show up when I provoke the error. Instead, I get the traditionnal warning “1. Input failed to collect data” which is much less informative in that particular case. Is it possible to display my custom runtime messages in that particular case? Am I doing it correctly? Here’s the code:
protected override GH_GetterResult Prompt_Plural(ref List<RFEMTypes.RFEMMemberType> values)
{
IModel model = Initialize();
if (model == null)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No RFEM model seems to be open.");
return GH_GetterResult.cancel;
}
// Gets model data
IModelData data = model.GetModelData();
data.EnableSelections(true);
// picks objects with built-in RFEM pick tool that returns a string
string strPick = "";
model.GetActiveView().PickObjects(ToolType.SelectMembers, ref strPick); // picks the objects in RFEM and puts them in a str
if (string.IsNullOrEmpty(strPick))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No valid member was picked.");
Unitialize(ref model);
return GH_GetterResult.cancel;
}
else
{
values = new List<RFEMTypes.RFEMMemberType>();
foreach (int val in ParseIndices(strPick))
{
RFEMTypes.RFEMMemberType mem = new RFEMTypes.RFEMMemberType(-1);
if (mem.CastFrom(val)) // return true if cast succeeded
values.Add(mem);
else
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "A member provided is invalid. Please check the output.");
}
Unitialize(ref model);
return GH_GetterResult.success;
}
}
I’m sensing that has something to do with the return value of the method but I’m not sure. In a more general sense, any guidance on how runtime messages work would be very much appreciated.
Many thanks,