I forgot to post the issue for a long time. The post is just for searching convenience or further improvement.
Under Windows, SDK and written here, GH_Document
has a zero-parameter constructor
var doc = new GH_Document();
However, in the Mac version of GH, there’s no such ctor
. The only available one is GH_Document(RhinoDoc)
. Rhino (namely Mono) would crash if you call the Windows version ctor.
Due to the nature of IL translation, you must separate two ctor
s in isolated methods. So in Pancake, I use the following code to target both platforms:
private static GH_Document NewEmptyDocumentMac()
{
return (GH_Document)Activator.CreateInstance(typeof(GH_Document), new object[] { Rhino.RhinoDoc.ActiveDoc });
}
private static GH_Document NewEmptyDocumentNormal()
{
return new GH_Document();
}
private static GH_Document NewEmptyDocument()
{
return Config.IsMono ? NewEmptyDocumentMac() : NewEmptyDocumentNormal();
}