Skip to content

Commit

Permalink
Wow, lots changed.
Browse files Browse the repository at this point in the history
Improvements of all sorts took place, and it would take me a long time
to cover everything. But the major changes were stability improvements.
It is very very hard to crash the exporter now, whereas before you could
simply close inventor during an operation and crash everything. Now, the
moment connection is lost to inventor, a message box will pop up asking
the user to either reopen the assembly or close the exporter before
anything continues. This makes the exporter and the field assembly
appear to be linked together, making it hard to mess things up. Another
stability improvement was made so that if an exception IS thrown (again,
very unlikely from my testing), a dialog window will appear asking the
user to send their steps prior to the error occurring to the BXD team,
along with the details provided in a text box.
  • Loading branch information
MackinnonBuck committed Aug 28, 2015
1 parent ecafb34 commit 426ab37
Show file tree
Hide file tree
Showing 27 changed files with 8,779 additions and 246 deletions.
154 changes: 81 additions & 73 deletions FieldExporter/FieldExporter/Components/ComponentPropertiesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class ComponentPropertiesForm : UserControl
private InteractionEvents interactionEvents;

/// <summary>
/// The events triggered by object selection in Inventor
/// The events triggered by object selection in Inventor.
/// </summary>
private SelectEvents selectEvents;

Expand All @@ -40,7 +40,7 @@ public bool interactionEnabled
}

/// <summary>
/// Initializes the component.
/// Initializes a new ComponentPropertiesForm instance.
/// </summary>
public ComponentPropertiesForm(ComponentPropertiesTabPage tabPage)
{
Expand Down Expand Up @@ -100,34 +100,40 @@ public double GetMass()
}

/// <summary>
/// Enables interaction events.
/// Enables interaction events with Inventor.
/// </summary>
private void EnableInteractionEvents()
{
try
if (Program.INVENTOR_APPLICATION.ActiveDocument == Program.ASSEMBLY_DOCUMENT)
{
interactionEvents = Program.INVENTOR_APPLICATION.CommandManager.CreateInteractionEvents();
interactionEvents.OnActivate += interactionEvents_OnActivate;
interactionEvents.Start();
try
{
interactionEvents = Program.INVENTOR_APPLICATION.CommandManager.CreateInteractionEvents();
interactionEvents.OnActivate += interactionEvents_OnActivate;
interactionEvents.Start();

inventorSelectButton.Text = "Cancel Selection";
inventorSelectButton.Text = "Cancel Selection";

interactionEnabled = true;
interactionEnabled = true;
}
catch
{
MessageBox.Show("Cannot enter select mode.", "Document not found.");
}
}
catch
else
{
MessageBox.Show("Cannot enter select mode.", "Document not found.");
MessageBox.Show("Can only enter select mode for " + Program.ASSEMBLY_DOCUMENT.DisplayName);
}
}

