Skip to content

Commit

Permalink
cleaned up after ana
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Tammik committed Apr 13, 2015
1 parent 1ac3eb3 commit ec74ce6
Showing 1 changed file with 67 additions and 68 deletions.
135 changes: 67 additions & 68 deletions RvtVa3c/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public class Command : IExternalCommand
/// Export a given 3D view to JSON using
/// our custom exporter context.
/// </summary>
public void ExportView3D( View3D view3d, string filename )
public void ExportView3D(
View3D view3d,
string filename )
{
AppDomain.CurrentDomain.AssemblyResolve
+= CurrentDomain_AssemblyResolve;
Expand All @@ -81,11 +83,9 @@ Va3cExportContext context

#region UI to Filter Parameters
public static ParameterFilter _filter;
public static bool _filterParameters = false;
public static TabControl _tabControl;
public static Dictionary<string, List<string>> _parameterDictionary;
public static Dictionary<string, List<string>> _toExportDictionary;
public static bool includeT = false;

/// <summary>
/// Function to filter the parameters of the objects in the scene
Expand Down Expand Up @@ -311,89 +311,88 @@ public Result Execute(
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Autodesk.Revit.ApplicationServices.Application app
= uiapp.Application;
Document doc = uidoc.Document;

if( doc.ActiveView is View3D )
{
string filename = doc.PathName;
if( 0 == filename.Length )
{
filename = doc.Title;
}
if( null == _output_folder_path )
{
// Sometimes the command fails if the file is
// detached from central and not saved locally

try
{
_output_folder_path = Path.GetDirectoryName(
filename );
}
catch
{
TaskDialog.Show( "Folder not found",
"Please save the file and run the command again." );
return Result.Failed;
}
}
// Check that we are in a 3D view.

// Dialog to ask the user if they want to
// choose which parameters to export or just
// export them all.
View3D view = doc.ActiveView as View3D;

TaskDialog td = new TaskDialog( "Ask user to filter parameters" );
td.Title = "Filter parameters";
td.CommonButtons = TaskDialogCommonButtons.No | TaskDialogCommonButtons.Yes;
td.MainInstruction = "Do you want to filter the parameters of the objects to be exported?";
td.MainContent = "Click Yes and you will be able to select parameters for each category in the next window";
td.AllowCancellation = true;
td.VerificationText = "Check this to include type properties";
TaskDialogResult tdResult = td.Show();

if( td.WasVerificationChecked() ) includeT = true;
else includeT = false;
if( null == view )
{
Util.ErrorMsg(
"You must be in a 3D view to export." );

if( tdResult == TaskDialogResult.Yes )
{
// Filter the properties
filterElementParameters( doc, includeT );
_filterParameters = true;
if( ParameterFilter.status == "cancelled" )
{
ParameterFilter.status = "";
return Result.Cancelled;
}
}
else _filterParameters = false;
return Result.Failed;
}

// Prompt for output filename selection.

ViewOrientation3D vo = ( (View3D) doc.ActiveView ).GetOrientation();
string filename = doc.PathName;

// Save file
if( 0 == filename.Length )
{
filename = doc.Title;
}

filename = Path.GetFileName( filename ) + ".js";
if( null == _output_folder_path )
{
// Sometimes the command fails if the file is
// detached from central and not saved locally

if( SelectFile( ref _output_folder_path,
ref filename ) )
try
{
filename = Path.Combine( _output_folder_path,
_output_folder_path = Path.GetDirectoryName(
filename );
}
catch
{
TaskDialog.Show( "Folder not found",
"Please save the file and run the command again." );
return Result.Failed;
}
}

ExportView3D( doc.ActiveView as View3D,
filename );
filename = Path.GetFileName( filename ) + ".js";

return Result.Succeeded;
}
if( !SelectFile( ref _output_folder_path,
ref filename ) )
{
return Result.Cancelled;
}
else

filename = Path.Combine( _output_folder_path,
filename );

// Ask user whether to interactively choose
// which parameters to export or just export
// them all.

TaskDialog td = new TaskDialog( "Ask user to filter parameters" );
td.Title = "Filter parameters";
td.CommonButtons = TaskDialogCommonButtons.No | TaskDialogCommonButtons.Yes;
td.MainInstruction = "Do you want to filter the parameters of the objects to be exported?";
td.MainContent = "Click Yes and you will be able to select parameters for each category in the next window";
td.AllowCancellation = true;
td.VerificationText = "Check this to include type properties";

if( TaskDialogResult.Yes == td.Show() )
{
Util.ErrorMsg(
"You must be in a 3D view to export." );
filterElementParameters( doc, td.WasVerificationChecked() );
if( ParameterFilter.status == "cancelled" )
{
ParameterFilter.status = "";
return Result.Cancelled;
}
}
return Result.Failed;

// Save file.

ExportView3D( doc.ActiveView as View3D,
filename );

return Result.Succeeded;
}
}
}

0 comments on commit ec74ce6

Please sign in to comment.