public override bool Execute() { // Get the reference nodes to see if Cut was applied or it is the first time var cutShapes = Dependency[3].ReferenceList; if (cutShapes == null) { return(false); } var rootNode = Parent.Root; // Get the Cut dependencies (cutting shape, cut depth and cut type) var cuttingShape = Dependency[0].ReferedShape; var sketchNode = Dependency[0].ReferenceBuilder.Node; var faces = AutoGroupLogic.BuildAutoFaces(sketchNode, rootNode.Get <DocumentContextInterpreter>().Document); var depth = Dependency[1].Real; var cutType = (CutTypes)Dependency[2].Integer; cuttingShape = faces.First(); // firstFace.Shape; // Test the cutting shape if (cuttingShape == null || cuttingShape.IsNull) { return(false); } var dir = GeomUtils.ExtractDirection(cuttingShape) ?? sketchNode.Children[1].Get <Axis3DInterpreter>().Axis.GpAxis.Direction; // Build a list with the cutting prisms used to Cut the objects var cuttingPrisms = new List <TopoDSShape>(); var depthM = cutType == CutTypes.ToDepth ? depth : 7000; if (Math.Abs(depthM) < Precision.Confusion) { depthM = 0.1; } foreach (var face in faces) { TopoDSShape cutPrismShape = null; var translationVector = new gpVec(dir); translationVector.Multiply(-1 * depthM / 2); var transformation = new gpTrsf(); transformation.SetTranslation(translationVector); var brepTrans = new BRepBuilderAPITransform(face, transformation, false); var translatedShape = brepTrans.Shape; var translatedFace = translatedShape; // Describe the height through a vector var vector = new gpVec(dir); vector.Multiply(depthM); // Make the prism cutPrismShape = new BRepPrimAPIMakePrism(translatedFace, vector, false, true).Shape; cuttingPrisms.Add(cutPrismShape); } if (cuttingPrisms.Count == 0) { return(false); } var document = rootNode.Get <DocumentContextInterpreter>().Document; var shapeList = new List <int>(); if (Dependency[3].ReferenceList.Count > 0) { shapeList.AddRange(Dependency[3].ReferenceList.Select(sse => sse.Node.Index)); } else { shapeList.AddRange(NodeUtils.GetDocumentSolids(document)); shapeList.Remove(Parent.Index); } TopoDSShape resShape = null; foreach (var cuttingPrism in cuttingPrisms) { // If the Cut is executed first time if (cutShapes.Count <= 0 || resShape == null) { // Put back the shapes // Cut them again var cutModifiedNodes = new List <SceneSelectedEntity>(); resShape = CutThroughAll(rootNode, cuttingPrism, cutModifiedNodes, shapeList); Dependency[3].ReferenceList = cutModifiedNodes; cutShapes = Dependency[3].ReferenceList; } else { // Execute Cut on the shapes from ReferenceList resShape = CutThroughShape(resShape, cuttingPrism); } } if (resShape == null) { return(false); } // Show the new Cut shape Shape = resShape; return(true); }