protected override void SolveInstance(IGH_DataAccess DA) { List <Object> objects = new List <Object>(); List <string> layers = new List <string>(); bool bake = false; if (!DA.GetDataList(0, objects)) { return; } if (!DA.GetDataList(1, layers)) { return; } if (!DA.GetData(2, ref bake)) { return; } // Specify the active Rhino document. RhinoDoc doc = RhinoDoc.ActiveDoc; List <Guid> ids = new List <Guid>(); // Debugging list List <int> debug = new List <int>(); if (bake) { for (int i = 0; i < objects.Count; i++) { int layerIndex = -1; if (layers.Count != objects.Count) { i = 0; } Layer layer = doc.Layers.FindName(layers[i]); if (layer == null) { this.Message = "Creating Layer"; Layer newLayer = new Layer(); newLayer.Name = layers[i]; // Add a new layer to the document layerIndex = doc.Layers.Add(newLayer); } else { layerIndex = layer.Index; } GH_ObjectWrapper obj = new GH_ObjectWrapper(objects[i]); ObjectAttributes oAtt = new ObjectAttributes(); oAtt.LayerIndex = layerIndex; int tag = obj.GetHashCode(); debug.Add(tag); Guid id = new Guid(); if (overwrite) { /* * if (debug. * { * * } */ } else { obj.BakeGeometry(doc, oAtt, ref id); } ids.Add(id); } } this.Message = "Completed"; DA.SetDataList(0, ids); DA.SetDataList(1, debug); }