/// <summary>
/// Disables interaction events.
/// Disables interaction events with Inventor.
/// </summary>
private void DisableInteractionEvents()
{
interactionEvents.Stop();

Program.INVENTOR_APPLICATION.ActiveDocument.SelectSet.Clear();
Program.ASSEMBLY_DOCUMENT.SelectSet.Clear();

inventorSelectButton.Text = "Select in Inventor";
addSelectionButton.Enabled = false;
Expand All @@ -138,7 +144,7 @@ private void DisableInteractionEvents()
/// <summary>
/// Enables select events when interaction events are activated.
/// </summary>
void interactionEvents_OnActivate()
private void interactionEvents_OnActivate()
{
selectEvents = interactionEvents.SelectEvents;
selectEvents.AddSelectionFilter(SelectionFilterEnum.kAssemblyOccurrenceFilter);
Expand All @@ -153,7 +159,7 @@ void interactionEvents_OnActivate()
/// <param name="ModelPosition"></param>
/// <param name="ViewPosition"></param>
/// <param name="View"></param>
void selectEvents_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
private void selectEvents_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
{
if (!addSelectionButton.Enabled)
{
Expand Down Expand Up @@ -188,81 +194,83 @@ private void inventorSelectButton_Click(object sender, EventArgs e)
/// <param name="e"></param>
private void addSelectionButton_Click(object sender, EventArgs e)
{
Program.INVENTOR_APPLICATION.UserInterfaceManager.UserInteractionDisabled = true;
//Program.INVENTOR_APPLICATION.UserInterfaceManager.UserInteractionDisabled = true;
Program.LockInventor();

addSelectionButton.Enabled = false;
inventorSelectButton.Enabled = false;

Program.progressWindow = new ProgressWindow(this, "Adding Selection...", "Processing...",
Program.PROCESSWINDOW = new ProcessWindow(this, "Adding Selection...", "Processing...",
0, selectEvents.SelectedEntities.Count,
new Action(() =>
{
DialogResult permanentChoice = DialogResult.None;
for (int i = 0; i < selectEvents.SelectedEntities.Count; i++)
{
DialogResult permanentChoice = DialogResult.None;
if (Program.PROCESSWINDOW.currentState.Equals(ProcessWindow.ProcessState.CANCELLED))
return;
Program.PROCESSWINDOW.SetProgress(i, "Processing: " + (Math.Round((i / (float)selectEvents.SelectedEntities.Count) * 100.0f, 2)).ToString() + "%");
for (int i = 0; i < selectEvents.SelectedEntities.Count; i++)
if (parentTabPage.parentControl.NodeExists(selectEvents.SelectedEntities[i + 1].Name, parentTabPage))
{
if (Program.progressWindow.currentState.Equals(ProgressWindow.ProcessState.CANCELLED))
return;
Invoke(new Action(() =>
{
switch (permanentChoice)
{
case DialogResult.None:
ConfirmMoveDialog confirmDialog = new ConfirmMoveDialog(
selectEvents.SelectedEntities[i + 1].Name + " has already been added to another PhysicsGroup. Move " +
selectEvents.SelectedEntities[i + 1].Name + " to " + parentTabPage.Name + "?");
Program.progressWindow.SetProgress(i, "Processing: " + (Math.Round((i / (float)selectEvents.SelectedEntities.Count) * 100.0f, 2)).ToString() + "%");
DialogResult result = confirmDialog.ShowDialog(Program.PROCESSWINDOW);
if (parentTabPage.parentControl.NodeExists(selectEvents.SelectedEntities[i + 1].Name, parentTabPage))
{
Invoke(new Action(() =>
{
switch (permanentChoice)
if (result == DialogResult.OK)
{
parentTabPage.parentControl.RemoveNode(selectEvents.SelectedEntities[i + 1].Name, parentTabPage);
inventorTreeView.Invoke(new Action(() =>
{
inventorTreeView.AddComponent(selectEvents.SelectedEntities[i + 1]);
}));
}
if (confirmDialog.IsChecked())
{
case DialogResult.None:
ConfirmMoveDialog confirmDialog = new ConfirmMoveDialog(
selectEvents.SelectedEntities[i + 1].Name + " has already been added to another PhysicsGroup. Move " +
selectEvents.SelectedEntities[i + 1].Name + " to " + parentTabPage.Name + "?");
DialogResult result = confirmDialog.ShowDialog(Program.progressWindow);
if (result == DialogResult.OK)
{
parentTabPage.parentControl.RemoveNode(selectEvents.SelectedEntities[i + 1].Name, parentTabPage);
inventorTreeView.Invoke(new Action(() =>
{
inventorTreeView.AddComponent(selectEvents.SelectedEntities[i + 1]);
}));
}
if (confirmDialog.futureCheckBox.Checked)
{
permanentChoice = result;
}
break;
case DialogResult.OK:
parentTabPage.parentControl.RemoveNode(selectEvents.SelectedEntities[i + 1].Name, parentTabPage);
inventorTreeView.Invoke(new Action(() =>
{
inventorTreeView.AddComponent(selectEvents.SelectedEntities[i + 1]);
}));
break;
permanentChoice = result;
}
}));
}
else
break;
case DialogResult.OK:
parentTabPage.parentControl.RemoveNode(selectEvents.SelectedEntities[i + 1].Name, parentTabPage);
inventorTreeView.Invoke(new Action(() =>
{
inventorTreeView.AddComponent(selectEvents.SelectedEntities[i + 1]);
}));
break;
}
}));
}
else
{
inventorTreeView.Invoke(new Action(() =>
{
inventorTreeView.Invoke(new Action(() =>
{
inventorTreeView.AddComponent(selectEvents.SelectedEntities[i + 1]);
}));
}
inventorTreeView.AddComponent(selectEvents.SelectedEntities[i + 1]);
}));
}
}),
}
}),
new Action(() =>
{
Program.INVENTOR_APPLICATION.UserInterfaceManager.UserInteractionDisabled = false;
{
Program.UnlockInventor();
//Program.INVENTOR_APPLICATION.UserInterfaceManager.UserInteractionDisabled = false;
DisableInteractionEvents();
inventorSelectButton.Enabled = true;
}));
DisableInteractionEvents();
inventorSelectButton.Enabled = true;
}));

Program.progressWindow.StartProcess();
Program.PROCESSWINDOW.StartProcess();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public PhysicsGroupsTabControl parentControl
}

