public override void Flatten(UndoBuffer undoBuffer) { // change this from a text object to a group var newContainer = new GroupObject3D(); newContainer.CopyProperties(this, Object3DPropertyFlags.All); foreach (var child in this.Children) { newContainer.Children.Add(child.Clone()); } undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, new[] { newContainer })); }
public override void Flatten(UndoBuffer undoBuffer) { // we want to end up with just a group of all the visible mesh objects using (RebuildLock()) { var newChildren = new List <IObject3D>(); // push our matrix into a copy of our visible children foreach (var child in this.VisibleMeshes()) { var meshOnlyItem = new Object3D { Matrix = child.WorldMatrix(this), Color = child.WorldColor(this), MaterialIndex = child.WorldMaterialIndex(this), OutputType = child.WorldOutputType(this), Mesh = child.Mesh, Name = "Mesh".Localize() }; newChildren.Add(meshOnlyItem); } if (newChildren.Count > 1) { var group = new GroupObject3D { Name = this.Name }; group.Children.Modify(list => { list.AddRange(newChildren); }); newChildren.Clear(); newChildren.Add(group); } else if (newChildren.Count == 1) { newChildren[0].Name = this.Name; } // and replace us with the children undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, newChildren)); } Invalidate(InvalidateType.Children); }
public override void Flatten(UndoBuffer undoBuffer) { // change this from a text object to a group var newContainer = new GroupObject3D(); newContainer.CopyProperties(this, Object3DPropertyFlags.All); int index = 0; foreach (var child in this.Children) { var clone = child.Clone(); var newName = index < NameToWrite.Length ? NameToWrite[index++].ToString() : "Letter".Localize(); clone.Name = MapIfSymbol(newName); newContainer.Children.Add(clone); } undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, new[] { newContainer })); newContainer.Name = this.Name + " - " + "Flattened".Localize(); }