public override bool CastFrom(object source) { if (source == null) { return(false); } int val; LayerTable LT = Rhino.RhinoDoc.ActiveDoc.Layers; if (GH_Convert.ToInt32(source, out val, GH_Conversion.Both)) { Rhino.DocObjects.Layer La = LT.FindIndex(val); if (La == null) { Value = null; return(false); } else { Value = La; return(true); } } Guid id; if (GH_Convert.ToGUID(source, out id, GH_Conversion.Both)) { Rhino.DocObjects.Layer La = LT.FindId(id); if (La == null) { Value = null; return(false); } else { Value = La; return(true); } } string Name; if (GH_Convert.ToString(source, out Name, GH_Conversion.Both)) { int Index = LT.FindByFullPath(Name, -1); if (Index == -1) { Rhino.DocObjects.Layer La = new Layer(); La.Name = Name; Value = La; return(true); } else { Value = LT.FindIndex(Index); return(true); } } if (source.GetType() == typeof(Layer)) { Value = (Layer)source; return(true); } if (source.GetType() == typeof(Hu_Layer)) { Value = ((Hu_Layer)source).Value; return(true); } return(false); }