Hm, so this object is not coming from our Objects classes? It would greatly help if you could share the class definition (or a minimal version of it) so we can reproduce & debug on our end!
Indeed, I was experimenting with a custom class to define any Parametric CrossSection in SCIA/ADM following SAF conventions.
Here is the object definition:
namespace Objects.Structural.SCIA.Properties.Profiles
{
public class SCIAParametricCrossSection: SectionProfile
{
public SCIAProfileId profileId { get; set; }
public double[] parameters { get; set; }
public SCIAParametricCrossSection() { }
[SchemaInfo("Parametric", "Creates a Speckle structural parametric section profile for SCIA", "SCIA", "Section Profile")]
public SCIAParametricCrossSection(string name, SCIAProfileId profileId, double[] parameters)
{
this.name = name;
this.profileId = profileId;
this.parameters = parameters;
this.shapeType = ShapeType.Parametric;
}
}
}
In any case, I seem to have found a working solution for the method that was throwing the error (not using the Activator class), though not sure if it is robust for other potential use cases:
private object GetObjectListProp(IGH_Param param, List<object> values, Type t)
{
if (!values.Any()) return null;
var listElementType = t.GetElementType();
var list = (IList)Array.CreateInstance(listElementType, values.Count);
for (int i=0; i< values.Count; i++)
{
list[i] = (ConvertType(listElementType, values[i], param.Name));
}
return list;
}
While I agree this is a limitation, if you set that double[] parameters { get; set; } to be a List<double> parameters { get; set; } we might get away cheaper - not sure if this is something affordable given the class design you’re working with, but it might not require changes in Gh!
For the change per se, it feels like subjective decades since i’ve looked through that, so I’ll defer to @AlanRynne
Hey @kelvin, thanks for the extra clarification. I did some initial tests and your proposed solution seems to work, but i’ll have to do some more tests to ensure nothing is breaking in any of the other Schema classes.
As for @dimitrie’s comment on swapping the model to use List<double>, I can confirm that should also solve your issue.
Anyway, I opened an issue in GitHub so we could track this
Thanks for the feedback! I will for now use a List instead of Array, shouldn’t change that much in the end. I went for an Array as I saw it appearing in your object model as well, particularly for the ETABS specific objects.
General question, do you prefer to see these code/bug related questions being asked here, or directly on Github, or perhaps it doesn’t really matter?
We don’t have a pre-defined rule for when to open an issue vs a thread in the community; but here’s my take:
Opening threads is preferable as it does give a better chance for non-“tech-saavy” users to jump into the conversation. This is specially true when discussing changes/updates to existing features.
That being said, if you do find a limitation/bug on the code-side of things and know where it’s coming from, etc… (like this case right here!) then opening an issue directly in GitHub if fine; eventually any bugs will end up tracked in GitHub anyway.