High-level question: is there any way to access GH_Goo types in C# Script components before they get converted to other types on inputs via the ScriptVariable?
Description: Probably a silly question, but I am blanking out. I am writing a C# Script component (must be so, cannot be a compiled one) and I want to access the history of transforms for a Transform object using GH_Transform.CompoundTransforms (as I guess the native Split component does). If the input type is set to Transform, then I lose that history as a I get the flat 4x4 matrix without the history. If I use a generic object:
private void RunScript(System.Object T, ref object X)
{
Print(T.ToString());
GH_Transform xform = T as GH_Transform;
if (xform == null) {
Print("null");
}
else {
Print(xform.ToString());
}
}
…it stringifies to a Transform, but the cast fails:
My guess here is that the object gets “flattened” to a Transform as it enters the C# Script, before being further “flattened” to an object? Is there any way to access the original GH_Transform at this point?
No, almost all goo types will cast themselves to a ‘script safe’ type before they are even handed to the script assembly. I’m afraid you’ll need to create a component using Visual Studio.
You can process VolatileData yourself, but you may lose the convenience of item/list access.
If the performance is not an issue, you can rebuild GH_Transform from Transform type, which is the real type you get. Just use var transform = new GH_Transform(T as Transform)
Agreed, this is for sure an ugly solution with a lot of potential errors, but under the premise “has to be a script component, cannot be compiled” it would be an option