Exemple #1
0
        private List <string> GetTags(ModelComponent InModelComponent)
        {
            List <string> NodeTags = new List <string>();

            NodeTags.Add(string.Format("Rhino.ID: {0}", InModelComponent.Id));

            string ComponentTypeString = FUniqueNameGenerator.GetDefaultTypeName(InModelComponent);

            NodeTags.Add(string.Format("Rhino.Entity.Type: {0}", ComponentTypeString));

            //Add the groups this object belongs to.
            RhinoObject InRhinoObject = InModelComponent as RhinoObject;

            if (InRhinoObject != null && InRhinoObject.GroupCount > 0)
            {
                int[] GroupIndices = InRhinoObject.GetGroupList();
                for (int GroupArrayIndex = 0; GroupArrayIndex < GroupIndices.Length; ++GroupArrayIndex)
                {
                    string GroupName = GroupNameList[GroupIndices[GroupArrayIndex]];
                    if (GroupName != null)
                    {
                        NodeTags.Add(GroupName);
                    }
                }
            }

            return(NodeTags);
        }
Exemple #2
0
        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();
        }