speckle-sharp
speckle-sharp copied to clipboard
SendReceiveTransport - Force Flatten Params
https://github.com/specklesystems/speckle-sharp/blob/ca31096d045131d35b120b84fa672b56b284b78a/ConnectorGrasshopper/ConnectorGrasshopper/Transports/SendReceiveTransport.cs#L37
Is it better to set param data mapping in BeforeSolveInstance() as a general approach to enforcing a particular GH_DataMapping type?
protected override void BeforeSolveInstance()
{
//Enforce flattened inputs.
Params.Input[0].DataMapping = GH_DataMapping.Flatten;
}
Hey @d3ssy!
Nice to have you around :) This is a nice suggestion, to be honest I'm not sure it would have any negative repercussions so I'm open to this, although I find that doing data tree operations behind the user is sometimes counter-intuitive.
I find it nicer report any limitations on the user and let the user decide, instead of modifying the input/output behaviour of GH altogether.
If a user inputs a data tree but gets a single list out, I fear it may be more confusing that just telling them what they're trying to do cannot be done.
We'd also love to know where this is coming from. Are you finding yourself constantly flattening that input? 😅
Hey @AlanRynne !
Yeah it's certainly a forceful approach and, to your point, could be confusing when you click on the flatten option and nothing happens.
An alternative, and I suppose the best of both worlds, is to at least flatten the input on RegisterInputParameters offering the user a default flattened state, and throw the warning if they so happen to change it in BeforeInstance.
Came across this by chance digging through the code; the test on the number of iterations in SolveInstance stumped me... bit of ocd kicked in lol.
Oh, that could be quite a nice solution indeed! Would be worth a shot, and seems like a 3 line change in the code 👍🏻
Anyway thanks for lurking through our code and pointing out weird stuff! We're always happy to re-visit old decisions if/when they make sense 😄
Closing for now! Feel free to reopen if you feel its required for you ;)