public static void DecomposeObj(RhinoDoc doc, Layer layer, RhinoObject obj, Brep brep, ref int progressCurrentIndex, ref int progressShowedPercent, int progressMax, bool beforeFixAllIssues, int objsInLayerCount = -1) { //if (objsInLayerCount == -1) //{ // objsInLayerCount = layer._GetObjsCount(doc, false, ObjectType.Brep); //} var newLayerIndex = GetNewLayer(doc, layer, obj, beforeFixAllIssues); int index = 0; int nameLength = 1; if (brep.Faces.Count >= 10) { nameLength = 2; } if (brep.Faces.Count >= 100) { nameLength = 3; } if (brep.Faces.Count >= 1000) { nameLength = 4; } if (brep.Faces.Count >= 10000) { nameLength = 5; } foreach (BrepFace face in brep.Faces_ThreadSafe()) { index++; // Duplicate brep var face_copy = face.DuplicateFace(true); var id = doc.Objects.AddBrep(face_copy, new ObjectAttributes() { LayerIndex = newLayerIndex, Visible = true, Name = index.ToString("D" + nameLength), }); // Add to group if (id != Guid.Empty && obj.GroupCount > 0) { foreach (var groupId in obj.GetGroupList()) { doc.Groups.AddToGroup(groupId, id); } } // Show progress progressCurrentIndex++; var progressCurrentPercent = 100 - ((progressMax - progressCurrentIndex) * 100 / progressMax); if (progressCurrentPercent - progressShowedPercent >= 1) { progressShowedPercent = progressCurrentPercent; log.rawText(g.SolidNavigator, "."); } } obj._Delete(); }