public override bool CastTo <Q>(ref Q target) { if (typeof(Q) == typeof(GH_Brep)) { var exportedStp = SolidExchanger.NXExport(Value); var import = SolidExchanger.GrasshopperImport(exportedStp); target = (Q)(object)new GH_Brep(import); return(true); } else if (typeof(Q) == typeof(GH_Surface)) { var rhino = Value.ToRhinoSurface(); if (rhino == null) { return(false); } target = (Q)(object)new GH_Surface(rhino); return(true); } else { Console.WriteLine(typeof(Q)); return(base.CastTo(ref target)); } }
public override bool CastFrom(object source) { if (source is GH_Brep gh_brep) { var interFile = SolidExchanger.GrasshopperExport(gh_brep.Value); Value = SolidExchanger.NXImport(interFile); return(true); } else { Console.WriteLine($"无法将 {source.GetType()} 转换为 NXOpen.Body"); return(base.CastFrom(source)); } }
public override bool CastTo <Q>(ref Q target) { if (typeof(Q) == typeof(GH_Brep)) { var body = Value; InterFile = SolidExchanger.NXExport(body); var s = SolidExchanger.GrasshopperImport(InterFile); target = (Q)(object)new GH_Brep(s); return(true); } else { Console.WriteLine($"无法将 NXOpen.Body 转换为 {typeof(Q)}"); return(base.CastTo(ref target)); } }