/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Point3d eye = new Point3d(); Point3d target = new Point3d(); string name = ""; //get user inputs //user should be able to create a scene contianing only lines, or only meshes, or both. All geo and material inputs will be optional, and we'll run some defense. if (!DA.GetData(0, ref eye)) return; if (!DA.GetData(1, ref target)) return; if (!DA.GetData(2, ref name)) return; try { //create json from lists of json: string outJSON = pointJSON(eye, target,name); outJSON = outJSON.Replace("OOO", "object"); Element e = new Element(outJSON, va3cElementType.Camera); DA.SetData(0, e); } catch (Exception) { return; } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { //local varaibles GH_Mesh mesh = null; List<GH_Colour> colors = new List<GH_Colour>(); List<GH_String> attributeNames = new List<GH_String>(); List<GH_String> attributeValues = new List<GH_String>(); Dictionary<string, object> attributesDict = new Dictionary<string, object>(); Layer layer = null; string layerName = "Default"; //catch inputs and populate local variables if (!DA.GetData(0, ref mesh)) { return; } if (mesh == null) { return; } if (!DA.GetDataList(1, colors)) { return; } DA.GetDataList(2, attributeNames); DA.GetDataList(3, attributeValues); if (attributeValues.Count != attributeNames.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please provide equal numbers of attribute names and values."); return; } DA.GetData(4, ref layerName); layer = new Layer(layerName); //populate dictionary int i = 0; foreach (var a in attributeNames) { attributesDict.Add(a.Value, attributeValues[i].Value); i++; } //add the layer name to the attributes dictionary attributesDict.Add("layer", layerName); //create MeshFaceMaterial and assign mesh face material indexes in the attributes dict string meshMaterailJSON = makeMeshFaceMaterialJSON(mesh.Value, attributesDict, colors); //create json from mesh string meshJSON = _Utilities.geoJSON(mesh.Value, attributesDict); Material material = new Material(meshMaterailJSON, va3cMaterialType.Mesh); Element e = new Element(meshJSON, va3cElementType.Mesh, material, layer); DA.SetData(0, e); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { //local varaibles GH_Mesh mesh = null; List<GH_String> attributeNames = new List<GH_String>(); List<GH_String> attributeValues = new List<GH_String>(); Dictionary<string, object> attributesDict = new Dictionary<string, object>(); Material material = null; string layerName = "Default"; //catch inputs and populate local variables if (!DA.GetData(0, ref mesh)) { return; } if (mesh == null) { return; } //Make sure the material is of mType Mesh if (!DA.GetData(1, ref material)) { return; } if (material == null) { return; } if (material.Type != va3cMaterialType.Mesh) { throw new Exception("Please use a MESH Material"); } DA.GetDataList(2, attributeNames); DA.GetDataList(3, attributeValues); if (attributeValues.Count != attributeNames.Count) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please provide equal numbers of attribute names and values."); return; } Layer layer = null; DA.GetData(4, ref layerName); layer = new Layer(layerName); //populate dictionary int i = 0; foreach (var a in attributeNames) { attributesDict.Add(a.Value, attributeValues[i].Value); i++; } //add the layer name to the attributes dictionary attributesDict.Add("layer", layerName); //create json from mesh string outJSON = _Utilities.geoJSON(mesh.Value, attributesDict); Element e = new Element(outJSON, va3cElementType.Mesh, material, layer); DA.SetData(0, e); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { //local variables GH_Line line = null; Material material = null; Layer layer = null; string layerName = "Default"; //catch inputs and populate local variables if (!DA.GetData(0, ref line)) { return; } if (!DA.GetData(1, ref material)) { return; } if (material.Type != va3cMaterialType.Line) { throw new Exception("Please use a LINE Material"); } DA.GetData(2, ref layerName); layer = new Layer(layerName); //create JSON from line string outJSON = lineJSON(line.Value); Element e = new Element(outJSON, va3cElementType.Line, material, layer); //output results DA.SetData(0, e); }