void ExecuteStartTool()
 {
     if (IsToolActive)
     {
         var tool = WorkspaceController.CurrentTool as EdgeModifierTool;
         tool?.Stop();
     }
     else
     {
         WorkspaceController.StartTool(new EdgeModifierTool(Fillet));
     }
 }
 void ExecuteStartTool()
 {
     if (IsToolActive)
     {
         var tool = WorkspaceController.CurrentTool as SketchEditorTool;
         tool?.Stop();
     }
     else
     {
         WorkspaceController.StartTool(new SketchEditorTool(Sketch));
     }
 }
Exemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        void CreateSketch()
        {
            var sketch = new Sketch();
            var body   = Body.Create(sketch);

            body.Position = _Plane.Location;
            body.Rotation = _Plane.Rotation();
            InteractiveContext.Current.Document.AddChild(body);
            InteractiveContext.Current.UndoHandler.Commit();

            InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(body);
            WorkspaceController.StartTool(new SketchEditorTool(sketch));
        }
 void ExecuteReselectFace()
 {
     if (IsToolActive)
     {
         var tool = WorkspaceController.CurrentTool as CreateLoftTool;
         tool?.Stop();
     }
     else
     {
         if (WorkspaceController.StartTool(new CreateLoftTool()))
         {
             IsToolActive = true;
         }
     }
 }
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            bool finished     = false;
            var  selectAction = toolAction as SelectSubshapeAction;

            Debug.Assert(selectAction != null);

            if (selectAction.SelectedSubshapeType == SubshapeTypes.Face)
            {
                var face        = TopoDS.Face(selectAction.SelectedSubshape);
                var brepAdaptor = new BRepAdaptor_Surface(face, true);
                if (brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Plane)
                {
                    StatusText = "Selected face is not a plane type surface.";
                }
                else
                {
                    selectAction.Stop();
                    Stop();
                    finished = true;
                    var faceRef = _TargetShape.GetSubshapeReference(_TargetBrep, face);
                    if (faceRef == null)
                    {
                        Messages.Error("A subshape reference could not be produced for this face.");
                        return;
                    }

                    if (_Mode == ToolMode.CreateNew)
                    {
                        // Create new
                        var sketch = new Sketch
                        {
                            Body = _TargetBody,
                        };

                        var imprint = Imprint.Create(_TargetBody, faceRef, sketch);
                        if (imprint != null)
                        {
                            imprint.Mode = _ImprintMode;
                            InteractiveContext.Current.UndoHandler.Commit();
                            InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody);
                            WorkspaceController.StartTool(new SketchEditorTool(sketch));
                        }
                    }
                    else if (_Mode == ToolMode.ReselectFace)
                    {
                        // Reselected face
                        _ImprintToChange.Face = faceRef;
                        _ImprintToChange.Invalidate();
                        InteractiveContext.Current.UndoHandler.Commit();
                    }
                }
            }

            if (!finished)
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }