public Schema CreateSolveInput(IGH_DataAccess DA, bool cacheSolveOnServer, out List <string> warnings) { warnings = new List <string>(); var schema = new Resthopper.IO.Schema(); schema.CacheSolve = cacheSolveOnServer; var inputs = GetInputParams(); if (inputs == null) { if (!PathIsAppServer && !System.IO.File.Exists(Path)) { return(null); } } foreach (var kv in inputs) { var(input, param) = kv.Value; string inputName = kv.Key; string computeName = input.Name; bool itemAccess = input.AtLeast == 1 && input.AtMost == 1; var dataTree = new DataTree <Resthopper.IO.ResthopperObject>(); dataTree.ParamName = computeName; schema.Values.Add(dataTree); int inputListCount = 0; switch (param) { case Grasshopper.Kernel.Parameters.Param_Arc _: CollectDataHelper <Arc>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Boolean _: CollectDataHelper <bool>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Box _: CollectDataHelper <Box>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Brep _: CollectDataHelper <Brep>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Circle _: CollectDataHelper <Circle>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Colour _: CollectDataHelper <System.Drawing.Color>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Complex _: CollectDataHelper <Grasshopper.Kernel.Types.Complex>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Culture _: CollectDataHelper <System.Globalization.CultureInfo>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Curve _: CollectDataHelper <Curve>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Field _: CollectDataHelper <Grasshopper.Kernel.Types.GH_Field>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_FilePath _: CollectDataHelper <string>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_GenericObject _: throw new Exception("generic param not supported"); case Grasshopper.Kernel.Parameters.Param_Geometry _: CollectDataHelper <GeometryBase>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Group _: throw new Exception("group param not supported"); case Grasshopper.Kernel.Parameters.Param_Guid _: throw new Exception("guid param not supported"); case Grasshopper.Kernel.Parameters.Param_Integer _: CollectDataHelper <int>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Interval _: CollectDataHelper <Grasshopper.Kernel.Types.GH_Interval>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Interval2D _: CollectDataHelper <Grasshopper.Kernel.Types.GH_Interval2D>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_LatLonLocation _: throw new Exception("latlonlocation param not supported"); case Grasshopper.Kernel.Parameters.Param_Line _: CollectDataHelper <Line>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Matrix _: CollectDataHelper <Matrix>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Mesh _: CollectDataHelper <Mesh>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_MeshFace _: CollectDataHelper <MeshFace>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_MeshParameters _: throw new Exception("meshparameters param not supported"); case Grasshopper.Kernel.Parameters.Param_Number _: CollectDataHelper <double>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; //case Grasshopper.Kernel.Parameters.Param_OGLShader: case Grasshopper.Kernel.Parameters.Param_Plane _: CollectDataHelper <Plane>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Point _: CollectDataHelper <Point3d>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Rectangle _: CollectDataHelper <Rectangle3d>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; //case Grasshopper.Kernel.Parameters.Param_ScriptVariable _: case Grasshopper.Kernel.Parameters.Param_String _: CollectDataHelper <string>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_StructurePath _: CollectDataHelper <Grasshopper.Kernel.Types.GH_StructurePath>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Surface _: CollectDataHelper <Surface>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Time _: CollectDataHelper <DateTime>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Transform _: CollectDataHelper <Transform>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Vector _: CollectDataHelper <Vector3d>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Special.GH_NumberSlider _: CollectDataHelper <double>(DA, inputName, itemAccess, ref inputListCount, dataTree); break; } if (!itemAccess) { if (inputListCount < input.AtLeast) { warnings.Add($"{input.Name} requires at least {input.AtLeast} items"); } if (inputListCount > input.AtMost) { warnings.Add($"{input.Name} requires at most {input.AtMost} items"); } } } schema.Pointer = Path; if (PathIsAppServer) { string definition = Path.Substring(Path.LastIndexOf('/') + 1); schema.Pointer = definition; } return(schema); }
public Schema CreateSolveInput(IGH_DataAccess DA, bool cacheSolveOnServer, int recursionLevel, out List <string> warnings) { warnings = new List <string>(); var schema = new Resthopper.IO.Schema(); schema.RecursionLevel = recursionLevel; schema.CacheSolve = cacheSolveOnServer; var inputs = GetInputParams(); if (inputs != null) { foreach (var kv in inputs) { var(input, param) = kv.Value; string inputName = kv.Key; string computeName = input.Name; GH_ParamAccess access = AccessFromInput(input); var dataTree = new DataTree <Resthopper.IO.ResthopperObject>(); dataTree.ParamName = computeName; schema.Values.Add(dataTree); int inputListCount = 0; switch (param) { case Grasshopper.Kernel.Parameters.Param_Arc _: CollectDataHelper2 <Arc, GH_Arc>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Boolean _: CollectDataHelper2 <bool, GH_Boolean>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Box _: CollectDataHelper2 <Box, GH_Box>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Brep _: CollectDataHelper2 <Brep, GH_Brep>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Circle _: CollectDataHelper2 <Circle, GH_Circle>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Colour _: CollectDataHelper2 <System.Drawing.Color, GH_Colour>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Complex _: CollectDataHelper2 <Complex, GH_ComplexNumber>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Culture _: CollectDataHelper2 <System.Globalization.CultureInfo, GH_Culture>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Curve _: CollectDataHelper2 <Curve, GH_Curve>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Field _: CollectDataHelper <Grasshopper.Kernel.Types.GH_Field>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_FilePath _: CollectDataHelper2 <string, GH_String>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_GenericObject _: throw new Exception("generic param not supported"); case Grasshopper.Kernel.Parameters.Param_Geometry _: CollectDataHelper <IGH_GeometricGoo>(DA, inputName, access, ref inputListCount, dataTree, true); break; case Grasshopper.Kernel.Parameters.Param_Group _: throw new Exception("group param not supported"); case Grasshopper.Kernel.Parameters.Param_Guid _: CollectDataHelper2 <Guid, GH_Guid>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Integer _: CollectDataHelper2 <int, GH_Integer>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Interval _: CollectDataHelper2 <Interval, GH_Interval>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Interval2D _: CollectDataHelper2 <UVInterval, GH_Interval2D>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_LatLonLocation _: throw new Exception("latlonlocation param not supported"); case Grasshopper.Kernel.Parameters.Param_Line _: CollectDataHelper2 <Line, GH_Line>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Matrix _: CollectDataHelper2 <Matrix, GH_Matrix>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Mesh _: CollectDataHelper2 <Mesh, GH_Mesh>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_MeshFace _: CollectDataHelper2 <MeshFace, GH_MeshFace>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_MeshParameters _: CollectDataHelper2 <MeshingParameters, GH_MeshingParameters>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Number _: CollectDataHelper2 <double, GH_Number>(DA, inputName, access, ref inputListCount, dataTree); break; //case Grasshopper.Kernel.Parameters.Param_OGLShader: case Grasshopper.Kernel.Parameters.Param_Plane _: CollectDataHelper2 <Plane, GH_Plane>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Point _: // TODO: figure out how Point3d trees should be handled CollectDataHelper <Point3d>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Rectangle _: CollectDataHelper2 <Rectangle3d, GH_Rectangle>(DA, inputName, access, ref inputListCount, dataTree); break; //case Grasshopper.Kernel.Parameters.Param_ScriptVariable _: case Grasshopper.Kernel.Parameters.Param_String _: CollectDataHelper2 <string, GH_String>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_StructurePath _: CollectDataHelper2 <Grasshopper.Kernel.Data.GH_Path, GH_StructurePath>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_SubD _: CollectDataHelper2 <SubD, GH_SubD>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Surface _: CollectDataHelper <Surface>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Time _: CollectDataHelper2 <DateTime, GH_Time>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Transform _: CollectDataHelper2 <Transform, GH_Transform>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Parameters.Param_Vector _: CollectDataHelper2 <Vector3d, GH_Vector>(DA, inputName, access, ref inputListCount, dataTree); break; case Grasshopper.Kernel.Special.GH_NumberSlider _: CollectDataHelper2 <double, GH_Number>(DA, inputName, access, ref inputListCount, dataTree); break; } if (access == GH_ParamAccess.list) { if (inputListCount < input.AtLeast) { warnings.Add($"{input.Name} requires at least {input.AtLeast} items"); } if (inputListCount > input.AtMost) { warnings.Add($"{input.Name} requires at most {input.AtMost} items"); } } } } schema.Pointer = Path; var pathType = GetPathType(); if (pathType == PathType.Server) { string definition = Path.Substring(Path.LastIndexOf('/') + 1); schema.Pointer = definition; } return(schema); }