private void TerminateCommand() { _InteractionManager.Terminate(); if (_frm != null) { _frm.Dispose(); _frm = null; } }
////////////////////////////////////////////////////////////////////////////////////////////// // OnMouseDown event we create the client feature that holds the dimension graphics // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseDown( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (Button != MouseButtonEnum.kLeftMouseButton) { return; } Vector normal = View.Camera.Eye.VectorTo(View.Camera.Target); CreateClientFeature( _dimData.Point1, _dimData.Point2, ModelPosition, normal); _interactionManager.Terminate(); }
///////////////////////////////////////////////////////////// // Use: Ok Button clicked Handler // ///////////////////////////////////////////////////////////// private void bOk_Click(object sender, EventArgs e) { bool silentOp = _Application.SilentOperation; _Application.SilentOperation = true; PartDocument template = _Application.Documents.Open( _ThreadTemplatePath, false) as PartDocument; _Application.SilentOperation = silentOp; if (!ValidateTemplateParameters(template)) { DialogResult res = MessageBox.Show( "Missing sketch parameter in template file!", "Invalid Template", MessageBoxButtons.OK, MessageBoxIcon.Error); bOk.Enabled = false; _ThreadTemplatePath = string.Empty; tbTemplate.Text = string.Empty; if (template != _Application.ActiveDocument) { template.Close(true); } return; } List <ThreadFeature> threads = new List <ThreadFeature>(); foreach (System.Object selectedObj in _InteractionManager.SelectedEntities) { ThreadFeature thread = selectedObj as ThreadFeature; if (thread.Suppressed) { continue; } threads.Add(thread); } PlanarSketch templateSketch = template.ComponentDefinition.Sketches[1]; if (!ThreadWorker.ModelizeThreads( _Document, templateSketch, threads, _extraPitch)) { DialogResult res = MessageBox.Show( "Failed to create CoilFeature... " + "Try with a bigger Pitch Offset value", "Modelization Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); switch (res) { case DialogResult.OK: //template.Close(true); return; default: break; } } // Problem: closing the template doc here // will empty the undo stack (as designed)... //template.Close(true); if (!_cleaned) { CleanUp(); } _InteractionManager.Terminate(); }