Skip to content

Commit

Permalink
added version number to Hello World message box
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Tammik committed Dec 20, 2016
1 parent a4ad4d1 commit 052f204
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 50 deletions.
6 changes: 4 additions & 2 deletions CS/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
// 2016-06-04 - 2017.0.0.4 - merged pull request #13 by awmcc90 to skip mepSys.Elements for OST_ElectricalInternalCircuits category
// 2016-06-23 - 2017.0.0.5 - merged pull request #14 by Shayneham to handle exceptions snooping flex pipe and duct lacking levels etc.
// 2016-08-05 - 2017.0.0.6 - merged pull request #16 by @arif-hanif to add post build event to project file to copy addin manifest and dll to addins folder
// 2016-12-20 - 2017.0.0.7 - merged pull request #18 by @Andrey-Bushman to use NuGet Revit API package
// 2016-12-20 - 2017.0.0.8 - added version number to Hello World message box
//
[assembly: AssemblyVersion( "2017.0.0.6" )]
[assembly: AssemblyFileVersion( "2017.0.0.6" )]
[assembly: AssemblyVersion( "2017.0.0.8" )]
[assembly: AssemblyFileVersion( "2017.0.0.8" )]
99 changes: 51 additions & 48 deletions CS/TestCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Autodesk.Revit.UI;
using RevitLookup.Test;
using Autodesk.Revit.Attributes;
using System.Reflection;

// Each command is implemented as a class that provides the IExternalCommand Interface
//
Expand All @@ -42,14 +43,16 @@ namespace RevitLookup
/// <summary>
/// The classic bare-bones test. Just brings up an Alert box to show that the connection to the external module is working.
/// </summary>
[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class HelloWorld : IExternalCommand
{
public Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
Assembly a = Assembly.GetExecutingAssembly();
string version = a.GetName().Version.ToString();
TaskDialog helloDlg = new TaskDialog( "Autodesk Revit" );
helloDlg.MainContent = "Hello World from " + System.Reflection.Assembly.GetExecutingAssembly().Location;
helloDlg.MainContent = "Hello World from " + a.Location + " v" + version;
helloDlg.Show();
return Result.Cancelled;
}
Expand All @@ -59,13 +62,13 @@ public Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string
/// SnoopDB command: Browse all Elements in the current Document
/// </summary>

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdSnoopDb : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
Autodesk.Revit.UI.Result result;
Result result;

try
{
Expand All @@ -91,12 +94,12 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
ActiveDoc.UIApp = cmdData.Application;
form.ShowDialog();

result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{
msg = e.Message;
result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

return result;
Expand All @@ -108,13 +111,13 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
/// SnoopDB command: Browse the current view...
/// </summary>

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdSnoopActiveView : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
Autodesk.Revit.UI.Result result;
Result result;

try
{
Expand All @@ -133,12 +136,12 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
Snoop.Forms.Objects form = new Snoop.Forms.Objects( doc.ActiveView );
form.ShowDialog();

result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{
msg = e.Message;
result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

return result;
Expand All @@ -150,13 +153,13 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
/// In case nothing is selected: browse visible elements
/// </summary>

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdSnoopModScope : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
Autodesk.Revit.UI.Result result;
Result result;

try
{
Expand All @@ -166,7 +169,7 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
Snoop.CollectorExts.CollectorExt.m_activeDoc = dbdoc; // TBD: see note in CollectorExt.cs
Autodesk.Revit.DB.View view = dbdoc.ActiveView;

//ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; // 2015, jeremy: 'Autodesk.Revit.UI.Selection.Selection.Elements' is obsolete: 'This property is deprecated in Revit 2015. Use GetElementIds() and SetElementIds instead.'
//ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; // 2015, jeremy: 'Selection.Selection.Elements' is obsolete: 'This property is deprecated in Revit 2015. Use GetElementIds() and SetElementIds instead.'
//if (ss.Size == 0)
//{
// FilteredElementCollector collector = new FilteredElementCollector( revitDoc.Document, view.Id );
Expand Down Expand Up @@ -199,12 +202,12 @@ FilteredElementCollector collector
ActiveDoc.UIApp = cmdData.Application;
form.ShowDialog();

result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{
msg = e.Message;
result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

return result;
Expand All @@ -215,13 +218,13 @@ FilteredElementCollector collector
/// Snoop App command: Browse all objects that are part of the Application object
/// </summary>

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdSnoopApp : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
Autodesk.Revit.UI.Result result;
Result result;

try
{
Expand All @@ -231,12 +234,12 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
Snoop.Forms.Objects form = new Snoop.Forms.Objects( cmdData.Application.Application );
form.ShowDialog();
ActiveDoc.UIApp = cmdData.Application;
result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{
msg = e.Message;
result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

return result;
Expand All @@ -249,20 +252,20 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
/// each test and occupy additional menu items. Create a Test by adding new RevitLookupTestFuncs objects.
/// </summary>

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdTestShell : IExternalCommand
{
ArrayList m_tests = new ArrayList();
Autodesk.Revit.UI.UIApplication m_app = null;
UIApplication m_app = null;

public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
m_app = cmdData.Application;

Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application;
Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document; // TBD: see note in CollectorExt.cs
Autodesk.Revit.UI.Result result;
Result result;

try
{
Expand All @@ -275,7 +278,7 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
if( form.ShowDialog() == DialogResult.OK )
form.DoTest();

result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{ // we want to catch it so we can see the problem, otherwise it just silently bails out
Expand All @@ -291,7 +294,7 @@ public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData c
MessageBox.Show( msg );


result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

finally
Expand Down Expand Up @@ -341,51 +344,51 @@ private void
/// Snoop ModScope command: Browse all Elements in the current selection set
/// </summary>

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdSampleMenuItemCallback : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
Autodesk.Revit.UI.Result result;
Result result;

try
{
MessageBox.Show( "Called back into RevitLookup by picking toolbar or menu item" );
result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{
msg = e.Message;
result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

return result;
}
}

[Autodesk.Revit.Attributes.Transaction( Autodesk.Revit.Attributes.TransactionMode.Manual )]
[Autodesk.Revit.Attributes.Regeneration( Autodesk.Revit.Attributes.RegenerationOption.Manual )]
[Transaction( TransactionMode.Manual )]
[Regeneration( RegenerationOption.Manual )]
public class CmdEvents : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
{
EventTrack.Events.ApplicationEvents.m_app = cmdData.Application.Application;
EventTrack.Events.DocEvents.m_docSet = cmdData.Application.Application.Documents;

Autodesk.Revit.UI.Result result;
Result result;

try
{
RevitLookup.EventTrack.Forms.EventsForm dbox = new RevitLookup.EventTrack.Forms.EventsForm();
dbox.ShowDialog();

result = Autodesk.Revit.UI.Result.Succeeded;
result = Result.Succeeded;
}
catch( System.Exception e )
{
msg = e.Message;
result = Autodesk.Revit.UI.Result.Failed;
result = Result.Failed;
}

return result;
Expand Down

0 comments on commit 052f204

Please sign in to comment.