/// <summary>
/// The child ComponentPropertiesForm
/// The child ComponentPropertiesForm.
/// </summary>
public ComponentPropertiesForm childForm
{
Expand All @@ -35,7 +35,7 @@ public ComponentPropertiesForm childForm
/// <summary>
/// Right-click menu options.
/// </summary>
ContextMenu rightClickMenu;
private ContextMenu rightClickMenu;

/// <summary>
/// Initalizes the component with a specified parent and name.
Expand Down Expand Up @@ -67,6 +67,9 @@ public void SetName(string name)
Text = Name = name;
}

/// <summary>
/// Changes the name of the ComponentPropertiesTabPage if the name is not already taken.
/// </summary>
public void ChangeName()
{
EnterNameDialog nameDialog = new EnterNameDialog();
Expand Down Expand Up @@ -96,15 +99,15 @@ public void ShowRightClickMenu(MouseEventArgs e)
}

/// <summary>
/// Removes this component.
/// Removes this component from its parent control.
/// </summary>
public void Remove()
{
parentControl.TabPages.Remove(this);
}

/// <summary>
/// Removes this control when the delete menu item is selected.
/// Removes this control when the "Delete" right-click option is selected.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand All @@ -113,6 +116,11 @@ private void deleteMenuItem_onClick(object sender, EventArgs e)
Remove();
}

/// <summary>
/// Changes the name when the "Change Name" right-click option is clicked.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void changeNameMenuItem_onClick(object sender, EventArgs e)
{
ChangeName();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions FieldExporter/FieldExporter/Components/CreatePhysicsGroupForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ namespace FieldExporter.Components
{
public partial class CreatePhysicsGroupForm : UserControl
{
/// <summary>
/// The parent CreatePhysicsGroupTabPage.
/// </summary>
private CreatePhysicsGroupTabPage parentTabPage;

/// <summary>
/// Initializes a new instance of the CreatePhysicsGroupForm class.
/// </summary>
/// <param name="tabPage"></param>
public CreatePhysicsGroupForm(CreatePhysicsGroupTabPage tabPage)
{
InitializeComponent();
Expand All @@ -24,6 +31,11 @@ public CreatePhysicsGroupForm(CreatePhysicsGroupTabPage tabPage)
parentTabPage = tabPage;
}

/// <summary>
/// Adds a ComponentPropertiesTabPage when the "Create" button is clicked.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void newPhysicsButton_Click(object sender, EventArgs e)
{
parentTabPage.parentTabControl.AddComponentPropertiesTab();
Expand Down
Loading

0 comments on commit 426ab37

Please sign in to comment.