예제 #1
0
        private void PlayButton_Click(object sender, EventArgs e)
        {
            if (!CheckState())
            {
                return;
            }

            if (GRBLMachinePlugin.Props.ToolChangeProcess == IgnoreProcessPassOn.Process)
            {
                string post = CamBamUI.MainUI.ActiveView.CADFile.MachiningOptions.PostProcessor;

                if (!string.IsNullOrEmpty(post) && post != "GRBLMachine")
                {
                    switch (MessageBox.Show("The Post Processor in Machining Options is not 'GRBLMachine'.\r\n\r\nSet Post Processor to 'GRBLMachine' and regenerate GCODE ?", "GRBLMachine - Play", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                    {
                    case DialogResult.Yes:
                        CamBamUI.MainUI.ActiveView.CADFile.MachiningOptions.PostProcessor = "GRBLMachine";
                        CAMUtils.GenerateGCodeOutput(CamBamUI.MainUI.ActiveView);
                        break;

                    case DialogResult.Cancel:
                        return;

                    case DialogResult.No:
                        break;
                    }
                }
            }

            if (GRBLMachinePlugin.Props.TrackMachine == EnabledDisabled.Enabled)
            {
                CamBamUI ui = CamBamUI.MainUI;

                // turn toolpaths et al on
                ui.ActiveView.CADFile.ShowToolpaths       = true;
                ui.ActiveView.CADFile.ShowRapids          = true;
                ui.ActiveView.CADFile.ShowDirectionVector = true;
                ui.ViewContextMenus.RefreshCheckedMenus();

                // runs in background, so just start it, we'll do something else in the meanwhile
                CAMUtils.GenerateToolpaths(ui.ActiveView);

                // fit current drawing and current perspective to fit view
                ui.ActiveView.ZoomToFitEx();

                // setup ISO-like perspective ( inspired from ViewToolbarAddins (y) )
                ViewProjection vp = ui.ActiveView.ViewProjection;
                Matrix4x4F     mx = Matrix4x4F.Identity;

                mx.Scale(vp.ViewMatrix4x4F.GetScale());
                mx.RotZ(-Math.PI / 4f);                 // 90 degrees
                mx.RotX(-Math.PI / (4f * (60f / 90f))); // 60 degrees
                mx.Translate(vp.ViewMatrix4x4F.m[12], vp.ViewMatrix4x4F.m[13], vp.ViewMatrix4x4F.m[14]);

                vp.ViewMatrix4x4F = mx;

                // re-zoom, since drawing may now be outside the view
                ui.ActiveView.ZoomToFitEx();

                // wait until GenerateToolpaths is ready
                while (ui.ActiveView.IsThinking)
                {
                    Application.DoEvents();
                }

                // re-zoom, since toolpaths may be outside the view
                ui.ActiveView.ZoomToFitEx();
            }

            _sendingFileName          = FileName.Text;
            _writeThread              = new Thread(WriteThread);
            _writeThread.Name         = "GCODE-SenderThread";
            _writeThread.IsBackground = true;

            PauseButton.Checked = false;

            EnableButtons();

            FileName.Enabled     = false;
            BrowseButton.Enabled = false;
            LinesSent.Text       = LinesTotal.Text = "-";

            _pauseEvent.Set();
            _fileData.Clear();

            _writeThread.Start();
        }
예제 #2
0
 /// <summary>
 /// 设置加工体
 /// </summary>
 protected void SetWorkpiece()
 {
     CAMUtils.SetFeatureGeometry("WORKPIECE", ele.PartTag.Bodies.ToArray());
 }
예제 #3
0
 /// <summary>
 /// 设置加工体
 /// </summary>
 private void SetWorkpiece()
 {
     CAMUtils.SetFeatureGeometry("WORKPIECE", this.pt.Bodies.ToArray());
 }