Quantcast
Channel: Grasshopper Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 3656

Access GH_Transform type from C# Script component

$
0
0

@garciadelcastillo wrote:

Hi there!

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:

image
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?

Thanks!

Posts: 7

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 3656


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>