Combine can subtract holes
This commit is contained in:
parent
cf5931d272
commit
9839215603
5 changed files with 43 additions and 31 deletions
|
|
@ -1073,37 +1073,12 @@ namespace MatterHackers.MatterControl
|
|||
return new SceneOperation("Group")
|
||||
{
|
||||
OperationType = typeof(SelectionGroupObject3D),
|
||||
ResultType = typeof(GroupObject3D),
|
||||
ResultType = typeof(GroupHolesAppliedObject3D),
|
||||
TitleGetter = () => "Group".Localize(),
|
||||
Action = (sceneContext) =>
|
||||
{
|
||||
var scene = sceneContext.Scene;
|
||||
var selectedItem = scene.SelectedItem;
|
||||
scene.SelectedItem = null;
|
||||
|
||||
var newGroup = new GroupObject3D();
|
||||
// When grouping items, move them to be centered on their bounding box
|
||||
newGroup.Children.Modify((gChildren) =>
|
||||
{
|
||||
selectedItem.Clone().Children.Modify((sChildren) =>
|
||||
{
|
||||
var center = selectedItem.GetAxisAlignedBoundingBox().Center;
|
||||
|
||||
foreach (var child in sChildren)
|
||||
{
|
||||
child.Translate(-center.X, -center.Y, 0);
|
||||
gChildren.Add(child);
|
||||
}
|
||||
|
||||
newGroup.Translate(center.X, center.Y, 0);
|
||||
});
|
||||
});
|
||||
|
||||
scene.UndoBuffer.AddAndDo(new ReplaceCommand(selectedItem.Children.ToList(), new[] { newGroup }));
|
||||
|
||||
newGroup.MakeNameNonColliding();
|
||||
|
||||
scene.SelectedItem = newGroup;
|
||||
var group = new GroupHolesAppliedObject3D();
|
||||
group.WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||
},
|
||||
HelpTextGetter = () => "At least 2 parts must be selected".Localize().Stars(),
|
||||
IsEnabled = (sceneContext) => sceneContext.Scene is InteractiveScene scene
|
||||
|
|
@ -1534,6 +1509,7 @@ namespace MatterHackers.MatterControl
|
|||
if (selectedItem != null)
|
||||
{
|
||||
return selectedItem is GroupObject3D
|
||||
|| selectedItem is GroupHolesAppliedObject3D
|
||||
|| selectedItem.GetType() == typeof(Object3D)
|
||||
|| selectedItem.CanApply;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,10 +29,14 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow.View3D;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class GroupObject3D : Object3D
|
||||
public class GroupObject3D : Object3D
|
||||
{
|
||||
public override bool CanApply => true;
|
||||
|
||||
|
|
@ -41,4 +45,33 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
Name = "Group".Localize();
|
||||
}
|
||||
}
|
||||
|
||||
[ShowUpdateButton(Show = false)]
|
||||
public class GroupHolesAppliedObject3D : SubtractObject3D_2
|
||||
{
|
||||
public GroupHolesAppliedObject3D()
|
||||
{
|
||||
Name = "Group".Localize();
|
||||
}
|
||||
|
||||
public override SelectedChildren SelectedChildren
|
||||
{
|
||||
get
|
||||
{
|
||||
var selections = new SelectedChildren();
|
||||
|
||||
foreach(var child in SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf().Children.Where(i => i.WorldOutputType(this) == PrintOutputTypes.Hole))
|
||||
{
|
||||
selections.Add(child.ID);
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
if (newChildren.Count > 1)
|
||||
{
|
||||
var group = new GroupObject3D
|
||||
var group = new GroupHolesAppliedObject3D
|
||||
{
|
||||
Name = this.Name
|
||||
};
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
}
|
||||
|
||||
[DisplayName("Part(s) to Subtract")]
|
||||
public SelectedChildren SelectedChildren { get; set; } = new SelectedChildren();
|
||||
public virtual SelectedChildren SelectedChildren { get; set; } = new SelectedChildren();
|
||||
|
||||
#if DEBUG
|
||||
public ProcessingModes Processing { get; set; } = ProcessingModes.Polygons;
|
||||
|
|
|
|||
|
|
@ -4339,6 +4339,9 @@ Translated:Select this option only if your printer does not appear in the list
|
|||
English:Select What to Import
|
||||
Translated:Select What to Import
|
||||
|
||||
English:Selected Children
|
||||
Translated:Selected Children
|
||||
|
||||
English:Selected Material and Bed Surface are Incompatable
|
||||
Translated:Selected Material and Bed Surface are Incompatable
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue