algorithmic modeling for Rhino
I have a method that works on GH_Structure 's. The general method accepts asks for GH_Structure<IGH_Goo> as i need it to be versatile.
I found there is a method GH_Structure<whatever>.DuplicateCast<whatever>()
but somehow i don't manage to make it work. Any hint somebody.
Thanks in advance.
Manuel
I think there should should be somewhere a repository for leaving PHYSICAL beer to all the people helping in the forum by the way, THANKS A LOT GUYS. LIKE THE FORUM
Tags:
Hi,
It's not possible to do that by casting.
GH_Structure<GH_Point> does not derive from GH_Structure<IGH_Goo> they are just instances of the same template class.
You'll have to create a new GH_Structure and do the casting on each one of the inner elements and in your case it's possible only because they DO derive.
Yes It is right what you say.
But i found a method of the class GH_Structure, it is called DuplicateCast which is meant to do that. The problem is that I somehow don't figure out how to use it, it somehow has a tricky sintax.
Thanks.
Manuel
You could use the DuplicateCast method, you'll have to supply a conversion delegate.
private IGH_Goo conversion(GH_Point data)
{
return data; // easy since GH_Point already implements IGH_Goo.
}
pass in a reference to this method to DuplicateCast and it should work.
--
David Rutten
david@mcneel.com
Thanks David.
You earned the first beer in the repository.
It is exactly what I wanted, but I am not still familiarized with delegates, but it worked.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by