algorithmic modeling for Rhino
Hello everyone,
I am developing a set of tools as a GH plug-in, now working (for the most part) without too many issues as a GHA. As part of the plug-in I have a few custom data objects I need to use to ferry data between the components. All of the custom types are wrapped as GH_Goo or GH_GeometricGoo. I have no issues with data exchange between the components. However I am not able to pass proper data into the scripting component of GH.
1. I have tried using the object type hint but the data is not unwrapping itself inside the script component. It prints as my custom data object but I cannot access the attributes inside it. I should mention that my .GHA is referenced as an assembly inside the script component. I think it must be something with my Goo wrapping (I've tried several .ScriptVariable override approaches but no luck) I am attaching the GH_GeometricGoo class I created.
2. I have tried to construct a custom input parameter from inside the scripting component using the custom param for I've set up inside the GHA but when I try to use it or edit the script Rhino+GH crashes.
I've created a custom input param for the script like this
MGraphParameter mPar = new MGraphParameter();
mPar.Access = GH_ParamAccess.item;
mPar.Name = "MGraph";
mPar.NickName = "G";
mPar.Description = "This is a description";
Component.Params.Input[0] = mPar;
After this the component acts weird and I cannot connect any wire to the new input
If I do manage to connect something to it (by deleting it and recreating it) I get this error
1. [A]Grasshopper.Kernel.Data.GH_Structure`1[Ivy.MGraphGoo] cannot be cast to [B]Grasshopper.Kernel.Data.GH_Structure`1[Ivy.MGraphGoo]. Type A originates from 'Grasshopper, Version=1.0.0.20, Culture=neutral, PublicKeyToken=dda4f5ec2cd80803' in the context 'LoadFrom' at location 'C:\Program Files\Common Files\McNeel\Rhinoceros\5.0\Plug-ins\Grasshopper (b45a29b1-4343-4035-989e-044e8580d9cf)\0.9.76.0\Grasshopper.dll'. Type B originates from 'Grasshopper, Version=1.0.0.20, Culture=neutral, PublicKeyToken=dda4f5ec2cd80803' in the context 'LoadFrom' at location 'C:\Program Files\Common Files\McNeel\Rhinoceros\5.0\Plug-ins\Grasshopper (b45a29b1-4343-4035-989e-044e8580d9cf)\0.9.76.0\Grasshopper.dll'.
Can anybody offer some ideas ? Getting either cases to work would be great. Thanks.
Andrei.
Tags:
Why not add the MGraphParameter from the RegisterInputParameters* method? pManager has a method for adding any type of parameter.
Gobble gobble!
(You have to be an American to understand that one.)
Bump!
Hey Andrei :)
The only way I know of to be able to script with custom data types is to launch grasshopper with "COFF Loading" disabled. (this option is accessible from the GrasshopperDeveloperSettings command.) If you do this, you will be able to feed your data into the c# (or other) scripting component as "object" and then cast it internally to the desired type (likely you will need to add your own GHA or DLL as a reference to the script component).
I don't know of any way to actually add special types to the script component type hints themselves - will have to defer to Mr. Rutten for that one.
it's possible (haven't tested this myself) that you can avoid setting the app-level COFF toggle by modifying the load setting for your plug-in alone - this can be done on a per-user basis in the GH preferences (solver / plug-in loading, find yours and click the load mechanism button til you get the disc icon), or you can force a certain loading in your plugin. (details on that here).
Hi Andrew,
So this thing needs to be set by every user (Rhino/GH different install) using my plug-in at least once ?
I was looking for a solution to expose some of the API inside the script component together with my custom types available for anyone using Ivy.
How are some other plug-in developers doing this ? I know Kangaroo is using custom goals scriptable inside GH and it relies on custom types. They seem to work fine and are converted from generic objects by default inside the C# script.
Disabled the COFF setting did not do the trick for me. I'm not sure what else I could be trying to make this work.
Well I worked. Setting the COFF to disabled did the trick.
Thanks Andrew, You saved me yet again :)
But it seems I can't get GH to abide by the load setting prescribed in the assembly.
Is the bug David talks about in the discussion you mentioned still present ?
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
© 2024 Created by Scott Davidson. Powered by