Grasshopper

algorithmic modeling for Rhino

Hi All,

can someone tell me how to properly tap into a GHA file just like it is possible with a dll.

If I add the GHA via "Manage Assemblie" I get the following casting error.

error: [A]CustomClassXY cannot be cast to [B]CustomClassXY. Type A originates from 'CustomLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' in a byte array. Type B originates from 'CustomLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadFrom' at location 'C:\Users\T\AppData\Roaming\Grasshopper\Libraries\CustomLib.gha'. (line: 96)


This is how I do the casting:

List<CustomLib.SomeClass.CustomClassXY> AllINPUTs = new   List<CustomLib.SomeClass.CustomClassXY>();

for (int i = 0 ; i < INPUT.Count; i++)//
    {
      AllINPUTs.Add((CustomLib.SomeClass.CustomClassXY) INPUT[i]);
    }

The GHA is compiled with two namespaces, one for the component one for the library.

Thanks a lot in advance,

Tim

Views: 673

Replies to This Discussion

The error says it. The casting is ambiguous. Try to use different class names...it's finding 2 CustomClassXY.

Usually this script above should work, when the Types are right.

Hope this solves the problem, good luck with it.

FF

To elaborate, if you have two namespaces imported which have similarly named types, you need to include the namespace with the type. So instead of typing CustomClassXY, you'd need either A.CustomClassXY or B.CustomClass.XY.

If even the namespaces are the same, then I think you probably made a mistake importing two different versions of some assembly where you only meant to import one.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service