├── .gitignore
├── CodeToRunRemotely
├── CodeToRunRemotely.csproj
├── Command.cs
└── Properties
│ └── AssemblyInfo.cs
├── README
├── RemoteDependencies
├── IRemoteCommand.cs
├── Properties
│ └── AssemblyInfo.cs
├── RemoteDependencies.csproj
└── RevitQueueItem.cs
├── RevitRemoteBoot
├── AutoHotkey.ahk
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── RevitRemoteBoot.csproj
├── RevitRemoteRunner.sln
├── RevitRemoteRunner
├── Properties
│ └── AssemblyInfo.cs
├── RemoteRunner-Manifest.addin
├── RemoteRunner.cs
└── RevitRemoteRunner.csproj
└── ScheduledExport
├── Command.cs
├── Properties
└── AssemblyInfo.cs
└── ScheduledExport.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #ignore thumbnails created by windows
3 | Thumbs.db
4 | #Ignore files build by Visual Studio
5 | *.obj
6 | *.exe
7 | *.pdb
8 | *.user
9 | *.aps
10 | *.pch
11 | *.vspscc
12 | *_i.c
13 | *_p.c
14 | *.ncb
15 | *.suo
16 | *.tlb
17 | *.tlh
18 | *.bak
19 | *.cache
20 | *.ilk
21 | *.log
22 | [Bb]in
23 | [Dd]ebug*/
24 | *.lib
25 | *.sbr
26 | obj/
27 | [Rr]elease*/
28 | _ReSharper*/
29 | [Tt]est[Rr]esult*
--------------------------------------------------------------------------------
/CodeToRunRemotely/CodeToRunRemotely.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}
9 | Library
10 | Properties
11 | CodeToRunRemotely
12 | CodeToRunRemotely
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2012\Program\RevitAPI.dll
36 | False
37 |
38 |
39 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2012\Program\RevitAPIUI.dll
40 | False
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}
56 | RemoteDependencies
57 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------
/CodeToRunRemotely/Command.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net.Mail;
6 | using System.Text;
7 | using Autodesk.Revit.DB;
8 | using Autodesk.Revit.UI;
9 | using RevitRemoteRunner;
10 |
11 | namespace CodeToRunRemotely
12 | {
13 | public class Command : IExternalCommand, IRemoteCommand
14 | {
15 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
16 | {
17 | return RunRemotely(commandData.Application.ActiveUIDocument.Document);
18 | }
19 |
20 | public Result RunRemotely(Document document)
21 | {
22 | FilteredElementCollector collector = new FilteredElementCollector(document);
23 | ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns);
24 | TextWriter writer = new StreamWriter(@"C:\ColumnOutput.txt", true);
25 | writer.WriteLine("Column IDs");
26 |
27 | foreach (Element e in collector.WherePasses(filter))
28 | {
29 | writer.WriteLine(e.Name + " " + e.Id);
30 | }
31 | writer.WriteLine("Written: " + DateTime.Now);
32 | writer.Close();
33 | return Result.Succeeded;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/CodeToRunRemotely/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CodeToRunRemotely")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("CodeToRunRemotely")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8d836a4c-57fc-4ae3-9d45-ae6c0a0e95e7")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RodH257/RevitRemoteBoot/6befc16b74e4b22fa5ad6fe6d734b6b78986184a/README
--------------------------------------------------------------------------------
/RemoteDependencies/IRemoteCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Autodesk.Revit.ApplicationServices;
6 | using Autodesk.Revit.DB;
7 | using Autodesk.Revit.UI;
8 |
9 | namespace RevitRemoteRunner
10 | {
11 | public interface IRemoteCommand
12 | {
13 | Result RunRemotely(Document document);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/RemoteDependencies/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RemoteDependencies")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("RemoteDependencies")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("113376ca-51a3-4d0e-a013-d3155763717e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RemoteDependencies/RemoteDependencies.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}
9 | Library
10 | Properties
11 | RemoteDependencies
12 | RemoteDependencies
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2012\Program\RevitAPI.dll
36 | False
37 |
38 |
39 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2012\Program\RevitAPIUI.dll
40 | False
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
62 |
--------------------------------------------------------------------------------
/RemoteDependencies/RevitQueueItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.Serialization;
6 | using System.Text;
7 | using System.Xml.Serialization;
8 |
9 | namespace RemoteDependencies
10 | {
11 | ///
12 | /// Represents a class that will hold a queue item fo rrevit ro read
13 | /// when it is initialized by the remote boot sequence.
14 | ///
15 | [Serializable()]
16 | public class RevitQueueItem
17 | {
18 | ///
19 | /// Location of the revit file to perform the operations on
20 | ///
21 | public string RevitFileLocation { get; set; }
22 |
23 | ///
24 | /// Locations of the dll that contains the operation to preform
25 | ///
26 | public string DllLocation { get; set; }
27 |
28 | ///
29 | /// Class name from the dll file that contains the code to run
30 | /// Must implement IRemoteCommand
31 | ///
32 | public string ClassName { get; set; }
33 |
34 | ///
35 | /// A list of extra custom arguments to present to revit
36 | /// may be used in running the actual tool itself
37 | ///
38 | public List CustomArgs { get; set; }
39 |
40 | ///
41 | /// The location of the dropzone, should be constant generally
42 | ///
43 | public string DropZoneLocation { get; set; }
44 |
45 | ///
46 | /// A unique identifier for the queue item so that multiple instances of the same
47 | /// command may be stored in the dropzone.
48 | ///
49 | public Guid Identifier { get; set; }
50 |
51 | ///
52 | /// Stores the full path the the queue item
53 | ///
54 | public string QueueItemPath { get; set; }
55 |
56 | public RevitQueueItem()
57 | {
58 |
59 | }
60 | public RevitQueueItem(string revitFileLocation, string dllLocation,
61 | string className, Guid identifier, string dropZoneLocation)
62 | {
63 | RevitFileLocation = revitFileLocation;
64 | DllLocation = dllLocation;
65 | ClassName = className;
66 | Identifier = identifier;
67 | DropZoneLocation = dropZoneLocation;
68 | CustomArgs = new List();
69 | QueueItemPath = Path.Combine(DropZoneLocation, Identifier + ".rrb");
70 | }
71 |
72 | ///
73 | /// Adds a custom argument to the item
74 | ///
75 | ///
76 | public void AddArgument(string argument)
77 | {
78 | CustomArgs.Add(argument);
79 | }
80 |
81 | ///
82 | /// Serializes the class into the drop zone, names it by the guid.
83 | ///
84 | public void SaveToDropZone()
85 | {
86 | XmlSerializer xmlSerializer = new XmlSerializer(this.GetType());
87 | StreamWriter writer = new StreamWriter(this.QueueItemPath, false);
88 | xmlSerializer.Serialize(writer, this);
89 | writer.Close();
90 | }
91 |
92 |
93 | ///
94 | /// Marks the item as complete
95 | ///
96 | public void MarkComplete()
97 | {
98 | File.Delete(this.QueueItemPath);
99 |
100 | }
101 |
102 | ///
103 | /// Checks if the action has been completed yet or not.
104 | ///
105 | ///
106 | public bool CheckComplete()
107 | {
108 | return !File.Exists(this.QueueItemPath);
109 | }
110 |
111 | ///
112 | /// Checks if the queue item is intended for a certain file.
113 | ///
114 | ///
115 | ///
116 | public bool IsValidForFile(string revitFile)
117 | {
118 | return revitFile.ToLower().Equals(this.RevitFileLocation.ToLower());
119 |
120 | }
121 |
122 | ///
123 | /// Deserializes the queue items from the specified drop zone.
124 | ///
125 | /// drop zone
126 | ///
127 | public static IList ReadItemsFromDropZone(string dropZoneLocation)
128 | {
129 | IList items = new List();
130 |
131 | //TODO: Make it properly check the file format before loading in.
132 | foreach (string fileName in Directory.GetFiles(dropZoneLocation, "*.rrb"))
133 | {
134 | XmlSerializer serializer = new XmlSerializer(typeof (RevitQueueItem));
135 | StreamReader reader = new StreamReader(fileName);
136 | RevitQueueItem item = serializer.Deserialize(reader) as RevitQueueItem;
137 | items.Add(item);
138 | reader.Close();
139 | }
140 | return items;
141 | }
142 |
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/RevitRemoteBoot/AutoHotkey.ahk:
--------------------------------------------------------------------------------
1 | #Persistent
2 | SetTimer, MsgBoxCheck, 1000
3 |
4 | MsgBoxCheck:
5 |
6 | If WinExist("Copied Central Model")
7 | {
8 | #IfWinActive Revit
9 | WinClose
10 | ExitApp
11 | }
12 |
--------------------------------------------------------------------------------
/RevitRemoteBoot/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading;
8 | using RemoteDependencies;
9 |
10 | namespace RevitRemoteBoot
11 | {
12 | class Program
13 | {
14 | static void Main(string[] args)
15 | {
16 | //check the arguments
17 | if (args.Length < 4)
18 | {
19 | Console.WriteLine("Need to input Revit Server Path " +
20 | " + Export File Location + DLL + Class Name");
21 | return;
22 | }
23 |
24 | //read parameters
25 | string revitServerPath = args[0];
26 | string revitFile = args[1];
27 | string revitDir = Path.GetDirectoryName(revitFile);
28 | string dllFile = args[2];
29 | string className = args[3];
30 | Guid uniqueId = Guid.NewGuid();
31 |
32 | //drop zone location - should be kept somewhere else
33 | string dropZoneLocation = @"C:\RRBTest\";
34 |
35 |
36 | RevitQueueItem item = new RevitQueueItem(revitFile, dllFile, className,
37 | uniqueId, dropZoneLocation);
38 |
39 | //read any custom parameters that may have been added
40 | for (int i = 3; i < args.Length; i++)
41 | {
42 | string customArgument = args[i];
43 | item.AddArgument(customArgument);
44 | }
45 |
46 | item.SaveToDropZone();
47 |
48 | string revitToolLocation =
49 | @"C:\Program Files\Autodesk\Revit Structure 2012\Program\RevitServerToolCommand\RevitServerTool.exe";
50 |
51 | string arguments = "createLocalRVT " + revitServerPath + " -d " + revitFile + " -s localhost -o";
52 |
53 |
54 | Console.WriteLine("Running RevitServerToolCommand with arguments " + arguments);
55 | //create local file if its on a revit server using the revit server command line tool
56 | Process revitServerProcess = new Process();
57 | revitServerProcess.StartInfo = new ProcessStartInfo();
58 | revitServerProcess.StartInfo.UseShellExecute = true;
59 | revitServerProcess.StartInfo.WorkingDirectory = revitDir;
60 | revitServerProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
61 | revitServerProcess.StartInfo.FileName = revitToolLocation;
62 | revitServerProcess.StartInfo.Arguments = arguments;
63 | revitServerProcess.Start();
64 |
65 |
66 | //wait no longer than a minute for it to create a local file
67 | //if it takes too long, cancel it
68 | if (!revitServerProcess.WaitForExit(60 * 1000))
69 | {
70 | Console.WriteLine("Local file creation failed");
71 | return;
72 | } else
73 | {
74 | Console.WriteLine("Created local file at " + revitFile);
75 | }
76 |
77 | //start Revit and open the file
78 | Process p = new Process();
79 | p.StartInfo = new ProcessStartInfo();
80 | p.StartInfo.UseShellExecute = true;
81 | p.StartInfo.WorkingDirectory = revitDir;
82 | p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
83 | p.StartInfo.FileName = revitFile;
84 | p.Start();
85 |
86 | //wait for command to run and marked complete
87 | int loopCount = 0;
88 | //max of 500 seconds
89 | while (loopCount < 100 && !item.CheckComplete())
90 | {
91 | //sleep 5 seconds
92 | Thread.Sleep(5000);
93 | }
94 | p.Kill();
95 | //close revit
96 | p.Close();
97 |
98 |
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/RevitRemoteBoot/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RevitRemoteBoot")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("RevitRemoteBoot")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("74715ae9-bef2-49db-9f57-b1d100abe0c1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RevitRemoteBoot/RevitRemoteBoot.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}
9 | Exe
10 | Properties
11 | RevitRemoteBoot
12 | RevitRemoteBoot
13 | v3.5
14 | 512
15 |
16 |
17 | x86
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x86
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}
50 | RemoteDependencies
51 |
52 |
53 |
54 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/RevitRemoteRunner.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitRemoteRunner", "RevitRemoteRunner\RevitRemoteRunner.csproj", "{45590A61-1690-4642-BD92-0F65262A61F6}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeToRunRemotely", "CodeToRunRemotely\CodeToRunRemotely.csproj", "{DF70AAE9-11D3-4E13-8716-3BAFAE182E07}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteDependencies", "RemoteDependencies\RemoteDependencies.csproj", "{4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitRemoteBoot", "RevitRemoteBoot\RevitRemoteBoot.csproj", "{B2AA7672-49E9-4873-BD6A-545E3CEF8483}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScheduledExport", "ScheduledExport\ScheduledExport.csproj", "{2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Debug|Mixed Platforms = Debug|Mixed Platforms
18 | Debug|x86 = Debug|x86
19 | Release|Any CPU = Release|Any CPU
20 | Release|Mixed Platforms = Release|Mixed Platforms
21 | Release|x86 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {45590A61-1690-4642-BD92-0F65262A61F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {45590A61-1690-4642-BD92-0F65262A61F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {45590A61-1690-4642-BD92-0F65262A61F6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
27 | {45590A61-1690-4642-BD92-0F65262A61F6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
28 | {45590A61-1690-4642-BD92-0F65262A61F6}.Debug|x86.ActiveCfg = Debug|Any CPU
29 | {45590A61-1690-4642-BD92-0F65262A61F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {45590A61-1690-4642-BD92-0F65262A61F6}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {45590A61-1690-4642-BD92-0F65262A61F6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
32 | {45590A61-1690-4642-BD92-0F65262A61F6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
33 | {45590A61-1690-4642-BD92-0F65262A61F6}.Release|x86.ActiveCfg = Release|Any CPU
34 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
37 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
38 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Debug|x86.ActiveCfg = Debug|Any CPU
39 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
42 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Release|Mixed Platforms.Build.0 = Release|Any CPU
43 | {DF70AAE9-11D3-4E13-8716-3BAFAE182E07}.Release|x86.ActiveCfg = Release|Any CPU
44 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
47 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
48 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Debug|x86.ActiveCfg = Debug|Any CPU
49 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
50 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Release|Any CPU.Build.0 = Release|Any CPU
51 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
52 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
53 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}.Release|x86.ActiveCfg = Release|Any CPU
54 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Debug|Any CPU.ActiveCfg = Debug|x86
55 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
56 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Debug|Mixed Platforms.Build.0 = Debug|x86
57 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Debug|x86.ActiveCfg = Debug|x86
58 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Debug|x86.Build.0 = Debug|x86
59 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Release|Any CPU.ActiveCfg = Release|x86
60 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Release|Mixed Platforms.ActiveCfg = Release|x86
61 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Release|Mixed Platforms.Build.0 = Release|x86
62 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Release|x86.ActiveCfg = Release|x86
63 | {B2AA7672-49E9-4873-BD6A-545E3CEF8483}.Release|x86.Build.0 = Release|x86
64 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
67 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
68 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Debug|x86.ActiveCfg = Debug|Any CPU
69 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Release|Any CPU.ActiveCfg = Release|Any CPU
70 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Release|Any CPU.Build.0 = Release|Any CPU
71 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
72 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
73 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}.Release|x86.ActiveCfg = Release|Any CPU
74 | EndGlobalSection
75 | GlobalSection(SolutionProperties) = preSolution
76 | HideSolutionNode = FALSE
77 | EndGlobalSection
78 | EndGlobal
79 |
--------------------------------------------------------------------------------
/RevitRemoteRunner/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RevitRemoteRunner")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("RevitRemoteRunner")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7492e4ea-487e-487c-95f2-3360dc870e64")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RevitRemoteRunner/RemoteRunner-Manifest.addin:
--------------------------------------------------------------------------------
1 |
2 |
3 | C:\RRBTest\Addins\RevitRemoteRunner.dll
4 | dbc41e1e-e048-481c-9aa7-283ad64e8ef3
5 | RODH
6 | Revit Remote Runner
7 | Rod Howarth
8 | RevitRemoteRunner.RemoteRunner
9 |
10 |
--------------------------------------------------------------------------------
/RevitRemoteRunner/RemoteRunner.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Text;
8 | using Autodesk.Revit.DB;
9 | using Autodesk.Revit.UI;
10 | using Autodesk.Revit.Attributes;
11 | using RemoteDependencies;
12 |
13 | namespace RevitRemoteRunner
14 | {
15 | ///
16 | /// Processes a queue that is present in XML files in a dropzone
17 | /// Reads these files and looks for the DLl they reference
18 | /// casts those DLL's to IRemoteCommand and runs them.
19 | /// Marks complete when finished.
20 | ///
21 | [Regeneration(RegenerationOption.Manual)]
22 | [Transaction(TransactionMode.Manual)]
23 | public class RemoteRunner : IExternalApplication
24 | {
25 | ///
26 | /// Register the events on startup
27 | ///
28 | ///
29 | ///
30 | public Result OnStartup(UIControlledApplication application)
31 | {
32 | application.ControlledApplication.DocumentOpened += new EventHandler(ControlledApplication_DocumentOpened);
33 | return Result.Succeeded;
34 | }
35 |
36 | ///
37 | /// When the document is opened, cehck the dropzone and process the queue.
38 | ///
39 | ///
40 | ///
41 | void ControlledApplication_DocumentOpened(object sender, Autodesk.Revit.DB.Events.DocumentOpenedEventArgs e)
42 | {
43 | //check for files in drop zone accessor dir
44 |
45 | string dropZoneDir = @"C:\RRBTest\";
46 |
47 | try
48 | {
49 | //check for queue files to run
50 | foreach (RevitQueueItem item in RevitQueueItem.ReadItemsFromDropZone(dropZoneDir))
51 | {
52 | if (item.IsValidForFile(e.Document.PathName))
53 | {
54 | ProcessQueueItem(item, e.Document);
55 | }
56 | }
57 | } catch (Exception ex)
58 | {
59 | TaskDialog.Show("Error", ex.ToString());
60 | }
61 | }
62 |
63 | ///
64 | /// Performs the actions on a certain queue item.
65 | ///
66 | ///
67 | ///
68 | private void ProcessQueueItem(RevitQueueItem item, Document doc)
69 | {
70 | string dllLocation = item.DllLocation;
71 | string className = item.ClassName;
72 | //foreach of those.
73 | //load the dll with reflection
74 | Type type = LoadDllWithReflection(dllLocation, className);
75 | IRemoteCommand command = GetCommandFromType(type);
76 |
77 | //Check for transaction attribute, start one if automatic
78 | Transaction transaction = StartAutomaticTransaction(type, doc);
79 |
80 | //run the execute method
81 | Result result = command.RunRemotely(doc);
82 |
83 | //close the transaction
84 | if (transaction != null && result == Result.Succeeded)
85 | transaction.Commit();
86 |
87 | if (transaction != null && (result == Result.Cancelled || result == Result.Failed))
88 | transaction.RollBack();
89 |
90 | item.MarkComplete();
91 |
92 | }
93 |
94 | ///
95 | /// Checks for and starts automatic transaction
96 | ///
97 | ///
98 | ///
99 | ///
100 | private Transaction StartAutomaticTransaction(Type type, Document doc)
101 | {
102 | //check for transactionmode attribute, if automatic, start one
103 | Attribute[] attrs = Attribute.GetCustomAttributes(type);
104 |
105 | Transaction transaction = null;
106 | //start transaction
107 | foreach (Attribute attr in attrs)
108 | {
109 | if (attr is TransactionAttribute)
110 | {
111 | TransactionAttribute transAt = (TransactionAttribute)attr;
112 | if (transAt.Mode == TransactionMode.Automatic)
113 | {
114 | //needs automatic transaction mode.
115 | transaction = new Transaction(doc);
116 | transaction.Start("Remote Runner");
117 | }
118 | }
119 | }
120 | return transaction;
121 | }
122 |
123 | ///
124 | /// Uses reflection to load the dll
125 | ///
126 | ///
127 | ///
128 | ///
129 | private Type LoadDllWithReflection(string dllLocation, string className)
130 | {
131 | Assembly assembly = Assembly.LoadFrom(dllLocation);
132 | Type type = assembly.GetType(className);
133 | try
134 | {
135 | foreach (Type t in assembly.GetTypes())
136 | {
137 | if (t.FullName.EndsWith(className))
138 | type = t;
139 | }
140 | }
141 | catch (ReflectionTypeLoadException ex)
142 | {
143 | var exceptions = ex.LoaderExceptions;
144 | foreach (var failedType in ex.Types)
145 | {
146 | if (failedType != null)
147 | Debug.WriteLine(failedType.FullName);
148 | }
149 | foreach (Exception loadException in exceptions)
150 | {
151 | Debug.WriteLine(loadException.ToString());
152 | }
153 | }
154 | return type;
155 | }
156 |
157 | ///
158 | /// Gets the command from type
159 | ///
160 | ///
161 | ///
162 | private IRemoteCommand GetCommandFromType(Type type)
163 | {
164 | IRemoteCommand command = Activator.CreateInstance(type) as IRemoteCommand;
165 | if (command == null)
166 | throw new Exception("Could not get Remote Command");
167 |
168 | return command;
169 | }
170 |
171 | ///
172 | /// Clean up on shut down
173 | ///
174 | ///
175 | ///
176 | public Result OnShutdown(UIControlledApplication application)
177 | {
178 | application.ControlledApplication.DocumentOpened -= ControlledApplication_DocumentOpened;
179 | return Result.Succeeded;
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/RevitRemoteRunner/RevitRemoteRunner.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {45590A61-1690-4642-BD92-0F65262A61F6}
9 | Library
10 | Properties
11 | RevitRemoteRunner
12 | RevitRemoteRunner
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2012\Program\RevitAPI.dll
37 | False
38 |
39 |
40 | False
41 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2012\Program\RevitAPIUI.dll
42 | False
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}
58 | RemoteDependencies
59 |
60 |
61 |
62 |
63 |
64 |
65 |
72 |
--------------------------------------------------------------------------------
/ScheduledExport/Command.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using Autodesk.Revit.Attributes;
7 | using Autodesk.Revit.DB;
8 | using Autodesk.Revit.UI;
9 | using RevitRemoteRunner;
10 |
11 | namespace ScheduledExport
12 | {
13 | [Regeneration(RegenerationOption.Manual)]
14 | [Transaction(TransactionMode.Automatic)]
15 | public class Command : IExternalCommand, IRemoteCommand
16 | {
17 | public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
18 | {
19 | return RunRemotely(commandData.Application.ActiveUIDocument.Document);
20 | }
21 |
22 | public Result RunRemotely(Document document)
23 | {
24 | FilteredElementCollector collector = new FilteredElementCollector(document);
25 | collector.OfClass(typeof(ViewSheet));
26 |
27 | ViewSet set = new ViewSet();
28 | foreach (View view in collector)
29 | {
30 | set.Insert(view);
31 | }
32 | DWFXExportOptions options = new DWFXExportOptions();
33 | options.MergedViews = true;
34 | options.ImageQuality = DWFImageQuality.High;
35 | options.ExportObjectData = true;
36 |
37 | document.Export(@"C:\RRBTest\", "TestExport.dwfx", set, options);
38 | return Result.Succeeded;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ScheduledExport/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ScheduledExport")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("ScheduledExport")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("360c76c6-9c4d-4093-bc7f-6cbcdfe0c08a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ScheduledExport/ScheduledExport.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {2CB8F96D-1502-436C-91CE-B3E8F1DFF45E}
9 | Library
10 | Properties
11 | ScheduledExport
12 | ScheduledExport
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2011\Program\RevitAPI.dll
36 | False
37 |
38 |
39 | ..\..\..\..\Program Files\Autodesk\Revit Structure 2011\Program\RevitAPIUI.dll
40 | False
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | {4A67771C-F3E4-4AC8-8AD6-D68096F0BAB9}
56 | RemoteDependencies
57 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------